- Home /
When ai touches gameobject reset scene. The code does not work any suggestions
#pragma strict
var collisionObject : GameObject;
function OnCollisionEnter(collision : Collision){
if (collision.gameObject.name == collisionObject){
Application.LoadLevel("0");
}
}
function Update () {
}
Comment
Answer by GregoryNeal · May 06, 2015 at 02:13 AM
You're checking to see if the collision gameObject's name is equal to the collisionObject gameObject. You need to remove the .name from your if statement and just compare the two objects.
It has no errors, but the scene does not reset when the AI touches the first person controller
Answer by scarletshark · May 06, 2015 at 03:16 AM
Use the following:
var collisionObject : GameObject;
function OnCollisionEnter(collision : Collision)
{
if (collision.gameObject == collisionObject)
{
Application.LoadLevel(0);
}
}
Your answer
Follow this Question
Related Questions
Reset a scene 2 Answers
Objects still in scene on loadscene? (creating objects on destroy?) 0 Answers
need to refind script execution order from before crashing without touching to other settings 0 Answers
Playing Music After Seconds Works, But When Scene Reloads, Script Doesn't Work 1 Answer
Reload scene when dead 5 Answers