Agent not facing target character with higher navmesh priority

tuirennder

New member
Hello!

I am using the Third Person Character Controller 2.1.1 and Behavior Designer in Unity 2018.2.20.

Since I want to do a 'click to move' player control, the player character has a Nav Mesh Agent component and a Nav Mesh Agent Movement ability.

To use the unity navmesh agent local avoidance, I set the player navmesh agent priority higher than the AI characters priority.
That way, the player can walk through a pack of ennemies without being blocked.

The problem: when the player has a higher priority ( =1), the agent is facing the player with a huge offset:
https://gfycat.com/fr/yellowimpartialhornet

And now the correct behavior when both characters have the same navmesh agent priority:
https://gfycat.com/fr/soulfulportlyasiaticmouflon

As you can see from the gifs it should be easily reproducible, no need for the 'click to move' script, just the navmesh agent and ability on the player.
The behavior tree is a simplified version of the TPC demo tree where I pre-assign the target to the player in the editor. I can share the scene if needed.
 

tuirennder

New member
Sorry I'm late, it seems my answer from mobile did not go through last week.

I mean the priority on the Unity Nav Mesh Agent, under the 'Obstacle Avoidance' section:
https://docs.unity3d.com/Manual/class-NavMeshAgent.html

The AI agent having a lower Navmesh priority, it's normal that he's not on a collision course towards the player, but when he's attacking,
I expect he would use his LocalLookSource, which is set to the player, to actually face the player.
 

Justin

Administrator
Staff member
Ah, I actually didn't know about that priority :)

The NavMeshMovement ability doesn't use that priority at all, but it could be related to the Movement Type's independent look setting. For a click to move I would create a new Movement Type that sets IndependentLook to true because the character shouldn't be looking in the direction of the camera.
 

tuirennder

New member
As a quick test I tried to set base.ForceIndependentLook = true inside the Initialize function of TopDown.cs, but no effect.

Then I looked at UseIndependentLook. I don't quite understand when this one returns true or false, but following its reference in Use.cs, I realized that the usable items have a FaceTarget boolean!

Back to the inspector, I see that the MeleeWeapon script has a nice checkbox for that, left unchecked by default.

Now with FaceTarget set to true in the melee weapon it works:

Thanks!
 
Top