Download

Possible to make a child actor blueprint use different BP logic on custom event?

What I have right now is an actor class BP with custom events “LookedAt” and “NotLookedAt”, which trigger in response to traces from the player camera. When the camera is pointed at an instance of the actor, it responds, right now by changing color. It changes back when the camera looks away.

What I’d like is to do is use the actor as a parent for others which I would like to respond to the “LookedAt” and “NotLookedAt” events, but not necessarily in the same way. I’ve been able to change the materials used by the existing logic by exposing them as variables and setting different defaults in the child class, but what if I want different BP functions to run from it? I suppose I can set up variables that indicate the behaviour of each child class, give each one an identifying value in their defaults and set all the logic in the parent class, but that seems messy. Attempting to set up the LookedAt/NotLookedAt custom events in the child’s event graph just seems to break the existing function, so neither the original material-changing logic nor the new function seem to fire.

Will I have to go back and run the material-changer from event tick and use a variable to determine the correct state? So the LookedAt event will set a variable to true, and the tick event will run a function to set the material based on that? Should I be concerned about overheads if I’m doing this will lots of these objects at once? Seems like it shouldn’t need to be that way…

I’d say use an Event Dispatcher for this. When your base class’ logic runs, also call the event dispatcher. On the child classes, bind a new custom event to this dispatcher and run your custom logic.

Here’s a tutorial I posted in another topic: https://forums.unrealengine.com/showthread.php?52390-casting-messaging-to-other-blueprints-specified-in-quot-open-quot-variables&p=183599#post183599

That looks promising, thanks! The +Event Dispatcher button is clipped of in my display so I might have missed it.

Hello,
If you solve your issue with an event dispatcher this is good, but parent child custom event works fine, you just need to do :
Or set your custom event in your parent only and it works on call for every child.
Or set custom event empty in parent, set it in child and each child will have its own reaction on call.
Or set custom event in both parent for common effects and child for particular effect, then you need to call the parent custom event from your custom event in your child before adding your code there (do right click on custom event “add call to parent” this is an orange node.)

This a great information! This is something I do all the time in code, but I never thought to transfer that over to Blueprints! Thank you for that bit.