Call actor reference custom events set in runtime

I have a blackboard key set as type object with a base class of actor which is a reference to an enemy in my game. In a task in the attached behaviour tree, I’m setting this reference which is allocated in runtime to the Get Actor of Class node and trying to use a custom event from that reference like below.

Because this reference is set in runtime, the Get Actor of Class is returning an Actor object reference thus not allowing me to access the Blueprint custom event. Is there any way around this that doesn’t involve hard coding multiple different versions of the same behaviour tree task for different enemy types etc.? Eventually I’ll make this into a base class so every enemy will have this custom event, but even so how would I access it when it’s allocated at run time? Is there any way to do this without hard coding the actor class like in the first picture?


Hey @angusthecrab! Welcome to the forums!

So this would be a great use for a Blueprint Interface!
Basically you’ll create the interface,
create your take damage function,
then implement the BPInterface to every enemy that you need.

Then in this task, you’ll use “implements interface?” to check it (running around it on fail), and then if implements interface = True, send a message using the interface to that actor. You’ll be able to see what I’m saying in more detail here in the documentation:

However, all of that aside, it would still be better to go ahead and make a parent for your enemies. The sooner you do that, the better :slight_smile:

2 Likes

Thank you for the solution, it worked!

1 Like