Is there a more optimal way to move in 2d space than lerping every tick?

I’m working on a 2d, realtime sprite-based roguelike. It has no collision so I can’t use a proper navmesh. In its place, when an NPC plans a route it compiles an array of Vector3 representing the points it needs to visit in order to reach its destination. Right now, every NPC runs this every fixedupdate:

  void MoveTowards(Vector3 targetPos, float speed)
  {
       if (currentPosition == targetPos)
       {
           ArrivedAtWaypoint(); //Consult navgraph and get new starting and target positions
       }
       else
       {
           currentPosition = Vector3.Lerp(currentPosition , targetPos, Time.deltaTime * speed);
       }
  }

This works okay, but it’s rubberbandy and it can often be jerky (since the sprite is teleporting every frame). More importantly however, it feels extremely inefficient; under normal conditions there will be 20-30 NPCs in the game at any given time, and requiring each of them to run this in tick every single frame (even if most of the time it will just check against a bool to see if movement needs to be calculated) feels incredibly inefficient. Is there an obvious, more performant implementation I’m missing, or am I obsessing over optimizing something that’s already pretty fast?

From my personal experience, having 20+ lerps happening at once does not affect the game / performance extremely heavily.
As far as I know, lerps are pretty efficient.

Lerping is just multiplication and division. It’s cheap.

Your jerking is because you are lerping wrong.

But in this situation I wouldn’t lerp, I would just use MoveTowards.

Hmm you’re right, MoveTowards is much cheaper… as long as that proposal doesn’t make anyone scream out loud at the thought of the overhead it involves, that’s good enough for me- thank you guys for weighing in :slight_smile:

FixedUpdate should only be used for physics calculations. Using Update and a timer that is accumulating Time.deltaTime should be the way to go or MoveTowards like already suggested.