NavMesh agent sync

Hey guys!
Let’s say I have a navmesh agents array which must follow each player joined.
I already have a basic logic like OnPlayerJoin it spawn an instance of an agent, and it works, but only localy, so each player see only its own agent in movement, while agents for other playes are motionless.

Is there any way to make them sync? According to official guide I already tried to add VRCObjectSync component on the agent prefab, add collider, rb, add PickUp component (even i don’t want it to be pickupable) – unmark it pickupable / mark it pickupable – result is the same. only local motion update.
I suspect its because using a rigidbody with navmeshAgent suposed it to be kinematic only. So probably using them both could prevent VRC syncing code by somehow

Do you have any clue on how it could be fixed?
I’m newbie in udon, but pretty familar with unity and sharp so I prefer to use udon sharp instead default node system. But i’ll be really gratefull for any suggestion which push me in the right direction :slight_smile: )

1 Like

Centauri made an AI prefab, both local and synced, and went over how to code it from the ground up during a talk. In the beginning of the Networking section, they mention a few things that have to be set in order to sync NavMesh agents correctly, like setting the NavMeshAgent.UpdateRotation off for everyone except the master. Link to the timestamp here;

If you need a more in depth look, the prefab is available for download here;


Wow! Thank you very much! :pray:

I made it works!
In my case i go without additional setting of a NavMesh Agent like disabling updateRotation / updatePosition, but instead just storing arrays of the target destinations and current positions in a separate class as synced variables. So if the player is owner – i just set a destination to them directly and pass position/destination data to arrays by index. And if no – i just grab that data from array and set it as destination. It was kinda headache cause Udon doesn’t support Lists or/and storing data in structs etc. But it works! Video is cool btw! I learned somethnig new about navmesh itself and a lot about networking here in VRC. Thanks for sharing!