Stopping the agent's movement when he is touching the player.

Lavos

Member
Hi,

I am using the ThirdPersonMeleeScene of the UCC integration. Everything seems to work fine out of the box except the agent keeps running towards the player even when he is touching him (the running animation is playing). Is this the normal behavior because it seems a little unnatural? Supposedly, there is a "seek" task which should stop the NavMesh movement but it does not seem to work. How can I stop the agent's movement?

1613401699601.png
 
The AI agent relies on Unity's navigation mesh to direct it where to go. In this case it sounds like the navmesh is moving the agent into another agent. I would try the free version of the A* Pathfinding Project to see if that helps at all. This will allow you to use their local avoidance instead.
 
Migrating to the A* Pathfinding Project seems to be a lot of work (I have to manually replace every Unity NavMesh task by an A* one in the BD) and I still do not understand why this does not work with Unity's NavMesh system. Isn't there a simpler way of doing this? I just want to deactivate the NavMeshAgentMovement ability so that the Animator's movement parameters can be set to 0. I tried to add a StartStopAbility with an ability type of NavMeshAgentMovement. It works but only for 1 frame. The NavMeshAgentMovement ability is reactivated on the following frame. I have checked my task tree frame by frame and there is no reason for the NavMeshAgentMovement ability to be reactivated. Do you know what is going on? Are you sure there is no other way? Why is it so complicated to prevent the agent from running when he is below the arrive distance?
 
Last edited:
Ok I think I got it to work. I just set the NavMeshAgentMovement's Stop Type to Automatic and then it worked! That's pretty simple but if you don't know the UCC perfectly, how can you figure out that kind of solutions by yourself without wasting hours on it ? ;o;
Am I doing something wrong or is it the same for everyone? Justin, if you have any advice to give me, I would love to hear it. Honestly I feel a bit lost and frustrated.
 
The behavior tree isn't responsible for obstacle avoidance. It's up to the pathfinding solution to do that for you. The local avoidance in the NavMeshAgent isn't as good as it is in A*.

I just want to deactivate the NavMeshAgentMovement ability so that the Animator's movement parameters can be set to 0. I tried to add a StartStopAbility with an ability type of NavMeshAgentMovement. It works but only for 1 frame. The NavMeshAgentMovement ability is reactivated on the next frame. I have checked my tree frame by frame and there is no reason for the NavMeshAgentMovement ability to be reactivated. Do you know what is going on? Are you sure there is no other way? Why is it so complicated to prevent the agent from running when he is below the arrive distance?
Ok I think I got it to work. I just set the NavMeshAgentMovement's Stop Type to Automatic and then it worked! That's pretty simple but if you don't know the UCC perfectly, how can you figure out that kind of solutions by yourself without wasting hours on it ? ;o;
Am I doing something wrong or is it the same for everyone? Justin, if you have any advice to give me, I would love to hear it. Honestly I feel a bit lost and frustrated.

I haven't set the stop type to automatic before for the NavMeshAgent but I'm glad that it's working for your project.
The start/stop types are described on this page:

 
Top