Question by
edmund20101 · Feb 22, 2021 at 03:00 PM ·
collision2dreloading
Collision with enemy not working after reload the scene
I know there's something wrong with my code, but i can't seem to find it. The character is able to collide with the enemy after i loaded the scene initially but after i reload it. The enemy will just pass through the character. Here's my code:
PlayerManager Script: public void OnCollisionEnter2D(Collision2D collision) {
//normal version
if (collision.gameObject.tag.Equals("Enemy") && mask == false && sprayCount == 0)
{
NormalVersion();
--health;
StartCoroutine("NormalInvincible");
if(health > 0)
{
hurtSound.GetComponent<AudioSource>().Play();
}
else
{
gameOverSound.Play();
LoseGame();
}
}
}
And here's my sceneManager Script: public void RestartLV() { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); }
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613025617im_/https://answers.unity.com/themes/thub/images/avi.jpg)