Attention | Topic was automatically imported from the old Question2Answer platform. | |
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