Surfaceflags or something of that sort?


I’m pretty new to UE4 (I’m about a month in at the moment) and I’d like to ask if there are any kind of surfaceflags or something of that sort?
By surfaceflags, I mean some kind of indicator which tells you if you are on solid ground, on slippery ice or any other kind of surface. Or would I have to build this in on my own and if so; what would be a good approach?

Best Regards

Take a look at the ShooterGame example, specifically Source/ShooterGame/Effects/ShooterImpactEffect.cpp. There you will see the game code has mapped some #defines in ShooterTypes.h to various values in the EPhysicalSurface enum. You can give these enums names (like ice) in Projects Settings under Engine > Physics > Physical Surfaces. Once you do that, you can create Physic Material Assets which you can assign these surface types to.


/** Types of surfaces in the game. */
enum EPhysicalSurface
    SurfaceType_Default UMETA(DisplayName="Default"),
    SurfaceType1 UMETA(Hidden),
    SurfaceType2 UMETA(Hidden),
    SurfaceType3 UMETA(Hidden),


#define SHOOTER_SURFACE_Default        SurfaceType_Default
#define SHOOTER_SURFACE_Concrete    SurfaceType1
#define SHOOTER_SURFACE_Dirt        SurfaceType2
#define SHOOTER_SURFACE_Water        SurfaceType3
#define SHOOTER_SURFACE_Metal        SurfaceType4
#define SHOOTER_SURFACE_Wood        SurfaceType5
#define SHOOTER_SURFACE_Grass        SurfaceType6
#define SHOOTER_SURFACE_Glass        SurfaceType7
#define SHOOTER_SURFACE_Flesh        SurfaceType8

Looking up the surface type in ShooterImpactEffect.cpp:

void AShooterImpactEffect::PostInitializeComponents()

    UPhysicalMaterial* HitPhysMat = SurfaceHit.PhysMaterial.Get();
    EPhysicalSurface HitSurfaceType = UPhysicalMaterial::DetermineSurfaceType(HitPhysMat);

    // show particles
    UParticleSystem* ImpactFX = GetImpactFX(HitSurfaceType);
    if (ImpactFX)
        UGameplayStatics::SpawnEmitterAtLocation(this, ImpactFX, GetActorLocation(), GetActorRotation());

Great information, thank you!

What I was looking for was more of the physical altering surfaces though; like when you’re walking on ice you’re sliding et.c. Are any of these dynamics built into the engine?

The Physical Material (the last image above) has settings related to friction.

Again, thank you.

If I was to force my character to slide on any surface, how would be best to go about it? I’ve tried setting the Friction to 0 but that doesn’t do it for me.

I’m not sure. Assuming you are using UCharacterMovementComponent, then maybe look at SetWalkableFloorAngle, CurrentFloor, and GroundFriction. GroundFriction, in particular, has the following note that sounds like what you’re trying to achieve:

I made it work by setting all friction variables to 0 when entering the “slide field”, thank you very much!