I've been studying steering and flocking behaviors, if not directly from Craig Reynolds work on Steering Behaviors For Autonomous Characters (http://www.red3d.com/cwr/steer/). I understand the basic concepts and how to apply forces but the main issue with this is performance. Using Unity, ECS and the job system, I have been able to implement a multi-threaded implementation of some simple behaviors (seek, arrival, evade etc).
The problem is simply that all of the implementations of steering behaviors that I find are all based on this same principle and they all seem to suffer from the same problem - framerate independence. For example, a simplified example of seeking:
// get a vector pointing directly at our target, at the maximum speed. desired_velocity = normalize(target - position) * max_velocity // get the steering force direction steering = desired_velocity - velocity // ensure the steering force never exceeds our maximum steering force steering = truncate(steering, max_steering_force) // ensure the velocity never exceeds the max speed velocity = truncate (velocity + steering , max_speed) // apply our velocity position += velocity * delta_time
When dealing with the final velocity, we are utilizing delta_time to ensure that the velocity is applied in a framerate independent manner. But the steering force is not framerate independent at all. If this was running at 120fps, the steering would reach it's maximum velocity much faster than if the game was running at 30fps.
Is there something more I should be doing here. I've experimented with using delta_time with the steering, but that seems to make little difference.