场景中创建一个空对象
添加碰撞盒
挂载脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class NextMission : MonoBehaviour
{
Rigidbody2D rbody;
// Start is called before the first frame update
void Start()
{
rbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
}
public void OnCollisionEnter2D(Collision2D collision)
{
if (PlayerControl.showflag == 1) ;
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
附完整教程:
原博地址
https://blog.csdn.net/weixin_43673589