- Home /
How do I restart a scene after a collision?
I am creating a game, and I cannot find a way to restart a scene after a collision. I want to restart the scene when a ball collides with a different ball, I have tried many different scripts, but nothing I use works.
Answer by getyour411 · Jan 11, 2015 at 05:02 AM
http://answers.unity3d.com/questions/64395/reload-current-level-when-i-die.html
Asked/answered many time, please search first or better define what you have tried/why this is different than so many others like it.
Thanks for the help, but the script I created still is not working, and i can't figure out what is wrong.
pragma strict
function Start () { UnityEngine.Component; if (Collision.gameObject.name == "Ball") Application.LoadLevel(Application.loadedLevel); }
move that to Update, Start is only called once at instantiate unlikely the ball collision will be true at that point
it says Expressions in statements must only be executed for their side-effects. After applying what you said, I do not know how to fix that I am a novice at the whole coding thing
It now says the reference script is missing. Is it obvious i have no idea what i am doing.
Answer by Digital-Phantom · Jan 11, 2015 at 05:29 AM
I think it's your capitalisation. Shouldn't your Collision.gameObject.name blablabla actually be Collision.GameObject.name (swap your small g for a capital G)
I assumed this was pseudo code; OP look at this
http://unity3d.com/learn/tutorials/modules/beginner/physics/on-collision-enter
Your answer
Follow this Question
Related Questions
How to load a scene on collision 2 Answers
Scene Audio Script Error 2 Answers
moving to next scene 1 Answer
Endless DeathZone??!!? 4 Answers
Teleporter 2 Answers