Super::Notify(MeshComp, Animation, EventReference);
if (!MeshComp || !MeshComp->GetOwner()) return;
AActor* owner = MeshComp->GetOwner();
FVector footLocation = owner->GetActorLocation();
UWorld* world = owner->GetWorld();
if (world == nullptr) return;
FHitResult hitResult;
FVector start = footLocation;
FVector upVector = owner->GetActorUpVector();
FVector end = start + (upVector * -200.0f);
if (world->LineTraceSingleByChannel(hitResult, start, end, ECC_Visibility))
{
UPhysicalMaterial* physMaterial = hitResult.PhysMaterial.Get();
EPhysicalSurface surfaceType = SurfaceType_Default;
if (physMaterial)
{
surfaceType = UPhysicalMaterial::DetermineSurfaceType(physMaterial);
}
PlayFootstepSound(world, footLocation, surfaceType);
}
my code is like this. I want to get the surface but it is always returning NULL. and my surface has set phys materials. I need help figuring this out