Working with fast agents and high time scales

For my current project we are working with a very large terrain area so we selected a recast graph with agents using the richAI movement script

We want to be able to work with agents that have a max speed of about 17mps and for the user to be able to specify faster time scales (ideally up to about 10x speed).

However we are getting some issues whilst trying to do this

  1. When having the agent moving at 17mps (time scale 1.0) there are some instances where the agent will randomly go off path for like 5 seconds then turn around and go back. I have tried increasing the acceleration of the stop time a little but still occurring. I have mainly noticed this on hills so maybe it is hitting a point when not following the path exactly

  2. At faster timescales the agent is falling through the terrain. I have seen a few posts on the forum that have spoken about this issue and you have recommended setting canMove to false and updating the position multiple times per frame. I have tried copying this but it doesnt seem to fix anything

Update:

So I have done some further work and testing and got it to where maybe 1 in 4 runs the agent falls through the navmesh (even though it is the same path every time).

What is causing this to happen and are there any ways beyond doing this:

// Make the AI not do any movement by itself
richAI.canMove = false;
// Run the movement code multiple times per frame
int timeMultiplier = (int)Mathf.Round(Time.timeScale);
for (int i = 0; i < timeMultiplier; i++)
{
     Vector3 nextPosition;
     Quaternion nextRotation;
     richAI.MovementUpdate(Time.deltaTime / timeMultiplier, out nextPosition, out nextRotation);
     richAI.FinalizeMovement(nextPosition, nextRotation);
}

Hi

What you have in your last post is the best way to handle it currently. That should make it as stable as running it at timescale 1. Otherwise, it would potentially have to deal with agents moving 170 meters (17 * 10) in a single simulation step, which would be extremely unstable.
I have some new movement scripts under development in which this happens automatically when you run the game at higher time scales.

I see. I have tried increasing it so that it does iterations equal to twice the time scale (so for 10x multiplier it would do 20 iterations per frame) and i have yet to run into any issues

It is good to hear that scripts dedicated to faster time scales are in the works

Update: So even with running with 20 updates per frame (when at 10x speed), the agent still falls through the terrain sometimes

Is there anything else that could be causing this?
Is there a way I can detect that this has happened and place the agent back onto the path?

Hi

The new movement script FollowerEntity is now available in the beta version. It should work well at higher time scales automatically.
You could try it out if you want :slight_smile: Let me know how it goes.