Does set_process(true) affect ALL instances of a scene?

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

Im working on a turn manager for turn based combat,
Ive had an issue where when I provide input (eg left) all the players move.
From my turn manager, I call a func on the first player called “play_turn”,
it prints “name started turn” then sets process to true.
Then for a basic debug, in process, it prints “AP is now…”
If I have 3 players,
my output says
Player started turn
AP is now 9
AP is now 9
AP is now 9
AP is now 8
AP is now 8
AP is now 8
. (etc)
once per player despite only one player starting their turn
It seems that _process() is playing out for each player
so when i set process to true, it did so for all instances

Is there a way i can set process true for only one instance, not all instances of the player scene?

ps they are true separate instances where their variables an differ from one another, not duplicates or something.
eg a = X.instance, add_child(a), b = X.instance, add_child(b)…

:bust_in_silhouette: Reply From: Senad

From how I understand your question is to have different classes for player-controlled units and the others.

The code that reacts to player input should then only be in the player-units and only affect those.

For the non-player units a different script should be attached.

Hey thank you for answering :slight_smile:
Sorry, I proably want so clear
Its 3 instances of the same scene (a controllable pawn)
I want to control each player in turn (one after the other)
One player/pawn starts it turn and calls set_process(true)
In process, it takes input. Then it’s turn ends and the next pawn starts.

My problem is that when I call set_process(true) its starting process for all of the instances, not just the one I called it on.
These are instances of the same pawn scene

BabyBorisova | 2021-04-05 09:45

Ah I get you know. I am not sure if there is a property from Godot that you can use. Maybe to disable the pawn?

But why not introduce your own flag (like active_pawn or something) and ignore the user input accordingly?

Senad | 2021-04-05 09:51