itch.io is community of indie game creators and players

Devlogs

MP_GRID MOVEMENT WOES

Disavowed
A downloadable game

What a HEADACHE.

To calculate the movement of the enemy AI i'm using the mp_grid functions in gms2. The grid is initialised for 32x32 which matches my tilesets. There are some enemies that are 48x48, naturally parts of the bigger enemy sprites clip over the collision wall. I've tried a multitude of different approaches to fix this and even weirder, the sprites that are 32x32 (matching the grid) occasionally clip into the collision too. i'm not sure of the best solution to this. here are some images to explain the issue clearer.

Let's break it down, the red grid is the obj_wall instance, and the green area is "walkable"  the pink box represents the enemies sprite size (48x48) the white box represents what the grid is calculated for (32x32). ignore the positioning of the white box, i was testing an offset on it.  As you can see, the sides of the enemy sprite are clipping over the collision area.
I've tried to add a buffer to account for this but no matter what approach I've attempted the result has been the same, the enemy always clips into the collision area. 

How does the mp_grid work. My understanding is that it calculates a grid of specified cell size (in this case 32x32. Then draws a path from the origin point of the object from position A - B across the grid to the desired location.  Then you move the object along the path.  so it would make total sense for it to be clipping into collision if the sprite is bigger than the 32x32 grid. but i've tried with both 48x48 and 32x32 sprites and get the same issue. 

I'm sure there is a work around for this and I will persist. if you have any suggestions I can try I will give anything a go at this point. for now i'm going to move on to other parts of the production and circle back to this later. 

Read comments (3)