-1
\$\begingroup\$

The game I am working on is currently using 32X32 collision boxes. I have implemented a working AI (A* - path finding method) which is based on the Grid Size.

Lets say that I use that 16x16 grid , then if I try to implement a sprite to the AI, bigger than 16x16 the path finding will work but part of the sprite will go thru walls, because the AI follows the path generated by A* for a 16x16 grid. Same rules applies if the grid is even smaller (8x8 for example). Is there a way to actually fix that problem. I do not know if that is possible, but if I could make the AI to include not 1 but lets say 4*(8x8)boxes then I will have a one Big 16x16 square and I can use a 16x16 sprite picture(or bigger where the same rules apply). But then the A* method should be tweaked.

The main idea is that I will create a Map in Tiled Editor with 16x16 grid , and then add collision 16x16 boxes (manually wherever I need them to be) which will be fed to an array with certain index numbers for each type of collision box (0,1,2 etc).So the bottom line is that I can not use sprites bigger than the collision box (or smaller will cause weird spaces). Am I missing something , or there are other ways of doing that ?

PS: also forgot to mention that if I make the collision boxes equal to the sprite size this won't work in the map, cause the collision wont be smooth or accurate enough

\$\endgroup\$
0
\$\begingroup\$

The path you find with A* and the path a unit travels do not have to be exactly the same path.

You can use methods like steering to follow paths found by A*, while avoiding the corners of your obstacles. Or you can change the input to your A* to allow it to find whatever kind of path you like (which can be followed directly). And you can find paths for units of whatever size you need.

You can use sprites of whatever size you like, as long as the steering algorithms know about the size and as long as A* knows about their size.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.