distance_to_object( obj );
|obj||The object to check for.|
This function calculates the distance from the edge of the
bounding box of the calling instance to the nearest edge of the
nearest instance of the object specified. The object can be an
object index or a specific instance id as well as the
keyword other, and the distance is returned in
pixels. Note that if either of the objects have no sprite or no
mask defined, the results will be incorrect.
if distance_to_object(obj_Player) < range
canshoot = true;
The above code will check for the distance to the player object and if it is less than the value stored in the variable "range" the variable "canshoot" is set to true.