This function computes a straight-line path for the instance, checking for collisions with a specific object


mp_linear_path_object(path, xgoal, ygoal, stepsize, obj);

Argument Description
path The index of the path to be used
xgoal The target x position.
ygoal The target y position.
stepsize The speed the instance moves in pixels per step.
obj The object that is to block the path. Can be an object index, an instance id or the special keyword ,all

Returns: Boolean


This function computes a straight line path from the current instance position to the point specified by the "xgoal" and "ygoal" values. It uses the indicated step size, the same as in the function mp_linear_step(). The indicated path must already exist and will be overwritten by the new path and the function will return if a complete path was found (true) or not (false). A full path is only found there was no collision with the specified object or instance and if false is returned then a path is still generated, but it will only run up to the position where the path was blocked.

Note: This function does not move the instance. It sets a path only, and you must use the Path functions for movement.


if mp_linear_path_object(path, mouse_x, mouse_y, 4, obj_Wall) path_start(path, 4, 0, 0);

The above code checks for a collision with "obj_Wall" along the path between the object running the code and the x/y position of the mouse. If there is no collision and the complete path is generated then it will start the object along the path generated.

Back: Motion Planning
Next: mp_potential_settings
© Copyright YoYo Games Ltd. 2018 All Rights Reserved