for some strange resson my PhysicMaterial is null and i cant work with it!
This gets called everytime i call my moveFunction.
void AArcadeShooterCharacter::Footsteps()
{
if (CanJump())
{
if (footCounter < maxFootCounter)footCounter++; else
{
footCounter = 0;
FVector start = GetActorLocation();
FVector end = FVector(start.X, start.Y, start.Z - 500);
FCollisionQueryParams params(FName(TEXT("Footsteps")), false, this);
FHitResult hit(ForceInit);
if (RayCast(hit, params, 500, start, end))
{
if (hit.PhysMaterial == NULL){ UE_LOG(LogTemp, Warning, TEXT("NULL")); }
else
{
UE_LOG(LogTemp, Warning, TEXT("Valid"));
}
if (materialType == MaterialType::Grass) UGameplayStatics::PlaySoundAtLocation(this, GrassSound, GetActorLocation());
if (materialType == MaterialType::Wood) UGameplayStatics::PlaySoundAtLocation(this, WoodSound, GetActorLocation());
if (materialType == MaterialType::Stone) UGameplayStatics::PlaySoundAtLocation(this, StoneSound, GetActorLocation());
if (materialType == MaterialType::Water) UGameplayStatics::PlaySoundAtLocation(this, WaterSound, GetActorLocation());
}
}
}
}
Heres my SingleTrace
bool AArcadeShooterCharacter::RayCast(FHitResult RV_Hit, FCollisionQueryParams params, float d, FVector Start, FVector End)
{
params.bReturnPhysicalMaterial = true;
params.bTraceAsyncScene = true;
params.bTraceComplex = true;
bool DidTrace = GetWorld()->LineTraceSingle(RV_Hit,Start,End,ECC_Pawn,params);
return DidTrace;
}
and if i want to use hit.PhysMaterial->SurfaceType; when i get “Pointer to incomplete class type is not allowed” ?
What am iam doing wrong ?
Iam new to UE4’s c++. So please excuse my bad code writing iam still learning.