Collision Help

T

ThePandaWizard

Guest
Is there a way to only check if the player is colliding with a certain side of an object? For instance if I want an if event to only happen when the player is on top of a block, but not if the player is hitting the side of the block.
 

YoSniper

Member
Depending on how far the two objects may overlap, you could simply use this condition:
Code:
if place_meeting(x, y+1, obj_block) {
    //do stuff
}
That means that the player is directly above the block (if he were moved one pixel down, he would be overlapping the block.)

If you need a more precise collision checking, I recommend using collision_rectangle or collision_line in a similar fashion. Those have a significantly different set of argument requirements, though, so make sure you understand them before you use them.
 
Top