0 votes

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, addchild(a), b = X.instance, addchild(b)...

in Engine by (14 points)

1 Answer

0 votes

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.

by (18 points)

Hey thank you for answering :)
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

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?

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.