Get Actor Property in BT Service

Hey all, so first what I’m trying to accomplish, is that given a scenario where my AI is in the process of attacking a player, I want it to first check that the player it’s attacking is still alive before proceeding with the next attack, I do this by calling a service before the attack branch which attempts to retrieve a boolean from the player character ‘IsAlive’, then using that value to set a local blackboard key which is used as a decorator on the attack branch.

The issue, is that I can’t get it to get the player characters IsAlive property and assign it to the blackboard key. What I’ve tried so far is 3 different approaches, firstly I’ve tried having a reference to the player character object which is working correctly, as I can see in the visualizer it’s correctly assigning the object type key to the target:

315079-targetref.png

And this is the service using the first method of just casting to the player character:

But as mentioned, that didn’t work, so I tried a second method of setting a reference to the player character in my AI Controller, then casting to the AI controller in the service and from there accessing the player character reference and its IsAlive property:

Again no luck with this one, so I’ve also tried another method of using an interface, and passing a reference to the local blackboard through an interface message to the character, where the character can then use the reference to set the blackboard key from its side:

And on the player character side:

315094-method3b.png

I’m out of ideas at this point, what am I doing wrong?

So figured I would post an update to this since the problem and my understanding of the issue has evolved, it turns out the problem has not been in the implementation, but there’s an issue in a decorator in the behavior tree…

So if I do the branch as follows:

Then the service runs correctly and sets the IsTargetAlive key exactly as it should no problems.

But the instant I add a decorator to the following node like so:

The IsTargetAlive service immediately ceases to function, and so the decorator can never evaluate to true.

Any ideas?

Okay I solved the issue! It turns out I was calling the wrong receive event in the service. I was calling the Event Receive Activation, which seems to not trigger until after the next node is evaluated, and when the next node was failing due to the decorator evaluating to false, it wasn’t ever triggering the Activation.

I’ve switched to Event Receive Search, which triggers before going to the next node in the branch hence setting the boolean before checking the decorator in the following node.