Hi all,
I am currently working on a unity project where I am creating a crowd evacuation simulation. I currently have a problem with creating a deterministic simulation because of the way that the NavMeshAgent updates on the AIUpdate which is part of the PlayerLoop.
From what I can tell (The docs are not super helpful with this), AIUpdate is called every frame.
This couples NavMeshAgents’ behaviour to the runtime frame rate.
This isn’t ideal for my case because I need my simulation to be deterministic, and also to be able to run independent of real time (i.e as fast as it can execute) for this I need fixed time steps that the agent is updated (e.g on the fixed update loop).
I have scoured the forums, docs, and discords for a solution to this , but have got nowhere.
I found this post where the op wants to use the FixedUpdate loop to update the NavMeshAgent, but with no solution was found.
One suggestion that keeps coming up is to disable the NavMeshAgent’s updating
agent.updatePosition = false;
agent.updateRotation = false;
And then applying movement in the Fixed Update loop using agent.desiredVelocity although I’m unclear exactly how to do this (update transform? warp? nextPosition?)
But this solution is unviable for me anyway because AIUpdate may be called several times every fixed update, which means the all my agents (potentially thousands) are needlessly planning their velocities for several update steps since the “simulated agent” is still being updated even if agent.updatePosition is false. (All updatePosition does is tell the “simulated agent” to update its transform)
Just to expand upon the details of my use case since it’s quite a unique one, my number one priority is determinism, then performance (only since I will have thousands of agents). Visual quality or consistency is not a concern. And I’m using NavMeshAgents both for the A* pathfinding and the the RVO based local avoidance.
If I can’t solve this issue then my next step is to implement navigation from scratch (A* + RVO or SFM or similar) but this will be quite an undertaking (maybe in DOTS?)