#Is there a "fixed update" or some equivalent in DOTS?

1 messages · Page 1 of 1 (latest)

indigo gust
#

I'm doing some pathfinding stuff. My game is running at hundreds of FPS... I really do not need to have pathfinding running that often, and it would slow down my game. I can run pathfinding 30-60 times a second (for local avoidance) while movement/animation code can run however much it wants, for smooth animations.

Is there some way to run a system at a fixed time rate (alongiside the monobehaviour physics system ideally?) or do I need to do a dirty workaround with skipping a system until enough time has passed to run my own "FixedUpdate"?

ideally, there'd be an attribute added to an ISystem [RunAtFixedUpdate] but there doesn't seem to be anything like that.

hallow mesa
#

I think you want something like: https://docs.unity3d.com/Packages/com.unity.entities@1.2/api/Unity.Entities.FixedStepSimulationSystemGroup.html

The examples have a tonne of physics examples, which also run on these groups, like https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/PhysicsSamples/Assets/6. Events/Scripts/TriggerGravitySystem.cs

So I guess that should answer the question.

Anyhow, I don't think you want to bunch up the cost of a heavy calculation like pathfinding. You want to spread it out as evenly as possible, to not get a spikey game. So I think that your approach is counterproductive. If you really want to spread out your calculations, you could do something like giving all your units a value between 1 and 5 at random, and then only doing pathfinding for 1 of those indexes. Or just maxing out your calculation of units to 100 each fixedtimestep frame, keeping a timepassed since last pathfinding calculation and get the lowest 100. There are many ways to solve this, but just not doing the calculations for a while and then doing it all at once is not a good idea in my opinion.