Why set_unit_offset on an instatiate PathFollow2D dosen't work ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zacharieg

Hey, I’m a very new beginner in godot, I had few experience in Unity but that’s all…
I want to create a sort of card game and I decided to start to implement a card system.
For the hand I decided to use a Path2D and PathFollow2Ds to distribute cards.

So for each card I create a PathFollow2D and assign it a unit offset, but for a bizarre reason the unit offset don’t setup… and the position of the PathFollow still is (0,0)…

Here is my code (I hope you’ll understand it)

extends Node2D

export (PackedScene) var Card
export var number_cards = 3
var cards = []
var positions = []

func _ready():
	for i in range(number_cards):
		var card = Card.instance()
		card.create(i)
		add_child(card)
		cards.append(card)
		
		var pos = PathFollow2D.new()
		var unit_offset = float(i)/(number_cards - 1);
		$CardPath.add_child(pos)
		pos.set_unit_offset(unit_offset)
		positions.append(pos)
		card.position = pos.position

Could anyone help me please ?

Works fine for me! Can you upload an example project?

njamster | 2020-09-15 09:11

:bust_in_silhouette: Reply From: Zacharieg

Ok I changed the path object in my scene (just replace it by another and it works ! O.o ) I Should have setup a bad parameter in that object… So thank you for your help (it help me figure out that my code was actually good) !