With this function you can check a position for a collision with another instance or all instances of an object. When you use this you are checking a single point in the room for an instance or an object. This check will be done against the bounding box of the instance or against the mask of the instance if that instance has precise collisions checked. If you need to get the unique instance id if the object being collided with you should use instance_position().
In addition to objects and instances, the function also accepts:
Passing an array allows you to check for collisions against multiple objects and/or Tile Maps in one call.
position_meeting(x, y, obj);
Argument | Type | Description |
---|---|---|
x | Real | The x position to check. |
y | Real | The y position to check. |
obj | Object Asset or Object Instance or Tile Map Element ID or Array | An object, instance, tile map ID, keywords all/other, or array containing these items |
if (mouse_check_button(mb_left))
{
if (!position_meeting(mouse_x, mouse_y, all))
{
instance_create_layer(mouse_x, mouse_y, "Walls", obj_Wall);
}
}
The above code checks for the left mouse button, and if it is pressed it checks the mouse x/y position for a collision with any instance. If there is none, then an instance of "obj_Wall" is created.