- Home /
My Js Script is not working
Hi everyone, I am really bad at scripting and I want to know what to do to make this simple script work.
function Update ()
{OnCollisionEnter=
Application.LoadLevel(1);
}
I want to make it so that when something collides with a particular object it will load the next level. I know it is a dumb question but any help would be awsome.
Answer by save · Sep 26, 2011 at 09:03 AM
There's nothing as a dumb question.
Try this out:
function OnCollisionEnter () {
Application.LoadLevel(1);
}
Remove the Update () and only do the above. If the object is set to trigger then use OnTriggerEnter
instead. Remember that they are separate functions and they can't run inside Update.
If you only want a specific object by tag trigger the level loading then add:
function OnCollisionEnter (collision : Collision) {
if (collision.collider.tag!="The Tag") return;
Application.LoadLevel(1);
}
If it is a trigger then use this instead:
function OnTriggerEnter (other: Collider) {
if (!other.CompareTag("The Tag")) return;
Application.LoadLevel(1);
}
Your answer
Follow this Question
Related Questions
What is the best way to script third person real-time action melee combat in C#? 0 Answers
My bullet wont move forward 1 Answer
Trigger respawn after collision? 3 Answers
enable / disable particle system 1 Answer
How to load a scene on collision 2 Answers