I want to load a scene when my player enters a specific location on the map. I cannot get it to work no matter what I try.
@noonanboys I don’t know what what exactly you have tried but this should work.
Make an empty gameobject setup a box collider2d on trigger. And just attach the script:
//MAKE SURE TO ADD NAMESPACE "Using UnityEngine.SceneManagement"
//MAKE SURE TO TAG THE PLAYER
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag=="Player")
{
SceneManager.LoadScene("scenename");
}
}
**Also if you don’t know: when loading a new scene unity destroys the current scene so make sure to have “DontDestroyOnLoad” on all the gameobjects that you will need on your next scene ie; player and transfer those gameobjects to next scene. OR you can use LoadSceneMode.Additve depends on what you are trying to do. Know more about this Here : unity - What is the different between "LoadSceneMode.Additive" and "LoadSceneMode.Single"? - Game Development Stack Exchange **