Run function (Event) from Child Actor

Hi guys,
I have a blueprint that has a child actor and that child actor blueprint has a custom event.
I’m trying to call the child actor event from the main blueprint but the event doesn’t show up - the only way I managed to make it work as to Get Child Actor, than to Cast it and only then it would show the custom events.

I don’t understand why I needed to get the child actor and then do the casting when the class was already set in for the child actor?

1 Like

Due to the 2 images limitation I’m posting here what I had to do to make it work

1 Like

This could just be me speculating, but your UI_InGame_Action is a ChildActorComponent. You need to get the Actor from that component, which is the child actor. The reason I believe you have to cast is as follows. You have gotten the actor. Though the actor in this case has your UI_InGame_Action Class, it’s still an Actor Class, which the compiler can’t see what that specific children that actor has under normal circumstances. To get by this, you have to confirm with the code, or in this case the blueprint, that it does have said class as a child, and thus allow it to access those functions.

NOTE: If this is the case, doing this to an actor that doesn’t have that class as a child will still be able to “access” those variables and fuctions, which results in an ERROR. This is just me relating this situation to how classes and pointers work in C++. This may not be the reason why, but it seams to fit.

In short, when you get the actor, you are not getting the class you give it off the bat, you have to get the actual actor, then cast to tell it IT DOES have that classes components to access them.

Bro that´s how you are supposed to do it. that’s not an error. Imagine you have 50 instances of the actor with the event attached to the parent and you want to run that event in only 1 of them or in 20 of them ?. Those events are specific for the actor instance. imagine something like an Begin Overlap, Each actor has his own Begin Overlap event that get’s triggered for that specific actor when something overlaps. It would be a mess if when Begin Overlap would trigger every single Begin Overlap event that it finds. Just the same with any other event.