How to limit object move

hi everyone


does there have any method limit the movement of sprite, in the picture i want the sprite only move 3 tiles only and then stop

i make game move by turn(it already move turn by turn), but i cant limit it move only 3 tiles, sometimes it stuck at the middle between the tiles

can you help me, thanks




i mean i want it alway in the middle the tile, not in the middle of the 2 tiles, and only move only 3 tiles per turn

How are test.X and test.Y being modified?

If you’re using the keyboard. I would recommend moving using teens but it looks like you’re using the pathfinder.

If you’re using the pathfinder behavior to move the object then one way is to get the node X, Y for node[3]. The behavior creates a list of nodes starting at Node[0] (the start position) . Just like arrays, it can get confusing because the node count will always be the last node +1. If the there are 4 modes then the nodes go from 0 to 3.

Anyways, if you are using the pathfinder, you set a route then you use the 4th node X, Y as the destination. I used min() in case there are fewer than 3 nodes then it uses the smaller number.

It might need further checks and balances.

Here’s the scene.

I used the draw pathfinder behavior on the player. I used the obstacle on the obstacles.

My grid is set to 32x32. The origin of my player is in the center. (16,16)

These are my pathfinder settings. It’s important to set the grid to the same size as your grid and the offset to half the value so the nodes end up in the center. I also unchecked the diagonal box.

If you don’t want to draw the path then don’t add the action to draw the path. If you do. I have the shape painter checkboxes unchecked for draw relative and clear.

Here are my events.

omg, thanks Mr.Keith, this gonna help me a lot, i will do and tell you my result

here is my result, thanks Mr.keith
16-52-14-ezgif.com-crop

1 Like