场景中创建一个空对象

添加碰撞盒

挂载脚本

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);
    }
    
}

附完整教程:

Unity2d Rubys Adventure 课程设计报告

posted on 2020-06-11 01:00  海月CSDN  阅读(675)  评论(0编辑  收藏  举报