Help with understanding a video from GDQuest

I’ve started an RPG project and I want to make a turn-based system with multiple players and enemy characters represented with nodes.

https://www.youtube.com/watch?v=FV4JkwI4OF4&list=PLhqJJNjsQ7KHaAQcGij5SmOPpFjrDTHUq&index=3

I was following this video from GDQuest on the same thing, but it left me confused as to how to implement their turn-based system into my game. The code is:

extends Node2D

class_name TurnQueue

var active_charater

func initalize():
    active_charater = get_child(0)
    

func play_turn():
    yield(active_charater.play_turn(),"completed")
    var new_index : int = (active_charater.get_index() + 1) % get_child_count()
    active_charater = get_child(new_index)

The part that confuses me is how to run the play_turn() function in the active_charaters code, I’m not sure what kind of check I should have in the player script to know it’s become the active character and let it play its turn until completion.

The example doesn’t go any further than just making the system, could someone show me as an example of the play_turn function in a node or explain to me how I should check for the active character myself?

well i figured out what to do, although im not too sure how to delete this thread or mark it as solved

glad you got it sorted, to mark as solved.

theres the three dots next to reply. if you press that on a post other than the original, it should expand and give you the option to mark solution.image

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms