# Can't get child class instance from "OnHit" function

**URL:** <https://forums.unrealengine.com/t/cant-get-child-class-instance-from-onhit-function/448228>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 2, 2019, 8:16am UTC](https://forums.unrealengine.com/t/cant-get-child-class-instance-from-onhit-function/448228 "2019-05-02T08:16:38Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Lardo\_Deepdelver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lardo\_Deepdelver](https://forums.unrealengine.com/u/Lardo_Deepdelver)\
**Post date:** [May 2, 2019, 10:03am UTC](https://forums.unrealengine.com/t/cant-get-child-class-instance-from-onhit-function/448228/4 "2019-05-02T10:03:18Z")

</div>

casting can not work with runtime classes, it needs to know what to cast to at compile time

sounds like what you want to do is use an interface

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

basically all your classes that should DoSomething need to implement that interface and in the hit you check if the object implements it, and if so call it

---

_[View the full topic](https://forums.unrealengine.com/t/cant-get-child-class-instance-from-onhit-function/448228)._
