Search code examples
javascriptunity-game-engineunityscript

Unity: the sprite won't die on my cactus. Why?


So, I want the game to go to Level 2 when the sprite in the suit collides with the cactus.

Why won't this work? This code is attached to the cacti.

function OnTriggerEnter2D(collider : Collider2D) {
    Application.LoadLevel(2);
}

enter image description here enter image description here


Solution

  • Try OnTriggerEnter2D , and put this function inside the cactus .