# Accessing Child Events/Functions From Child Class/Actor

**URL:** <https://forums.unrealengine.com/t/accessing-child-events-functions-from-child-class-actor/2002511>\
**Category:** Programming & Scripting\
**Tags:** inheritance, child-class, parent-class, unreal-engine, question\
**Created:** [September 2, 2024, 7:21pm UTC](https://forums.unrealengine.com/t/accessing-child-events-functions-from-child-class-actor/2002511 "2024-09-02T19:21:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gardx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gardx](https://forums.unrealengine.com/u/Gardx)\
**Post date:** [September 2, 2024, 7:21pm UTC](https://forums.unrealengine.com/t/accessing-child-events-functions-from-child-class-actor/2002511/1 "2024-09-02T19:21:03Z")

</div>

Hi,

I have been working on a combat system and weapon equipping

I have a Parent class called BP\_Weapon from this I have derived Child Classes of BP\_Sword and BP\_Bow, of which functions/events are available on the child class BP\_Bow which I would like to access

These Weapons are presented in the way of a Data Table where eventually they will be cascaded down to have different types of sword and bow (wood, metal etc)

 ![DT_Weapons](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/7/d/f7d48e996b82072df07b4df5ed2c32b0360e797a.png)

Entries in the Data Table are derived from the struct BPS\_Weapons below where the Weapon Class is of the Parent Class BP\_Weapons, which I can then reference the Child class in the Data table.

 ![BPSWeapons](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/c/3/6c332c56d2a28ab2dd91622b31b0e75dbf01d464.png)

In my combat system that references the above data table, I have 2 functions, EquipBow and EquipSword.

**Equip Bow**

 ![EquipBowFunction](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/c/aec69f39ef20f00386aaa97d75b8308f0d2f0b96.png)

**Equip Sword**

 ![EquipSwordFunction](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/0/6b041c6247e998cd0fe36f3d76919a53ff64878d.png)

Passing the Child Class through the structure into spawn actor from class does give me a child actor of that class however, I have to cast on both functions in order to access the child functions/events inside BP\_Bow and when doing so the blueprint is working as expected

Is this a standard way to approach this? and for the eventual addition of the child classes of BP\_Bow (BP\_WoodenBow etc) will additional casts need to be incorporated to access any functions/events in the lower classes if any? or should care be taken to include them all in BP\_Bow so that they are inherited and if not needed do not use them?

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [September 2, 2024, 11:09pm UTC](https://forums.unrealengine.com/t/accessing-child-events-functions-from-child-class-actor/2002511/2 "2024-09-02T23:09:29Z")

</div>

Hey @Gardx! Welcome to the forums!

You’re on a good track here with one exception:  
It needs to be flipped around.

I’m assuming you’re putting all of this on the player character, as you never stated where this was but that what it seems like.

Once an actor is spawned, you can have that actor talk BACK to the player as part of its begin play. You can have that actor tell the spawner (in this case, the player) what abilities and variables the spawned actor has, using “Get Owner” if you pass in “Self” as owner on “SpawnActor”.

Otherwise, you will end up with the player actor getting bloated, storing all of the information, which is what you’re trying to avoid by using a DataAsset.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Gardx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gardx](https://forums.unrealengine.com/u/Gardx)\
**Post date:** [September 3, 2024, 8:44pm UTC](https://forums.unrealengine.com/t/accessing-child-events-functions-from-child-class-actor/2002511/3 "2024-09-03T20:44:26Z")

</div>

Hi @Mind-Brain thank you for the information.

It is not on the player character but inside an actor component that sits on the player character called BPC\_CombatSystem. I made it an actor component so it could be used potentially on AI enemies in the future without the need to redo functionality.

When you say flipped around I’m not quite sure what you mean? Do you mind clarifying? I’m not really wanting the player to know about the Bow and Sword, just the combat system itself. The combat system knowing more about the Bow, sword and weapon classes.

I think what I’m wondering or trying to answer/understand is why in my equip sword and equip bow functions above (on the actor component) I have to cast to the BP\_Bow or BP\_Sword Actor when I have spawned the actor and have a reference of the passed in actor out of the spawn actor node? Why can I not store it as a variable with BP\_Bow Object reference or BP\_Sword object reference and then access the functions that way? Is it because it is just a reference to an actor and not a actual actor? if that makes sense? If I print the return node it would say BP\_Bow0 / BP\_Sword0
