AActor::OnActorHit
#include "GameFramework/Actor.h"
Access: public
Specifiers: UPROPERTYBlueprintAssignable
Description
Multicast delegate fired when this actor hits (or is hit by) a solid blocking surface. Triggered by character movement, sweep-based SetActorLocation calls, or physics simulation impacts.
Caveats & Gotchas
- • For physics simulation collisions to trigger this, 'Simulation Generates Hit Events' must be enabled on the involved PrimitiveComponent (not just Generate Overlap Events). These are different flags.
- • This is an actor-level event; use UPrimitiveComponent::OnComponentHit for per-component hit info if the actor has multiple colliding primitives.
- • NormalImpulse in the delegate will be zero for kinematic (non-simulating) hits such as those from character movement — it is only populated when at least one body is simulating physics.
Signature
UPROPERTY(BlueprintAssignable, Category="Collision")
FActorHitSignature OnActorHit Examples
Cast the other actor on hit and destroy it if it is a projectile
Blueprint
Apply damage on hit C++
void AMyProjectile::BeginPlay()
{
Super::BeginPlay();
OnActorHit.AddDynamic(this, &AMyProjectile::HandleHit);
}
void AMyProjectile::HandleHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit)
{
if (IsValid(OtherActor))
{
UGameplayStatics::ApplyDamage(OtherActor, 25.f, nullptr, this, nullptr);
Destroy();
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?