Home > Community Toolbox Reference > Collision utilities
Finds the instance at the given position with the least depth. If no instance is at the position, noone is returned.
Argument | Type | Usage | Description |
---|---|---|---|
x | Real |
Required | The x coordinate of the point to check. |
y | Real |
Required | The y coordinate of the point to check. |
obj | Asset.GMObject,Constant.All,Array |
Required | The object(s) to find at the given position. |
Id.Instance
The following code chooses the topmost (or frontmost) interactible instance in a point-and-click game, and potentially performs interactions on it.
hover_interactible = instance_position_top(mouse_x, mouse_y, par_Interactible);
with (hover_interactible) {
other.tooltip = tooltip;
if (mouse_check_button_pressed(mb_left))
begin_interaction();
}
- 24.6.0 - Created a function to find the least-depth instance at the given position.