Confused about parallel and interrupt behavior

Passero

New member
I am building a BT for a space ship. It's main purpose is to find a planet, look at what the planet has to offer and trade. Go to another planet and sell.
That part of the BT works fine.

I now want to add a behavior so if someone attacks the ship, it starts to run away from the attacker. I already implemented a Flee action but I am confused on how to incorporate it in my tree.

The issue is that I don't know how to combine parallel and/or interrupt so it will work? Some tasks will run for a while. I have a Goto action that keeps running while the ship moves towards a planet. This can take up a few minutes.

I don't know how I can create a branch in my tree so it keeps on checking if I'm attacked so it know it needs to interrupt whatever he is doing and move to another tasks.
Later on I want to add a IsHostileInRange condition that needs checking every time and will trigger another action.
 
It sounds like you'll want to use conditional aborts. Take a look at this video for an example setup that should help you get started:

 
Ok great. that seemed to do the trick.
Needs a bit getting used to.
I was trying to make it work so the Flee action is aborted when the ship is no longer under attack. I needed to set my sequence abort to Both.

I was trying to over complicate it with parallel and interrupts.

Here's how it looks with the conditional abort and it works just fine!

bt.JPG
 
One more question around this.
Can I somehow restrict Is Under Attack to be evaluated less times? At the moment it is running every tick but I want a lower frequency. Once every second for example.
 
Can I somehow restrict Is Under Attack to be evaluated less times? At the moment it is running every tick but I want a lower frequency. Once every second for example.
You can tick the entire tree at a different rate by manually calling BehaviorManager.Tick, but you are unable to set the tick rate for a specific task.
 
Sorry for bringing up an old thread, but I have a related question to the last one, can't we put a wait node in the the first sequence, to make it check it once a second for example?
 
Sorry for bringing up an old thread, but I have a related question to the last one, can't we put a wait node in the the first sequence, to make it check it once a second for example?
Doesn't make sense, it will still reevaluate condition on every frame during wait task. If you're a coder, just write your own conditional task with timer. Without a code you can create additional branch in parallel, which will calculate bool variable, and use this variable instead of conditional task.

111.PNG

Looks ugly, may be you can simplify it somehow. Also, beware that parallel tasks run in reversed order, that's why the main branch is on the left.
 
Thanks for the reply, sure I could write my own task if that would be easier. Thanks for clarifying that, also I didn't know about parallel tasks run in reversed order. Also sounds like we could have a condition task like "is under attack" that would set a bool straight away based on it's success status. It's very interesting, just a little confusing sometimes. :)
 
Top