- Home /
NavMeshRenderer don't stop my player object when it collides with an static object
My NavMashRenderer is attached to my PlayerObject but I can't make it stop when the Player collides with another static object, my player doesn't stop but my NavMashRenderer yes, can anyone help me? thanks
Is this Nav$$anonymous$$eshRenderer is something new that I am not aware of, or you just confusing $$anonymous$$eshRenderer with Nav$$anonymous$$eshAgent?
Answer by digiman72 · Oct 11, 2019 at 05:59 PM
make sure to add capsule colliders, and rigibodies to the objects, in order for them to collide.
i dont quite understand what you mean, when you say my player does not stop, but my navmeshAgent yes....basically your navMeshAgent is added to the player, (or whichever the root object is, incase you added an empty gameobject, then attached your player to the empty gameobjec), you would then add navmesh component to the empty gamobject you created..remember to add collider and rigibody to the base object(root object), if this is the case.
now it could be that your navmesh does stop, but your animation continues to play...???
when using navmesh, there is code to check if navmesh has path, and arrived at location, this must be included in update,
void FixedUpdate () {
if (!navMeshAgent.pathPending)
{
if (navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance)
{
if (!navMeshAgent.hasPath || navMeshAgent.velocity.sqrMagnitude == 0f)
{
// Debug.Log("ARRIVED......." + navMeshAgent.destination);
hasArrived = true;
if (hasArrived)
{
do desired function ex: change animation...
}
}
}
}
i hope this hhelps a bit, good luck