Calling Function on Child Actor Component

This is probably a super noob question but I couldn’t find the answer anywhere I looked.

I have a simple GunC BP, which is currently a in the FirstPersonCharacter BP. It has a simple function called Fire which does some stuff like checking how much ammo is in the mag and playing an animation if we do have enough ammo.

I also modified the builtin FirstPersonCharacter BP by adding GunC as a ‘Child Actor Component’. Also I tried to change the EventGraph so that when the InputAction Fire Event happens, it should call GunC.Fire().

Through the print statements, I can confirm that InputAction Fire does happen, and the cast to GunC does not fail. However GunC.Fire() does not seem to be executed.

I made similar logic that you want but in the opposite way.
In the pawn, I have controls that can turn on/off shooting (it is simply the boolean variable)


And I have a gun actor that is spawning and attaching to the pawn in run-time

The gun is casting by timer to the pawn to check is shooting turned on or not

It seems you are calling “Fire” that belongs to “Gun interface” , not the one that belongs to “GunC”.

You have two options :
-cast to GunC and use its “Fire” function (then it should be written “Target is GunC” instead of “Target is Gun interface”)
-OR use the Gun interface you created and you won’t need to cast. However you will need to implement the interface in “GunC” (which is actually not the case from what I can see on your pictures) and implement the event, then connect the “fire” function.

I would choose second option for its modularity

Ahh ok this fixed it, thank you

1 Like