UGameplayStatics::GetSurfaceType
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Extracts the EPhysicalSurface enum value from the physical material of a hit result. Use this to drive surface-specific effects like footstep sounds or impact particles.
Caveats & Gotchas
- • Returns SurfaceType_Default if the hit has no physical material — this happens unless bReturnPhysicalMaterial was true in the collision query that produced the hit.
- • Surface types are defined per-project in Project Settings > Physics > Physical Surface; the returned integer maps to that list, so handle the default case to avoid silent mismatches on surfaces you haven't assigned.
Signature
static ENGINE_API EPhysicalSurface GetSurfaceType(const struct FHitResult& Hit); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Hit | const struct FHitResult& | The hit result from which to read the physical material's surface type. | — |
Return Type
EPhysicalSurface Example
Play surface-specific footstep sound C++
EPhysicalSurface Surface = UGameplayStatics::GetSurfaceType(FootHit);
switch (Surface)
{
case SurfaceType1: // Concrete
UGameplayStatics::PlaySoundAtLocation(this, ConcreteFootstep, GetActorLocation());
break;
case SurfaceType2: // Grass
UGameplayStatics::PlaySoundAtLocation(this, GrassFootstep, GetActorLocation());
break;
default:
break;
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?