Question by
KokodokoGames · Feb 16, 2018 at 05:05 PM ·
ontriggerenterscene-loadingscene-switching
OnTriggerEnter2D stops working when loading a new scene
I have a scene where a player character picks up a coin. The coin has OnTriggerEnter2D to see if the player picks it up.
This works in Scene one, but not in any other scene that also has coins and a player. Everything is made with prefabs so the player, the coin and the script is exactly the same in both scenes.
How do I fix this?
void OnTriggerEnter2D(Collider2D coll)
{
Debug.Log("coin trigger " + coll.gameObject.tag);
if (coll.gameObject.tag == "Player")
{
Debug.Log("why is this not working in scene two?");
Debug.Log(gameObject);
GameScript.instance.UpdateScore(1);
GameScript.instance.PlaySound(geluid);
Destroy(gameObject);
}
}
Comment
Your answer
Follow this Question
Related Questions
Scene takes too long to load 1 Answer
scene transition 0 Answers
Game build often crashes when switching scenes 0 Answers
Fade between scenes 0 Answers
Event when the scene is loaded 1 Answer