I use the following script:
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Enemy")
{
Destroy(this.gameObject);
Application.LoadLevel(Application.loadedLevel);
}
}
The problem is that the collision only causes the player’s death if he moves into the enemy. If it’s the enemy who moves into the player nothing happens - the enemy just stands next to the player.
Any idea why this is happening?
@Matt5 Application.LoadLevel(Application.loadedLevel); will correctly reload the last level played. BTW, am I the only one bothered by the 1-Destroy(this) then 2-LoadLevel()?
– by0log1cDestroy wait the end of the frame to do its job. So nothing is wrong here.
– Berenger