Deltarune (Chapter 1) script viewer

← back to main script listing

gml_Object_obj_move_to_point_Step_0

(view raw script w/o annotations or w/e)
1
if (instance_exists(target))
2
{
3
    if (moved == 0)
4
    {
5
        x = target.x;
6
        y = target.y;
7
        dist = distance_to_point(movex, movey);
8
        dir = point_direction(x, y, movex, movey);
9
        amt = dist / movemax;
10
        xadd = lengthdir_x(amt, dir);
11
        yadd = lengthdir_y(amt, dir);
12
        moved = 1;
13
    }
14
    target.x += xadd;
15
    target.y += yadd;
16
    movetimer += 1;
17
    if (movetimer >= movemax)
18
        instance_destroy();
19
    if (target == obj_move_to_point)
20
        instance_destroy();
21
}
22
else
23
{
24
    instance_destroy();
25
}