File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,3 @@ position = Vector2( 228.464, 132.594 )
2424scale = Vector2 ( 0.5 , 0.5 )
2525texture = ExtResource ( 3 )
2626offset = Vector2 ( 0 , -26 )
27-
Original file line number Diff line number Diff line change @@ -29,17 +29,18 @@ func _process(delta):
2929
3030func move_along_path (distance ):
3131 var last_point = $ Character .position
32- for _index in range ( path .size () ):
32+ while path .size ():
3333 var distance_between_points = last_point .distance_to (path [0 ])
34+
3435 # the position to move to falls between two points
35- if distance <= distance_between_points and distance >= 0.0 :
36+ if distance <= distance_between_points :
3637 $ Character .position = last_point .linear_interpolate (path [0 ], distance / distance_between_points )
37- break
38- # the character reached the end of the path
39- elif distance < 0.0 :
40- $ Character .position = path [0 ]
41- set_process (false )
42- break
38+ return
39+
40+ # the position is past the end of the segment
4341 distance -= distance_between_points
4442 last_point = path [0 ]
4543 path .remove (0 )
44+ # the character reached the end of the path
45+ $ Character .position = last_point
46+ set_process (false )
You can’t perform that action at this time.
0 commit comments