Back to Browse

Unity - How to change level using a collision and FPScontroller

17.2K views
May 8, 2018
12:14

In this tutorial, we will be creating a collision that will allow us to change from level 1 to level 2 (SceneManager.LoadScene). The FPSController will be used to move around the project and run into a door to change to a new level. Add the following lines of code to the module asset list at the top: using UnityEngine.SceneManagement; Remember: to add a BOX COLLIDER to the FPS Controller if you are having issues. This project starts from scratch and shows you how to create a simple project that you can develop. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class CollisonSceneChange : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } void OnCollisionEnter(Collision col) { { Debug.Log("Collision Detected It Works"); SceneManager.LoadScene("Your Scene Name"); } } }

Download

0 formats

No download links available.

Unity - How to change level using a collision and FPScontroller | NatokHD