MP_GRID MOVEMENT WOES


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. 

Comments

Log in with itch.io to leave a comment.

(+1)

Brother, I've been struggling with the exact same thing.  Following you in case you come up with an answer.  My smaller sprite/objects get stuck too if they turn near a wall

yeah, its a head scratcher. I can't seem to figure out exactly WHAT gms2 uses as the border... I've tried multiple different sizes, I even tried making a 64x64 sprite with just a small image in the bottom of it and tried multiple different collision mask sizes, origin point positions... and the only on that has an effect is moving the origin point because that is where the path is drawn from.  I'll let you know if i have a breakthrough! 

(+1)

I'm trying to do a collision check for the wall that extends beyond the collision box of the enemy, I'll let you know....