S
snowy1996
Guest
I've been having issues getting accurate tile collision between my player object and my tile set. I've been using the code used by Shaun in his video on the subject, linked here:
It works well enough when the tiles are the same size or larger then the object colliding with it, but while trying to use tiles smaller then the player object the object will always be placed farther back then it should after detecting collision with the tile set.
The player object sprite is a 32x32 box, with a full body mask with its origin placed int he middle center. The tile set is sized as 8x8.
My code is as follows.
It's the same code used in Shaun's video, using what I think is the appropriate values for my tile set dimensions. I'm at a loss as for what the issue is.
The player object sprite is a 32x32 box, with a full body mask with its origin placed int he middle center. The tile set is sized as 8x8.
My code is as follows.
Code:
if (hsp > 0) bbox_side = bbox_right; else bbox_side = bbox_left;
if (tilemap_get_at_pixel(tilemap,bbox_side+hsp,bbox_top) != 0) or (tilemap_get_at_pixel(tilemap,bbox_side+hsp,bbox_bottom) != 0)
{
if (hsp > 0) x = x - (x mod 8) + 7 - (bbox_right - x);
else x = x - (x mod 8) - (bbox_left - x);
hsp = 0;
}
x += hsp;
if (vsp > 0) bbox_side = bbox_bottom; else bbox_side = bbox_top;
if (tilemap_get_at_pixel(tilemap,bbox_left,bbox_side+vsp) != 0) or (tilemap_get_at_pixel(tilemap,bbox_right,bbox_side+vsp) != 0)
{
if (vsp > 0) y = y - (y mod 8) + 7 - (bbox_bottom - y);
else y = y - (y mod 8) - (bbox_top - y);
vsp = 0;
}
y += vsp;