- Home /
Question by
Veasy62 · May 21, 2015 at 03:23 PM ·
sceneresetrestart game
I created a maze game where the ai uses a pathfinder to find the MainCharacter. I want when the ai touches the MainCharacter(First Person Controller), then reset the game. I have gotten help on my code a few time but the code never works.
The First Person controller has a Character Controller and the ai has a Capsule Collider. ][1]
pragma strict![
var collisionObject : GameObject;
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject == collisionObject)
{
Application.LoadLevel("Maze.unity");
}
}
Comment
Answer by FortisVenaliter · May 21, 2015 at 04:21 PM
Is the collisionObject field set in your inspector? If not, then that will only trigger when it collides with null (never).
Answer by smacbride · May 21, 2015 at 06:18 PM
I use tags assigned to the various characters/objects in the scene to determine what the player is colliding with. You can just inspect the tag associated with the object.