• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

help with collision from certain direction

Hey guys, this seems like it shouldnt be too hard, but anyways I can't wrap my head around it.
So in my top-down game, if the player is blocking with a shield, how do I make it so that enemy bullets (obj_arrow) coming from the direction the player is facing to, are blocked on collision with the player?
Its from a top down view so the player can rotate 360 degrees. (to give you guys an idea of how it plays, if it helps with the code)
Thanks beforehand!
 

TheouAegis

Member
if angle_difference(direction+180, other.image_angle) > 10 //modify 10 to adjust block radius
{
other.hp -= 1;
}

Something like that in the arrow's collision event. Or if you did it from the player's perspective

if angle_difference(other.direction+180,image_angle) > 10
{
hp -= 1;
}
 
somewhat works now, thanks guys!! atleast going the right way. some issues still.
I've noticed there's some trouble going on with image_angles. Everytime the player gets attack from the left, blocking doesnt always work, but from other directions it does. It's like it doesn't register the collision masks from the left as sharply as from other directions...
I have Full Image + Ellipse collision masks for the player (32x32 sprite) and Precise collision for the arrow object.
 
Last edited:
I think its something about the angle_difference actually. In @TheouAegis code with > 10 in the angle_difference, the arrow is blocked even if it doesn't just hit the shield, but even when it collides with the player when he is turned back to the enemy. I struggle to find the right values...
 
Last edited:
Top