RealDocs

AActor::OnActorHit

property Engine Blueprint Since 4.0
#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
Event Actor Hit Self Actor Other Actor Normal Impulse Normal Impulse Hit Cast To AProjectile Object Cast Failed As AProjectile As AProjectile Destroy Actor Target is Actor Target
Edit Blueprint graph Cast the other actor on hit and destroy it if it is a projectile
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
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();
	}
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.