I know this is a common question, but I still haven’t find an answer for it. So basically I attach this script to a 2D object
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
public class SwitchScene : MonoBehaviour {
public string level = "testingscene2";
// Use this for initialization
void TriggerEnter2D (Collision2D Colider){
if(Colider.gameObject.tag == "Player")
SceneManager.LoadScene(sceneName: "Platformer2");
}
void Start () {
}
// Update is called once per frame
void Update () {
}
}
I’m trying to make it so that when the player touches this object, the scene will change. But so far the only result I have got is “The referenced script on this Behavior is missing”. And when I checked out the script in the inspector, I got " The associated script can not be loaded. Please fix any compile errors and assign a valid script ". What seems to be the problem here?