With this function you can check a position for a collision with another instance or all instances of an object using the collision mask of the instance that runs the code for the check. When you use this you are effectively asking GameMaker Studio 2 to move the instance to the new position, check for a collision, move back and tell you if a collision was found or not. This will work for precise collisions, but only if both the instance and the object being checked for have precise collision masks selected otherwise only bounding box collisions are applied. this function will return the unique instance id of the object being collided, but if that is not needed it is slightly faster to use the function place_meeting. This function also accepts the special keywords all and other and will return the keyword noone if no collision occurs, or the unique instance ID value of the instance found if a collision does occur.
Note that the given x/y coordinates will be rounded to the nearest integer before the check is performed, so if this is not what you require (or you have been using a legacy GameMaker product), you should floor the coordinates in the check: instance_place(floor(x), floor(y), obj_Enemy).
instance_place(x, y, obj);
Argument Description x The x position to check for instances. y The y position to check for instances. obj The object to check for instances of.
Real (either an instance ID value or the keyword noone)
var _inst = instance_place(x, y, obj_Enemy);
if _inst != noone
hp -= _inst.dmg;
The above code will check for a collision with instances of "obj_Enemy" and if there is one, it will reduce the "hp" variable by the amount stored in the colliding instance's "dmg" variable and then destroy the colliding instance.