I’m using a GridGraph with a barebones subclass of AIPath on each AI agent. I subclassed it so I could override the OnPathComplete callback. I have the list of future nodes in the path, but I’m not sure what the best approach is to get a roughly estimated position x seconds in the future, since there can be a different length of time and distance between each subsequent node in the path list.
The context is basically this: I have a separate system that handles influence mapping on a ~(1-3)sec tick between updates for any given AI agent, provide that agent is on a different tile than it was the last tick. If an AI agent is moving, I want it to process half of the influence at its current position, and the other half at its future position, so the result is an interpolation. To do this, I need to be able to estimate an agent’s position x seconds in the future. Since the path is already calculated for pathfinding anyway, I figured that was the best thing to use for the future position estimate.
The only way I can think of to do this is to start iterating through the path from the start, read the distance and remainingDistance floats at each step and stop at a node where distance is close enough to some estimatedDistance value that is just the current speed * predictAheadTime, or the last node in the array if remainingDistance < estimatedDistance (which it shouldn’t ever actually be, since the predict ahead time will probably almost always be under 5sec at most, 1 sec or less will be more common).
Is there an easier/faster way to do this than my above idea?
Thanks @aron_granberg !