ApplyRadialDamageWithFalloff Not applying falloff damage

I’m trying to create a quake style rocket launcher and am trying to use UGameplayStatics::ApplyRadialDamageWithFalloff to do so. When an actor is within the outer damage radius they are given the base damage regardless of where they are positioned. my inner damage radius is 17 and my outer damage radius is 450.

Here is my code for the projectile:

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "FPSProjectile.generated.h"


class UProjectileMovementComponent;
class USphereComponent;
struct FRadialDamageParams;

UCLASS()
class AFPSProjectile : public AActor
{
	GENERATED_BODY()

protected:

	/** Sphere collision component */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Projectile")
	USphereComponent* CollisionComp;

	/** Projectile movement component */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Movement")
	UProjectileMovementComponent* ProjectileMovement;

	UPROPERTY(EditDefaultsOnly, Category = "Explosion")
	struct FRadialDamageParams ExplosionDamage;

public:

	AFPSProjectile();

	/** called when projectile hits something */
	UFUNCTION()
	void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);

	/** Returns CollisionComp subobject **/
	USphereComponent* GetCollisionComp() const { return CollisionComp; }

	/** Returns ProjectileMovement subobject **/
	UProjectileMovementComponent* GetProjectileMovement() const { return ProjectileMovement; }
};

Here is my code for the actor taking damage:

#include "FPSTestDummy.h"
#include "Components/StaticMeshComponent.h"
#include "Components/BoxComponent.h"
#include "Math/UnrealMathUtility.h"

// Sets default values
AFPSTestDummy::AFPSTestDummy()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
	MeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
	RootComponent = MeshComp;

	BoxComp = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxComp"));
	BoxComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
	BoxComp->SetupAttachment(RootComponent);

}

// Called when the game starts or when spawned
void AFPSTestDummy::BeginPlay()
{
	Super::BeginPlay();

	CurrentHealth = StartingHealth;
	
}

// Called every frame
void AFPSTestDummy::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

float AFPSTestDummy::TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser)
{
	int32 DamagePoints = FPlatformMath::RoundToInt(DamageAmount);
	UE_LOG(LogTemp, Log, TEXT("Damage is:%d"), DamagePoints);

	CurrentHealth -= DamagePoints;
	if (CurrentHealth <= 0)
	{
		Destroy();
	}
	return DamagePoints;
}

Hello Headhunter,

Have you made sure that the damage falloff exponent is not equal to zero, that the inner damage radius is less than the outer radius and the bFullDamage parameter isn’t true?

Regards,

Vecherka.

The damage falloff is set to 1. the inner damage radius is 17 and the outer is 450. How do i set bFullDamage? I’m really new to Unreal so you’ll have to bare with me haha

Could you send us the actual call of the ApplyRadialDamageWithFalloff method? I’m sorry the bFullDamage parameter is something from an older version of the engine, sorry about that.

Sure, i forgot to put it in the initial question, sorry.

void AFPSProjectile::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) && OtherComp->IsSimulatingPhysics())
	{
		OtherComp->AddImpulseAtLocation(GetVelocity() * 100.0f, GetActorLocation());
	}

	if (ExplosionDamage.BaseDamage > 0.0f)
	{
		UGameplayStatics::ApplyRadialDamageWithFalloff(this, ExplosionDamage.BaseDamage, ExplosionDamage.MinimumDamage, GetActorLocation(), ExplosionDamage.InnerRadius, ExplosionDamage.OuterRadius, ExplosionDamage.DamageFalloff, UDamageType::StaticClass(), TArray<AActor*>(), this, Instigator->GetController());
		DrawDebugSphere(GetWorld(), GetActorLocation(), ExplosionDamage.InnerRadius, 20, FColor::Black, false, 10, 0, 1);
		DrawDebugSphere(GetWorld(), GetActorLocation(), ExplosionDamage.OuterRadius, 20, FColor::Purple, false, 10, 0, 1);
	}

	MakeNoise(1.0f, Instigator);
	Destroy();
}

Sorry to bother you again, but could you give us the ExplosionDamage struct values?

296384-capture.png

The values don’t seem to be wrong?

No not really, and to be honest I’m kinda puzzled as this should work as expected. So just a silly question, the projectile doesn’t always hit the dummy does it, or hits something in close vicinity to it?
The ApplyRadialDamageWithFalloff function generates a FRadialDamageEvent, so it should be treated as one. Furthermore the ApplyRadialDamageWithFalloff function overwrites the DamageType DamageFalloff parameter.

The projectle hit the floor near the target.

Would you mind sharing an example screenshot?

Sure, I’ve added a screenshot to the original question

Oh my god, totally ignored that. TakeDamage is supposed to handle the damage it receives, so a simple call to the actor class should to the trick. Just replace this line inside the TakeDamage method:

int32 DamagePoints = FPlatformMath::RoundToInt(DamageAmount);

whit this one

int32 DamagePoints = FPlatformMath::RoundToInt(Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser));

Sorry for causing such a commotion, totally my mistake.

No worries. I’ll try that now

That worked. Thank you for the help Vecherka

Glad to hear. Sorry again for overlooking that.

Don’t forget to mark this question as answered. So people can find it easier, and to make it clear the question is closed. :slight_smile: