Applying and Receiveing Radial Damage in C++

Hello Guys,

I am working on extending the Testing Ground FPS project, and one feature that I would like to add it, is a simple exploding canister. When shot at, it should explode (this part + the particle effects I have already implemented), and then apply a radial damage to the Characters within a radius. I have a C++ parent class and a BP object that inherits from it. I would like to be able to both apply and take the damage from the C++ side.

I know that I should use the UGameplayStatics::ApplyRadialDamage (from the barrel side) and the TakeDamage (from the Character side) functions, similar to what was done in the BattleTank project, however, so far I was unsuccessful - my FP Character refuses to take any damage (except the damage from the projectiles). Are you guys aware of any example that would show how to do this + the correct collision settings to be applied on the BP side for the FP or TP Characters ?

Well what do you have so far?

Ok, so I have the following:


void AProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
	// Only add impulse and destroy projectile if we hit a physics
	if ((OtherActor != NULL) && (OtherActor != this) && (OtherComp != NULL))

		if (OtherComp->IsSimulatingPhysics())
			OtherComp->AddImpulseAtLocation(GetVelocity()*ImpulseMultiplier, GetActorLocation());

		UGameplayStatics::ApplyPointDamage(OtherActor, ProjectileDamage, GetVelocity().GetSafeNormal(), Hit, GetInstigatorController(), this, UDamageType::StaticClass());
		FTimerHandle TimerHandle;
		GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &AProjectile::DestroyProjectile, SelfDestructDelay, false);

void AProjectile::DestroyProjectile()
}`Preformatted text`


float ACannister_CPP::TakeDamage(float DamageAmount, FDamageEvent const & DamageEvent, AController * EventInstigator, AActor * DamageCauser)
	UE_LOG(LogTemp, Warning, TEXT("Damage Received %f"), DamageAmount)

	TArray<AActor*> ignoredActors;

	Hitpoints = Hitpoints - DamageAmount;

	if (Hitpoints <= 0)


		FTimerHandle TimerHandle;
		GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ACannister_CPP::DestroyCannister, SelfDestructDelay, false);

	return 0.0f;

After playing yesterday around with these functions, both in C++ and BP, I suspect that it might have something to do with the location/origin where I am applying the radial damage and the EcollisionChannel.

Could it be that by applying the radial damage at the actor location, I am applying it from “within” or under the canister, so it actually gets blocked by the canister mesh due to the “ECollisionChannel::ECC_Visibility” ? Unfortunately I did not have yet the time to test this latest theory.


I don’t think so but you could just add GetOwner() to the ignored actors, what values are you using for everything?

Hey Dan,
Sorry for the delay. Thanks for the help btw.
Added GetOwner() to ignoredActors, but unfortunately it made no difference.
In terms of values:
-> CannisterDamage - 30.0;
-> Radius - 600.0;
->I am not sure this is relevant, but Hitpoints are set to 15, and for every hit, the cannister is taking 10 points of damage, so two shots are destroying it.
The rest is just engine API.
The cannister is taking damage when shot at. If Hitpoints drop below 0, the particle effects activate and after the SelfDestructDelay, it is destroyed…Only the ApplyRadialDamage fails to manifest.
I tried applying radial damage from BP, with exaclty the same parameters, with Event Hit and it worked :confused: … the difference here is where I am applying the damage: I am using the Hit Location as Origin, which puts it outside the Cannister Actor … I think.

One more comment - I just realized that I did not post this from the beginning: the logic for taking the damage, for the Character Actor, is in BP. And it works rather well - it is taking the damage from projectiles.

Hey Dan,

I think I solved it. The problem was with GetActorLocation() -> when I took a loot at it, it turned out that it was only returning (0,0,0). I looked it up -> this function actually returns the location of the RootComponent of a given actor. It seems that in my original code I was not setting it up (the RootComponent) properly.

Thanks for the help nonetheless.
Sincerely yours,

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms