Interrupt on Event for RTS like Behaviour

JayRock22

New member
So i want to create the most basic RTS Behaviour and do not know if I do this right at all. I created a modified HasReceivedEvent Conditional which waits for input and returns running until the event is received, which already seems sketchy. What i just can not wrap my head around is how can i interrupt the ongoing sequences? In RTS games i want to be able to completely stop anything a unit does when i give new commands. Can you maybe lead me in a direction that's better or am I already doing it right in some way? Later on i want to implement Resource Gathering, Attacking, Chasing etc. all while being able to be interrupted.

Greetings!

1733693623519.png
 
You can use conditional aborts for this. Take a look at this page for an explanation/video:

 
Hey Justin,

I've looked at the video and read the page multiple times but still don't get how i would interrupt a sequence when receiving an Event. Could you maybe send me in the right direction? Like how would you do classic RTS controls on a high level? Thank you so much!
 
You would use a lower priority abort, similar to this example:


The Selector / Sequence pattern can be used for a large number of behavior tree designs and should be appropriate for an RTS as well.
 
1753456088747.png

Im using something similar to the example to drive RTS style events, but once Defend is active, it cannot be interrupted by a new command ,like Move.
How do I solve this?

Also is it possible to build a queue of tasks /events in game, that execute in order?
 
Im using something similar to the example to drive RTS style events, but once Defend is active, it cannot be interrupted by a new command ,like Move.

How do I solve this?
You can use the interrupt system: https://opsive.com/support/document...o/concepts/tasks/action/perform-interruption/


Also is it possible to build a queue of tasks /events in game, that execute in order?
You can't add nodes dynamically at runtime but you could create a new task that executes specific logic based on the current list iterator. Another approach would be to create a new task similar to the existing Iterator where instead of iterating on GameObjects it iterates on your custom enum or event.
 
I tried using hte parallel node, but I cant get it to interrupt defend, the node from the Tactical pack.
Can you advise on a specific tree setup?
At the moment the tasks are just the unmodified TacticalPack Seek and Defend, driven by events1753696691807.png

Ive tried rearranging the interrupt nodes, putting them on separate branches, but the Defend node really locks in and doesnt want to stop XD
 
Last edited:
The Defend task always returns a running status so you need to use the Parallel task and perform the interruption when the event occurs. Take a look at the link from above for using the task - the Defend task will replace Idle in your example.
 
Back
Top