So I’ve managed to fix the crash happening with the switch on the Surface Type but now the Surface Type is returning NULL and I don’t know how to fix it.
Any Ideas?
Player.CPP
//Target is the player reference and Hit is the FHitResult info
//Health is the health component we're accessing using the player reference and HP is teh health value stored in the health component
switch (UGameplayStatics::GetSurfaceType(Hit))
{
case SurfaceType1:
UGameplayStatics::ApplyPointDamage(Target, 50.0f, Hit.TraceStart, Hit, GetInstigatorController(), this, UDamageType::StaticClass());
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::SanitizeFloat(Target->Health->HP));
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::Printf(TEXT("SurfaceType: %s"), UGameplayStatics::GetSurfaceType(Hit)));
break;
case SurfaceType2:
UGameplayStatics::ApplyPointDamage(Target, 25.0f, Hit.TraceStart, Hit, GetInstigatorController(), this, UDamageType::StaticClass());
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::SanitizeFloat(Target->Health->HP));
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::Printf(TEXT("SurfaceType: %s"), UGameplayStatics::GetSurfaceType(Hit)));
break;
default:
UGameplayStatics::ApplyPointDamage(Target, 5.0f, Hit.TraceStart, Hit, GetInstigatorController(), this, UDamageType::StaticClass());
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::SanitizeFloat(Target->Health->HP));
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::Printf(TEXT("SurfaceType: %s"), UGameplayStatics::GetSurfaceType(Hit)));
}
Currently when the Surface Type is returned in the editor I get: (null), meaning in the switch statement its executing default.
And thanks in advance.