I’ve been trying to do a raycast and seeing what physical material it hits and doing damage based on the physical material hit on a player but every time I hit the player Unreal Engine crashes.
Any ideas on how I could implement this without it crashing?
Player.CPP
//Health is the UHealthComponent and HP is the health value of the component on the player
//Target is the player hit reference and Hit is the FHitResult hit info
switch (Hit.PhysMaterial.Get()->SurfaceType)
{
case 1:
UGameplayStatics::ApplyPointDamage(Target, 10.0f, Hit.TraceStart, Hit, GetInstigatorController(), this, UDamageType::StaticClass());
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::SanitizeFloat(Target->Health->HP));
break;
case 2:
UGameplayStatics::ApplyPointDamage(Target, 20.0f, Hit.TraceStart, Hit, GetInstigatorController(), this, UDamageType::StaticClass());
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::SanitizeFloat(Target->Health->HP));
break;
default:
UGameplayStatics::ApplyPointDamage(Target, 30.0f, Hit.TraceStart, Hit, GetInstigatorController(), this, UDamageType::StaticClass());
GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Green, FString::SanitizeFloat(Target->Health->HP));
}
Thanks in advance.