# OnComponentHit event from a Skeletal Body/Bone?

**URL:** <https://forums.unrealengine.com/t/oncomponenthit-event-from-a-skeletal-body-bone/360977>\
**Category:** Character & Animation\
**Tags:** oncomponenthit, unreal-engine, skeletalmesh, CPP, question\
**Created:** [June 16, 2016, 11:50am UTC](https://forums.unrealengine.com/t/oncomponenthit-event-from-a-skeletal-body-bone/360977 "2016-06-16T11:50:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ionbordura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ionbordura](https://forums.unrealengine.com/u/ionbordura)\
**Post date:** [June 16, 2016, 11:50am UTC](https://forums.unrealengine.com/t/oncomponenthit-event-from-a-skeletal-body-bone/360977/1 "2016-06-16T11:50:25Z")

</div>

Hi there,

is it possible to get the **OnComponentHit** event only from a given part of a **USkeletalMeshComponent** (e.g left hand, right leg, finger tip of a skeleton) ?

Using the **Phasset** tool, I can select various bodies to generate hit events.

And using `MySkelMesh->OnComponentHit.AddDynamic(..)` works fine, however I would like to have this trigger only when a selected part of the skeleton is in collision.

Thanks!

---

<div class="post-metadata">

**Author:** ![ionbordura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ionbordura](https://forums.unrealengine.com/u/ionbordura)\
**Post date:** [June 27, 2016, 9:54am UTC](https://forums.unrealengine.com/t/oncomponenthit-event-from-a-skeletal-body-bone/360977/2 "2016-06-27T09:54:13Z")

</div>

Seems that one can check for the bone in collision from the **USkeletalMeshComponent**. So

```
MySkelMesh->OnComponentHit.AddDynamic(..)

```

will trigger for any bone collision from the skeleton. And then we can check ( **const FHitResult& Hit** ) if it is the bone we are looking for:

```
// Collision callback
void MyClass::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	// Bone in collision
	UE_LOG(LogTemp, Warning, TEXT("BoneName: %s"), *Hit.BoneName.ToString());

}
```

---

<div class="post-metadata">

**Author:** ![leva78](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@leva78](https://forums.unrealengine.com/u/leva78)\
**Post date:** [August 23, 2017, 5:11pm UTC](https://forums.unrealengine.com/t/oncomponenthit-event-from-a-skeletal-body-bone/360977/3 "2017-08-23T17:11:15Z")

</div>

This is not true. Hit.BoneName returns the name of the bone not of its actor, but of the one with whom it collided. If the bullet flies in my “leg”, then I will only know that something has got into me, and where (bone) is not known. But the bullet Hit.BoneName will know exactly what is “the leg”. For some reason this feature is not included, see Runtime / Engine / Classes / GameFramework / Actor.cpp line 3816 for details.  
Void AActor :: DispatchPhysicsCollisionHit (const FRigidBodyCollisionInfo & MyInfo, const FRigidBodyCollisionInfo & OtherInfo, const FCollisionImpactData & RigidCollisionData)  
In particular line 3829  
// @todo At the moment we only pass the first contact in the ContactInfos array. Maybe improve this?

Update:  
It is possible to use ActorLineTraceSingle, the input parameters to take from OnHit and in the resulting const FHitResult & Hit obtained after digesting, we get our bone

PS In version 4.17, the DispatchPhysicsCollisionHit function became virtual and the name of the bone can be obtained from there

---

<div class="post-metadata">

**Author:** ![ruggy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ruggy/32/1194574_2.png) [@ruggy](https://forums.unrealengine.com/u/ruggy)\
**Post date:** [December 10, 2017, 5:54pm UTC](https://forums.unrealengine.com/t/oncomponenthit-event-from-a-skeletal-body-bone/360977/4 "2017-12-10T17:54:10Z")

</div>

> > PS In version 4.17, the DispatchPhysicsCollisionHit function became virtual and the name of the bone can be obtained from there

Brilliant, thanks!
