I'm trying to make an initiative based turn order game and I'm stuck on the part where the code has to await an end turn signal. Here's the relevant code:
func start_turns() -> void:
# Loop through the initiative order
for combatant in initiative_order:
var character = combatant["node"]
#var combatant = find_combatant_by_name(combatant["name"])
if character.is_in_group("enemy"):
print(character["name"], " initiative: ", character["initiative"])
enemy_turn_start(character)
character.act.rpc() # Call the act function on the active character
print("came here, wolf")
await UiEventBus.turn_end # Wait before the next turn
elif character.is_in_group("player"):
ally_turn_start.rpc_id(character.player_id, character.name)
await UiEventBus.turn_end
print("came here, player")
character.turn = false
start_turns()
The problem line is: "await UiEventBus.turn_end". When Player1 ends their turn, the print after the "await" prints out. When Player2 ends their turn, it doesn't. The thing is, they're using the same script to send out the signal:
func _on_end_turn_button_pressed() -> void:
end_turn_button.disabled = true
UiEventBus.turn_end.emit(self)
I'm using an event bus which allows the player to communicate with the UI. It works flawlessly so I know the signal is being emitted. Initiative order array of dictionaries is also correct since it's printing everyone correctly and it worked before I started messing with multiplayer. I think the issue lies somewhere in the await async routine or something.