Follow exact path on center of node

I’m making a 2D tower defense game and I need the enemies to always walk on the center of each node on the grid.
I’m currently using AI Lerp and it gives me this path:
Original Path

I’ve managed to correct it by creating a modifier that always returns the center of the node(substitutes the decimal part for 0.5, example: 1.3 -> 1.5) using this algorithm, and now it follows the correct path:
Corrected Path

But now it snaps like crazy, specially on turns. I’ve tried using pretty much every type of smooth modifier but it didn’t really help.
Is there a recommended way of doing this? Either way would work for me, smoothing the path or recalculating a better one.
Thanks.

Hi

  1. Make sure your node size is the same as the tile size in your tower defense game (see grid graph -> node size).
  2. Set Seeker -> Start End Modifier -> Start Point and End Point to SnapToNode. This will make the first and last points of the path be in the center of the node instead of anywhere inside the tile.

You will not need your custom modifier.

1 Like

Just had to increase the Repath rate and it worked perfectly, thanks a lot!

1 Like