Turn based manual tick implementation

Blargenflargle

New member
Hello,

I'm having issues implementing a turn based system using behavior designer. In this game I have X# of actors. Each actor has their own turn, and their own piece to move around the board. Each actor should evaluate the board once, right before they make their move. This is where I'm running into issues. Each actor has a behavior tree attached to it. When I run "BehaviorManager.instance.Tick()" only one actor does anything. If I run the tick function again, or 100 more times, that same actor will move every time. No other actor will move. If I delete the gameobject for that actor, another random actor will move every time I run the tick function. If I keep deleting the gameobject that's moving, a new one will keep being randomly chosen to be the next one that can move.

My questions basically boils down to: How do I make the tick function work? How can I ensure every behavior tree gets ticked? Are there any good examples of turn based implementations that don't just let their behavior trees run constantly? Thank you.
 
When I run "BehaviorManager.instance.Tick()" only one actor does anything. If I run the tick function again, or 100 more times, that same actor will move every time
BehaviorManager.Tick will tick all of the active behavior trees (set using BehaviorTree.EnableBehavior). If you only want to run a specific tree you can run BehaviorManager.Tick(BehaviorTree). Make sure on the Behavior Manager component you first set the tick rate to Manual.
 
Hi @Justin ,

I have my tick rate set to manual with "No Duplicates." All behavior trees are also enabled. However, I'm still running into the issue where I can only ever get one goblin to move. I'm not sure I'm explaining my problem very well via text so I decided to make a quick video. Please let me know if you have any questions, and I apologize in advance for the microphone quality.
 
Last edited:
I can't see anything wrong but it's always hard to tell without actually getting into the project and playing with it myself.

If you import the runtime source and step through BehaviorManager.Tick, does it update more trees than what you are expecting?
 
According to Visual Studio it understands that there are 8 trees, but it's only updating one at a time (just as is expected.) Would it help if I gave you access to my git repository? It's private but I really want to solve this problem. Right now you'd need Behavior Designer and A* pathfinding project to run my custom scripts... let me know.

Edit: I can also make a video going over whatever you think would help, including step by step debugging or whatever. Just tell me what lines you want breaks at and what variables you want me to go over and I can do it. Thanks in again.
 
I solved this problem. It turned out to be my own doing. When I went to refernce the gameObject containing the goblin script, I was referencing it using GameObject.FindObjectOfType instead of gameObject.GetComponent. This meant that I was just finding the first gameObject with a goblin script on it... seems obvious now. Thank you for trying to help me! I really appreciate it.
 
Top