Hey,
I’m wondering if you can help provide us some guidance regarding using State Trees. We’re currently on 5.6.
We’re using them to handle a complex “Reward System” which hooks into our gameplay which fires off game specific events when players perform actions. We then have a number of state trees with global tasks on them listening for gameplay events they care about. These global tasks on each state tree then send an event to the internal State Tree event queue. This event queue is shared among all state trees for a specific player using the built in State Tree functionality to share an event queue.
Our state tree then follows an example pattern of:
[Image Removed]
ST_OnPlayerKill (Attached Image)
[Global Task] Listen for Event > Send State Tree Event “Event.StateTree.PlayerKill”
> Root
>> Listen for Kill Event : [Transition - OnEvent “Event.StateTree.PlayerKill” -> On Kill Event - Consume Event = true]
>> On Kill Event : [Entry Event Requirement = “Event.StateTree.PlayerKill” - Consume Event = true]
We seem to be facing a bunch of issues with this setup which I can’t quite understand why it doesn’t work properly.
- Is event consumption fully functional? I’m finding that I can’t get ANY events to be consumed when just having Consume Event true on the “On Kill Event” entry requirement. It only seems to work when I set Consume Event to true on the transition of the “Listen for Kill Event” state.
- We’re seeing that even though theoretically our state trees can complete their execution in a single frame (due to not needing to wait on any states and all logic being performed on state entry) once we enter the “On Kill Event” state. We’re still finding that the state will run over a number of frames and it’s not entirely clear what is causing it to be spread out over multiple frames. Or how the state execution context instanced data is safe to persist that way (given it can contain UObject pointers to constantly changing actors etc). Is there a way to ensure a state tree will operate over a single frame if it doesn’t require waiting in any states?
- What is the correct way to architect a state tree to effectively run the state “On Kill Event” once per event added to the event queue and also consume the event. Then after the state “On Kill Event” has finished execution, we would like to go back to Root and check the event queue in “Listen for Kill Event” again and process/consume all events it can.
I realise that we may not be using State Tree in the way it was entirely designed for with spending no real time in states themselves, but it would be nice if we can get this working for our use case with the control it gives our designers.