AActor::ReceiveHit
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintImplementableEvent
Description
Blueprint event fired when this actor blocks or is blocked by another actor's movement. Covers character movement sweeps, SetActorLocation with sweep, and physics simulation collisions.
Caveats & Gotchas
- • For physics-simulated bodies, 'Simulation Generates Hit Events' must be enabled on the PrimitiveComponent, otherwise this event will not fire from physics hits.
- • When bSelfMoved is false (another actor hit this one), Hit.Normal and Hit.ImpactNormal are adjusted to represent the force direction against this actor — they will point away from the other actor rather than away from this actor's surface.
- • NormalImpulse is zero for swept blocking collisions (character walking into a wall). It is only populated when physics simulation generates the hit.
Signature
ENGINE_API void ReceiveHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| MyComp | class UPrimitiveComponent* | The component on this actor that was hit. | — |
| Other | AActor* | The other actor involved in the hit. | — |
| OtherComp | class UPrimitiveComponent* | The component on the other actor that was hit. | — |
| bSelfMoved | bool | True if this actor was the one that moved into the other. False if the other actor moved into this one. | — |
| HitLocation | FVector | World location of the hit. | — |
| HitNormal | FVector | Normal of the hit surface. | — |
| NormalImpulse | FVector | Impulse applied at the hit point (non-zero only for physics simulation hits). | — |
| Hit | const FHitResult& | Full hit result with detailed contact information. | — |
Return Type
void Examples
Cast the hitting actor and destroy it on a blocking hit
Blueprint
React to being hit by a specific actor type C++
void AMyActor::NotifyHit(UPrimitiveComponent* MyComp, AActor* Other, UPrimitiveComponent* OtherComp,
bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
{
Super::NotifyHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit);
if (AProjectile* Projectile = Cast<AProjectile>(Other))
{
ApplyDamage(Projectile->GetDamage(), HitLocation, HitNormal);
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?