- Home /
Question by
jeremy · Jun 13, 2012 at 07:09 PM ·
collisiongameobject
How to make scene restart on collision.
Hi I need to know how to restart a specific scene on collsion. For example, I have a game were I have turrets and robots shooting spheres at my FirstPersonController, and I want the whole scene to restart if my player gets hit by one. And I need it to only restart my scene if it hits my player so if you can please help me it would be great.
Heres the information you might need: Player name: First Person Controller. Scene name(this is the name of the scene I want to restart): Unity3dArrowGusherScene5. Laser name(this will be the thing that if the player gets hit by it the scene will restart): LaserSphere.
Comment
Answer by Sokco816 · Jun 13, 2012 at 07:52 PM
Add this snippet of code to your character:
function OnCollisionEnter(other : Collision){
if(other.gameObject.name == "LaserSphere")
Application.LoadLevel ("Unity3dArrowGusherScene5");
}
Good luck on the project!