Unity 进入下一关

场景中创建一个空对象

添加碰撞盒

挂载脚本

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

    // 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 课程设计报告

你可能感兴趣的:(Unity,游戏设计)