mp_potential_step(x,y,speed,checkall)
Jump to navigation
Jump to search
Description
Moves the calling instance towards the given point at the given speed avoiding collisions with other instances. When the instance would run into a solid instance (or any instance when checkall is true) it will change the direction of motion to try to avoid the instance and move around it. The approach is not guaranteed to work but in most easy cases it will effectively move the instance towards the goal.
Parameters
Parameter | Data Type | Description |
---|---|---|
x | double | x coordinate of the position |
y | double | y coordinate of the position |
speed | double | size of the step |
checkall | boolean | whether to stop when colliding with instances of non-solid objects |
Return Values
boolean: Returns whether or not the goal position was reached.
Example Call
// demonstrates moving an instance towards the mouse avoiding collisions with instances of solid objects
mp_potential_step(mouse_x, mouse_y, 10, false);