Making a force burst in C++

I’d like to know what is the best way to make a force burst, e.g. as a result of explosion (I’m talking of course only about physical aspect, not about the visuals).

I’ll post a solution that I’ve found myself, but I’m curious if any1 has a better idea.

One may simply use URadialForceComponent type, and attach it to the projectile actor while when exploded - then instantly remove it.

URadialForceComponent* ForceComp = NewObject<URadialForceComponent>( this, TEXT( "MissileHitForceComp" ) );
ForceComp->SetWorldLocation( Hit.Location );
ForceComp->SetWorldRotation( Hit.Location.Rotation() );

ForceComp->Radius = 1700;
ForceComp->ForceStrength = 100000;
ForceComp->ImpulseStrength = 100000;

ForceComp->SetWorldLocation( Hit.Location );

ForceComp->AttachTo( this->GetRootComponent(), NAME_None, EAttachLocation::KeepWorldPosition );


// Now simply remove it, it will automatically drop the component from list returned by this->GetComponents().
ForceComp->DestroyComponent( true );

The component approach described by sick is pretty interesting, but another approach would be to simply use:


You will however need the following params:

UGameplayStatics::ApplyRadialDamage(GetWorld(), ExplosionDamageAmount, GetActorLocation(), ExplosionRadius, UDamageType::StaticClass(), ignoredActors, this, nullptr, false, ECollisionChannel::ECC_Visibility);

Please note that the damage impulse is contained in the DamageType class, which I don’t like very much as it doesn’t allow determining it dynamically.

Please let me know if you need any more details on the params and I’ll elaborate.