I’m attempting to call TakeDamage() using my custom Weapon Class for some basic damage system. However, I can’t get the Point Damage to work properly.
void ABLTWeapon::PerformShot()
{
if (!GetOwner() || !Instigator)
return;
FCollisionQueryParams CollisionParams;
CollisionParams.AddIgnoredActor(this);
CollisionParams.AddIgnoredActor(Instigator);
FMinimalViewInfo CamInfo;
Cast<ABLTPlayerPawn>(Instigator)->CameraComponent->GetCameraView(FApp::GetDeltaTime(), CamInfo);
FVector StartLoc = CamInfo.Location;
FVector EndLoc = StartLoc + (CamInfo.Rotation.Vector() * 512);
FHitResult HitResult;
if (GetWorld()->LineTraceSingle(HitResult, StartLoc, EndLoc, ECC_GameTraceChannel1, CollisionParams))
DrawDebugLine(GetWorld(), CamInfo.Location, HitResult.Location, FColor::Magenta, true);
else
DrawDebugLine(GetWorld(), CamInfo.Location, CamInfo.Location + (CamInfo.Rotation.Vector() * 512), FColor::Magenta, true);
FPointDamageEvent DamageEvent;
DamageEvent.HitInfo = HitResult;
DamageEvent.DamageTypeClass = UDamageType::StaticClass();
if (HitResult.Actor != NULL)
HitResult.Actor->TakeDamage(Damage,DamageEvent, Instigator->GetController(), this);
//Sets a timer to our "delay" between shots, then starts the firing chain again
GetWorldTimerManager().SetTimer(this, &ABLTWeapon::BeginFire, FireInterval);
}
Then inside my BLTPawn class, I have logs setup.
float ABLTPawn::TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser)
{
UE_LOG(LogNPC, All, TEXT("%s::TakeDamge(DamageAmount:%f,DamageEvent: TODO, EventInstigator:%s,DamageCauser:%s"), *GetName(), DamageAmount, *EventInstigator->GetName(), *DamageCauser->GetName());
UE_LOG(LogNPC, All, TEXT("Eventdamage.ClassID: %f"), DamageEvent.ClassID);
Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
return 0;
}
float ABLTPawn::InternalTakePointDamage(float Damage, struct FPointDamageEvent const& RadialDamageEvent, class AController* EventInstigator, AActor* DamageCauser)
{
UE_LOG(LogNPC, All, TEXT("POINT DAMAGE!!!!!!!!!!!!!!!!!"));
return 0;
}
However, there is no calling of InternaltakePointDamage. I logged the Class ID as stated, and it keeps coming up as 0 despite the struct default being set to 1. So it seems like the IDing system isn’t operating as intended?