Download

Call child event from a parent reference

I have a parent blueprint for my enemies that just contain some basic variables and components that are common to any children instances.

In my game, whenever I am looking for overlap events I am casting to the base blueprint class to see if it is an enemy.

From there I need to be able to call a function that is part of the child instance but not the parent.

Is there a way I can do this without having to cast to each different child instance for every overlap/collision check?

Originally I was going to put the event in question in the parent blueprint however it relies on variables that are different for each child.

As far as I know, you have to do a ‘get child actor’ and cast to reach the child BP from the parent.

What it probably means is the child should deal with the event.

Ideally I want to avoid this as it means having to check the overlap/hit for several different child classes and then cast to the correct child class to run the events.

I ended up changing the custom events to functions and was then able to override the functions in the child class.

If you’re constantly having to reach into the child like that, it sounds like that code should be in the child.

I must say, this is one of the reasons I don’t use inheritance much…