path_positionprevious


描述

This variable can be used to get or to set the position of an instance along its current path in the previous step, and is a normalised value between 0 and 1 ie: 0 is the start position of the path and 1 would be the end position. It is similar to the xprevious and yprevious functions in how it works, only it is specific for paths. It can be useful for things like temporarily stopping a path follower if something is in the way (see the example code below).

For functions relating to paths, see here.


语法:

path_positionprevious;


返回:

Real(实数)


例如:

var xx = x + lengthdir_x(speed, direction);
var yy = y + lengthdir_y(speed, direction);
if collision_circle(xx, yy, 16, obj_Player, false,true) path_position = path_positionprevious;

The above code checks an area in front of the instance for a collision with the object "obj_Player" and if there is one, it sets the instance back to the previous position it occupied on the current path.