Collision2D not working after switching scenes.
So what happens is that I have 2 sprites, a player and an enemy. The moment you hit the enemy the collision gets detected, you then have to fill in an answer. If your answer is wrong you switch to the main menu scene by using SceneManager.LoadSceneAsync(0);
Cool. Back in the main menu, then we can switch back to the game again by using SceneManager.LoadSceneAsync(1);
But at this point the collision is not working. I have checked everything in the editor, everything appears the same besides the "InstanceID". Both sprites have a 'BoxCollider2D' with trigger enabled and a 'Rigidbody2D'. So it works, but after switching scenes it dies. But iirc the whole scene gets completely build from scratch, unless told otherwise in code.
Answer by Spookles · Nov 29, 2017 at 07:30 AM
Found my answer, I set Time.TimeScale = 0
but after a scene reset the timescale does NOT go back to 1, it was confusing for me as I used lerp
to move the player to my mouse and that kept working. Expected that it would go to pause aswell.
Answer by Danteg23 · Nov 25, 2017 at 03:25 PM
Hi man, I also having the same problem, after my player dies, menu pops up and If I press restart (the scene will be reloaded), collision on my player doesn't work, so
OnCollisionEnter2D
Function won't see player anymore, but
OnTriggerEnter2D
Function works fine, and after OnTriggerEnter2D
triggers, then collision start work on my player, I've spent few weeks, but still couldn't find any solution for this. Btw, If I'll press restart button with delay, collision will work fine. Is it some bug? Or I miss smt?
I'll try installing an older version of Unity as I'm running on 2017.2, will post updates as soon as I have them.