- Edited
First of all, sorry for the basic question.
I have an icon regularly following a Path2d
, this way:
# from the Path2D GDScript file:
func _process(delta:float) -> void:
t += delta
$Path2D/PathFollow2D.progress = t * 200.0
This was only a basic test to see how a sprite can follow a path, but the end goal is the following: by clicking a button, I want the icon to move from a point of the path to another one.
For example, I have A, B, C and D points: when I click the button, the icon must go from A to B. If I click again it must go from B to C (or B to D), etc.
So, the first thing I did was looking for a way to get my points: thanks to @xyz, I ended up making this function:
func get_point_positions() -> PackedVector2Array:
var points = PackedVector2Array()
var total_points = curve.point_count
for i in range(total_points):
points.append(curve.get_point_position(i))
return points
Problem is now I don't know how to move my icon.
I found the lerp
function, but it was not very useful (it looks like it can't move over a path). Then, there are the Tweens, but in Godot 4 they work differently, and I only found resources about previous Godot versions (the only Godot 4 resource I found, doesn't mention Path2D).
So, how could I do?