3D Free Grounder

Raycast-based grounder for standard 3D locomotion — detects ground contact with coyote time, applies manual gravity when airborne, switches to Slide mode on steep slopes.

GS_PhysicsRayGrounderComponent is the standard grounder for walking characters. Each physics tick it casts a ray downward from the unit’s capsule base, evaluates the slope, applies gravity when airborne, and updates the MoverContext with ground normal and grounding state.

Grounding mode name: "Free"

For usage guides and setup examples, see The Basics: GS_Unit.

Grounder component in the O3DE Inspector

 

Contents


How It Works

Each post-physics tick, the grounder runs two operations in order:

  1. GroundCheck() — determines contact, slope, and normal
  2. GroundingMove() — applies gravity or snap force based on contact result

Ground Check

GroundCheck() casts a sphere (matching the capsule base radius) downward from the unit’s feet:

  1. If the ray hits geometry within groundCheckDistance:
    • Computes slope angle from the hit normal vs. world up.
    • Updates MoverContextRequestBus::SetGroundNormal(hitNormal).
    • If slope angle ≤ maxWalkAngle (from the MoverContext): reports Grounded.
    • If slope angle > maxWalkAngle: reports Sliding.
    • Resets coyote timer.
  2. If no hit:
    • Increments coyoteTimer.
    • If coyoteTimer < coyoteTime: still reports Grounded (coyote grace period).
    • If coyoteTimer ≥ coyoteTime: reports Falling.

Grounding Move

GroundingMove() applies vertical forces based on the current state:

Grounded: Applies a downward TimedSpringDamper to keep the unit snapped to the surface without bouncing.

Falling: Applies manual gravity — adds gravityScale * AZ::Physics::DefaultGravity to the rigid body’s linear velocity each frame:

AZ::Vector3 velocity = rigidBody->GetLinearVelocity();
velocity.SetZ(velocity.GetZ() + gravity * delta);
rigidBody->SetLinearVelocity(velocity);

Sliding: Does not override vertical velocity — the Free Mover’s AccelerationSpringDamper handles the slide direction entirely.


Grounding State Changes

GroundingStateChange(newState) is called whenever the ground state changes:

StateValueTriggerAction
Falling0Lost ground contact beyond coyote timeSetContextState("grounding", 0)
Grounded1Ray hit within walkable angleSetContextState("grounding", 1)
Sliding2Ray hit but slope > maxWalkAngleSetContextState("grounding", 2), ChangeMovementMode("Slide")

When returning to Grounded from Sliding, the grounder calls ChangeMovementMode("Free") to restore locomotion.


Editor-Exposed Settings

FieldDefaultDescription
groundCheckDistance0.15Raycast distance below the capsule base to detect ground.
capsuleRadius0.3Radius of the sphere used for the downward cast (should match capsule).
coyoteTime0.12Seconds of grace period before reporting Falling after losing ground contact.
gravityScale1.0Multiplier on AZ::Physics::DefaultGravity applied when airborne.
snapHalflife0.05Spring halflife for the ground-snap TimedSpringDamper. Smaller = tighter snap.

Extension Guide

Extend GS_PhysicsRayGrounderComponent to add custom ground detection or state reactions.

#pragma once
#include <Source/Unit/Grounder/GS_PhysicsRayGrounderComponent.h>

namespace MyProject
{
    class MyGrounder : public GS_Unit::GS_PhysicsRayGrounderComponent
    {
    public:
        AZ_COMPONENT_DECL(MyGrounder);
        static void Reflect(AZ::ReflectContext* context);

    protected:
        void GroundingStateChange(AZ::u32 newState) override;
    };
}
void MyGrounder::GroundingStateChange(AZ::u32 newState)
{
    // Call base to handle mode switching
    GS_PhysicsRayGrounderComponent::GroundingStateChange(newState);

    if (newState == 0)
    {
        // Unit became airborne — trigger jump animation, etc.
    }
}

See Also

  • Grounders — Grounder base class and class hierarchy
  • Slide Mover — Activated when this grounder reports Sliding state
  • Mover Context — Receives ground normal and state from this grounder
  • Springs UtilityTimedSpringDamper used for ground snap

Get GS_Unit

GS_Unit — Explore this gem on the product page and add it to your project.