Movement handling on a grid

Hey guys,

I was wondering if somebody here did experience handling movements on a grid system. I’m trying to build a turn based strategy game where the player moves on a grid by clicking on the disired grid square and the player moves there by following the grid…

I’ve seen various examples of movement by clicking like this one : Point and click movement | Learn PlayCanvas

but what I’m trying to achieve is really inside a grid…

Hi @shiroy and welcome! I bought an extension from @Leonidas in the past. Unfortunately, this extension is not available anymore. I also know there are some JavaScript solutions you can find on the web, but this was not an option for me personally.

1 Like

You basically have to separate the data of the grid and obstacles etc from the actual objects in the scene.

The data could be something as simple as a 2D array which each cell representing the grid piece in the scene and it will contain where obstacles are etc.

You can then do a path finding algorithm such as A star to find a path between 2 grid cells. Once you have the path, you can move the player between the grid pieces (as listed in the path) in the grid in the scene via tweens or some other method.