- Home /
Question by
$$anonymous$$ · Mar 09, 2014 at 07:02 PM ·
collisionplayernavmeshnavmeshagent
NavMeshAgent Collision
Hi Community,
I have a simple question: How can i detect collision between a NavMeshAgent and a Player having a Character Controller ?
Comment
Answer by Ed unity · Mar 11, 2014 at 08:29 PM
You will want to use OnCollisionEnter in conjunction with object tags. Tag the NavMeshAgents with a specific tag that indicates they are an Agent. Place the below function inside of the Player's class and when he collides with an object, it will check if the object has the NavAgent tag and if it does you can do some reaction.
OnCollisionEnter(Collision otherObject)
{
if(otherObject.gameObject.tag == "NavAgent")
{
// Reaction
}
}
Reference Links
http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html http://docs.unity3d.com/Documentation/ScriptReference/GameObject-tag.html