0 votes

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 ?

in Engine by (19 points)

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

1 Answer

0 votes
Best answer

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) !

by (19 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.