Make the game restart if you get hit by wall

So, I would like to know how to make the game restart once my player hits a wall. My player is a rolling ball, and I’m new to scripting. If the rolling ball bumps into one of the walls around the edge of the level, I need the game to restart back to the beginning of the level. If anyone could help me write a script to do this, that would be great. I’m sure it’s not too hard, but what do I know.

Hi there,

You could make something to detect if the wall is hit or not. Then make a code that indicated what should happen if this is indeed the case.

From the top of my head you could make something like this:

  • give your wall object a collider and call it for example “Collision”.
  • give your player (your ball in your case) a new tag called “Player”.

function OnCollisionEnter(collision : Collision)




Application.LoadLevel(“your scene name that you would like to load”);

print(“go to a level”);