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.
#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;
}
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?
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.
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.
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: