[Solved] How to make pathfinding movement in a pixel perfect way

Hello, I am trying to make my enemies move with the pathfinding behavior, but with a pixel perfect movement, like when they move, they snap to a 8x8 grid. I tried the virtual grid, but it didn’t work. Any help would be appreciated.

The path finder uses the grid to find a path. It will stop on the grid location as long as it needs to move a full grid amount otherwise it will go to the exact coordinates. So, you need to use a grid of 8x8 and a target evenly divisible by 8. It also does its own rounding which makes things weird.

Something like
Move object to trunc(CursorX()/8)*8 , trunc(CursorY()/8)*8

Or you can use round()
Move object to trunc(round(CursorX()/8))*8 , trunc(round(CursorY()/8))*8

I drew a circle where the grid points are.
Using CursorX(),CursorY()

using adjusted CursorX(),CursorY()


Oh okay, I was trying to make my enemies move the same way as the player, I found an alternative by just using the same behavior as the player, but that just lead to multiple wait conditions, which is fine, but I thought the pathfinding behavior would lessen the actions, though thanks for the help, I will probably use the top-down behavior for my enemies though. :grin:

But I do have an extra question. Is there another way I could make an enemies follow a specific path going back and forth without the pathfinding and top-down behavior while moving in a pixel perfect way, and should I just make this post Solved, and make another post referring to this extra question or you could just tell me if you have any idea. :thinking:

I think you can leave it open. I don’t have an answer.

1 Like

Ok thanks, hopefully somebody does :grin: Also, should I change the name of the topic to pixel perfect movement for enemies :thinking: or is that something I’m not alowed to do?

As long as the title matches the thread. I see no problem with giving it a clearer title. It’s better than multiple similar threads.

1 Like

Not currently with GDevelop. It’ll be something you’ll have to create yourself.

One way is to have a series of hidden objects that direct the enemy which way to move or what angle to move at, and that angle directing the enemy to the next object. You can store the angle as an object variable.

1 Like

Ok, I’ll just use the top-down behavior with the pixel perfect movement. Thanks for the heads up though :grin:

1 Like