AI Agent Walk Backward facing Player

serenity

Member
I need the AI NavMesh Agent to walk backwards for a couple meters when too close to the player while still facing the player.

I have read in the following page that its better to use SetCharacterMovementInput & SetCharacterDeltaYawRotation to move the AI:

Something like this:
Code:
KinematicObjectManager.SetCharacterMovementInput(_character.KinematicObjectIndex, 0, 1);
KinematicObjectManager.SetCharacterDeltaYawRotation(_character.KinematicObjectIndex, 1);

1) Is the above used alone or it has to be coupled with setting the destination as well as such:
Code:
agent.destination = player.transform.position;

2) What does the range of values for horizontal and forward movement do (-1 to 1)?

3) Will these actions sync over the network using the Pun Addon?

Thanks
 
1. If you're using a NavMeshAgent then you do not need to manually set the CharacterMovement/Rotation.
2. Yes, it is -1 to 1. This simulates a button press.
3. If you are setting this on the master client and the master client owns the AI then it will.
 
Thanks

1. If you're using a NavMeshAgent then you do not need to manually set the CharacterMovement/Rotation.

So how would you make the AI go backwards while still facing the player? Does the move type has anything to do with it? I am using 3rd person controller with adventure mode.

3. If you are setting this on the master client and the master client owns the AI then it will.

How do you set it to the master client and do you have to pass that to a different client when master client leaves session?
 
So how would you make the AI go backwards while still facing the player? Does the move type has anything to do with it? I am using 3rd person controller with adventure mode.
The adventure movement type will always move the character forward. In that case the combat movement type will allow the character to move backwards.

How do you set it to the master client and do you have to pass that to a different client when master client leaves session?
The master client is normally the first person to join the room. When the master client leaves you will need to switch to a different client. This is on the Photon side of things though so I would take a look at their documentation for how it's done.
 
The adventure movement type will always move the character forward. In that case the combat movement type will allow the character to move backwards.

I changed AI agent to combat but it keeps turning its back to player when backing away even though I have LookSource set to player.
Any other setting that has to be set

The master client is normally the first person to join the room. When the master client leaves you will need to switch to a different client. This is on the Photon side of things though so I would take a look at their documentation for how it's done.

Thanks I will check it
 
I changed AI agent to combat but it keeps turning its back to player when backing away even though I have LookSource set to player.
Any other setting that has to be set
Could it be the NavMeshAgent rotating the character?


After you make this change you'll need to tell the NavMeshAgent not to update the rotation.
 
Top