# C++ OnClicked mesh component works on parent but not child

**URL:** <https://forums.unrealengine.com/t/c-onclicked-mesh-component-works-on-parent-but-not-child/476097>\
**Category:** Blueprint\
**Tags:** inheritance, unreal-engine, onclicked, Blueprint, question\
**Created:** [December 18, 2020, 1:25pm UTC](https://forums.unrealengine.com/t/c-onclicked-mesh-component-works-on-parent-but-not-child/476097 "2020-12-18T13:25:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darthmarshie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Darthmarshie](https://forums.unrealengine.com/u/Darthmarshie)\
**Post date:** [December 18, 2020, 1:25pm UTC](https://forums.unrealengine.com/t/c-onclicked-mesh-component-works-on-parent-but-not-child/476097/1 "2020-12-18T13:25:12Z")

</div>

I have a C++ Class EnemyBaseClass. It has this function in:

```
void AEnemyBaseClass::OnEnemyClicked(UPrimitiveComponent* pComponent, FKey inKey)
{
	UE_LOG(LogTemp, Log, TEXT("WAS CLICKED"));
}

```

The Constructor has this:

```
 GetMesh()->OnClicked.AddDynamic(this, &AEnemyBaseClass::OnEnemyClicked);

```

- I have a Blueprint called BP\_EnemyBaseClass which is based on the C++ class.

- I have another Blueprint called BP\_BadGuy that inherits from the BP\_EnemyBaseClass Blueprint.

- I have several BadGuy blueprints placed in the world. When I click on them, nothing happens.

When I place a BP\_EnemyBaseClass in the world, I can click it and the UE\_LOG triggers.

I don’t understand what the deal is? I’ve set up the collisions properly. The clicking works fine if I use Blueprint and it works fine on the parent class, but on the BadGuy class that inherits from the EnemyBaseClass it doesn’t work. The UE\_LOG never happens for the BadGuy Blueprints placed in the world.

Suggestions?

---

<div class="post-metadata">

**Author:** ![Darthmarshie](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Darthmarshie](https://forums.unrealengine.com/u/Darthmarshie)\
**Post date:** [December 18, 2020, 1:42pm UTC](https://forums.unrealengine.com/t/c-onclicked-mesh-component-works-on-parent-but-not-child/476097/2 "2020-12-18T13:42:12Z")

</div>

SOLVED KIND OF?: Well, I deleted all the BP\_BadGuy blueprints that were in the scene and placed them back and now the clicking functionality works fine.

I still don’t understand what the problem was. So if someone has a better answer, please feel free to give it here.
