So I use the line trace to get the physics material of the terrain, the function fires up and reaches the actual setting of the physics material and then just blanks out. can somebody explain to me what am I doing wrong here?
//terrain check for sounds
void APango::TracePhysicalSurface()
{
FVector StartTrace = FVector::ZeroVector;
FVector CamLoc;
FVector target;
FCollisionQueryParams TraceParams;
FHitResult currentHit;
CamLoc = GetActorLocation();
target = CamLoc + FVector(0.0f, 0.0f, -300.0f);
TraceParams;// = FCollisionQueryParams(false);
TraceParams.AddIgnoredActor(this);
TraceParams.bReturnPhysicalMaterial = true;
UPhysicalMaterial* physMat = NULL;
if (GetWorld()->LineTraceSingleByChannel(currentHit, CamLoc, target, ECollisionChannel::ECC_MAX, TraceParams))
{
//UE_LOG(LogTemp, Warning, TEXT("LineTrace HIT"));
//finding the phys mmaterial
if (currentHit.IsValidBlockingHit())
{
UPrimitiveComponent* comp = currentHit.GetComponent();
if (comp)
{
UMaterialInterface* mat = comp->GetMaterial(0);
if (mat)
{
physMat = mat->GetPhysicalMaterial();
}
}
//switch loop to actually play the sounds
if (physMat)
{
UE_LOG(LogTemp, Warning, TEXT("LineTrace sound physics mat"));
switch (physMat->SurfaceType)
{
case EPhysicalSurface::SurfaceType1:
pRollingAudio->Play();
break;
case EPhysicalSurface::SurfaceType2:
//pBoostAudio->Play();
break;
default:
//pLandingAudio->Play();
pRollingAudio -> Play();
break;
}
}
}
}
else
UE_LOG(LogTemp, Warning, TEXT("LineTrace work"));
return ;
}