RyanC
Member
Hi All,
Does anyone know a reliable way of checking if a collision is horizontal or vertical.
I'm trying to make a system where my player can only tackle enemies from above or below.
This code only seems to work from the right! (sprite width is 64 with centered origin)
Does anyone know a reliable way of checking if a collision is horizontal or vertical.
I'm trying to make a system where my player can only tackle enemies from above or below.
This code only seems to work from the right! (sprite width is 64 with centered origin)
Code:
if x < other.x
{
var x_pbox = xprevious+32;
if x_pbox < other.bbox_left
image_index = 1 // get hit
}
else
{
var x_pbox = xprevious-32;
if x_pbox > other.bbox_right
image_index = 1 // get hit
}
Last edited: