system
1
|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
eiei181315 |
The code here works fine, and the object moves along the path.
How can I make it go in the opposite direction?
extends Path2D
onready var follow=get_node("PathFollow2D")
func _ready():
set_process(true)
func _process(delta):
follow.set_offset(follow.get_offset()+350*delta)
system
2
|
|
|
 |
Reply From: |
kidscancode |
FYI, set_process(true)
hasn’t been required since Godot 2. You may be looking at very old documentation/tutorials.
offset
is the distance that the Pathfollow2D is located along the path. Your code, more succinctly written as:
follow.offset += 350 * delta
Is increasing that value by that amount every frame. To go backwards, you would just subtract instead of adding.
If you start with offset = 0
, you’ll be at the start of the path. To start at the end, you need to get the length of the curve:
follow.offset = curve.get_baked_length()
WHAT, HOW DO YOU DO TO HAVE AN ANWSER QUICKLY
@Lgdn kidscancode is an ever-present legendary genius, that’s why! 
timothybrentwood | 2021-08-22 14:37