0 votes

I'm currently trying to create up to four different nodes of the same instantiated scene. Basically a "player join screen", where a specific input can join and quit at each consecutive call.

My instance root is PathFollow2D with a sprite.
The current Scene has a Path2D to receive those instances as child nodes.
My InputActions are mapped to 4 different keys, each one calling the same generic node spawn function with a different parameter value. The Node spawns with a color that goes to define the sprite modulation, node name:

func input(event: InputEvent) -> void:
if Input.is
if Input.isactionjustpressed("GREENclick"):
if Input.is
if Input.isactionjustpressed("YELLOWclick"):

func set_player_in(color) -> void:
    if players_in.has(color) == false:
        var neuron := preload("res://Game Elements/Player/Neuron.tscn").instance()
        player_count += 1
        neuron.set_name(color + "neuron")
        player_count -= 1
        circuit.get_node(color + "neuron").queue_free()

So far it works, but I'm finding it hard to fine tune initial parameters for the instantiated scene such as its child nodes specific properties.
Before this, I thought It was better just to add the child instance and call a method inside its own script to set all its parameters at the moment of initiation of the node. That was not working, so I resorted to the code I now paste here.

What would be the best logic to implement this?

Godot version v3.5.1.stable.official
in Engine by (18 points)

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.