I’m making something akin to an endless runner (but not really) and am using splines for the AI to track. Think of it like Outrun, with multiple “lanes” for “traffic”.
As the player progresses, new spline points are added ahead of the player to make the splines longer. Eventually, this seems to start slowing down AI pathing: Find Location Closest To World Location is pretty much the single most expensive function in my entire game. (A standard run results in about 2000 spline points.)
The obvious fix is to start deleting spline points behind the player. Whenever a new spline point is added, if the total number of spline points is higher than 100, delete the “oldest” spline point. Because the game has no concept of “oldest” point, I have a counter that starts at 1 and use Add Spline Point at Index, passing the counter in as the index value. Then, if the counter is >100, I remove a spline point with Remove Spline Point.
However, regardless of whether I remove the point with index 0, 1, 100 or (counter - 100), after just one removal the value of Get Number Of Spline Points gets stuck at 100 no matter how many additional spline points I add. If I ignore this result and keep removing spline points, the AI tracking the spline eventually breaks (presumably because the spline has been completely deleted?).
I have no idea how to interpret this. Why does simply removing a spline point break everything, and how would I correctly find the index of the “oldest” spline point and remove it?