Load scene when colliding on GameObject

I’ve been looking for a few tutorials and other Unity Learn documentations, I couldn’t find what I was exactly looking for. My script doesn’t have errors, but it doesn’t work at all.

So, I have my character ready, a few GameObjects and a “Game Over” scene. Whenever I collide with red sphere (otherwise called, “GravityBall_Red”), I should be in the “Game Over” scene (called “LevelRetry”). Now here’s the script:

function OnCollisionEnter(other : Collision){
if(other.gameObject.name == "GravityBall_Red")
Application.LoadLevel ("LevelRetry");
}

If there’s anything else you guys should need, I’d be good to give you a little more info.

Thanks

Hi Crush,

So, based on your code, I can only say that the problem is that you’re not even detecting the collision, for some reason.
Are you sure your condition is being reached? I mean, if you debug inside the if condition, it’d be reached?

There are some details about collisions you should pay attention to, but the most important is that the gameobject from the script you’re verifying collision must have Rigidbody component.

Can you check that?