Take action on hit

eric

New member
I'm having a little trouble figuring out the right way to do this. I made a custom action that commands my NPC to attack. Right now I always have it return TaskStatus.Running; since it is always attacking. That might not be right. But anyway then I want it to dodge when it gets hit. So I send an event from my NPC controller to the behavior tree called "BeenHit". So far I don't seem to be understanding the right way to do this. If I put the getmessage in front of my attack then the sequence ends as soon as it starts since there is no message. If I put it after then nothing happens because it never gets there.

I thought I could put getmessage first as a conditional abort, but I don't see the option for that. So... anyway I'm kind of stuck. But this seems like something simple. What's the right way to attack this with behavior tree?

Thank you
 
You should use conditional aborts for this use case. Your conditional task will always reevaluate and when it has been hit it will return a status of success. Because it is reevaluating the task will abort your attacking task.

The Behavior Designer basics videos have a good overview of how to use conditional aborts.

 
Top