Extending with code

Everything here is optional: Responsive FX needs no code. Namespace RareGeometry.ResponsiveFX.

Listen to steps #

var footsteps = GetComponent<SurfaceFootsteps>();
footsteps.Stepped += step =>
{
    // step.surface.surface: the Surface; step.surface.source: why it was chosen
    // step.point, step.normal, step.foot, step.movement (Walk, Run, Sprint, Crouch, Jump, Land)
    // step.volume, step.intensity (landings: how hard), step.noiseRadius, step.addedZone
};
footsteps.Attempted += record => { /* every attempt, with record.result when it didn't play */ };

Play steps yourself #

footsteps.Trigger = FootstepTrigger.Manual;
footsteps.Step();                                    // the current movement, alternating feet
footsteps.Step(Foot.Left, FootstepMovement.Run);
footsteps.Jump();
footsteps.Land(fallSpeed: 7f);
footsteps.SetCrouching(true);
footsteps.SetAutoStepsPaused(true);                  // swimming, ladders, cutscenes (Step() still works)
footsteps.ResetMotion();                             // after a teleport or respawn

Your own audio system #

public sealed class FmodFootsteps : MonoBehaviour, IFootstepSoundPlayer
{
    public void PlayFootstep(in FootstepEvent step, AudioClip clip, float volume, float pitch)
    {
        // Play your event with step.surface.surface.DisplayName as a parameter, at step.point.
    }
}

Drag the component into Sound Player on Surface Footsteps. Responsive FX then plays nothing itself.

Ask what a surface is #

SurfaceResolution r = library.ResolveHit(hit);        // zones first, then the collider, like a footstep
if (library.TryResolveAt(position, out var below)) { } // cast down from a point, no character needed
if (r.Found) Debug.Log(r.surface.DisplayName + " " + FootstepDiagnostics.SourceWords(r));
library.SetRule(myMaterial, metalSurface);        // map from code
library.RefreshTerrain(terrain.terrainData);      // after painting at runtime
SurfaceCacheVersion.Bump();                       // after changing materials or tags from code
library.PrewarmTerrains();                        // after loading a terrain at runtime (no hitch on the first step)

AI hearing #

FootstepNoise.Made += step => { if (step.noiseRadius > Vector3.Distance(step.point, transform.position)) Investigate(step.point); };

Setup checks from code #

var problems = new List<FootstepProblem>();
FootstepDiagnostics.Check(footsteps, problems);   // the same checks as the debugger window

Responsive FX has no static state that survives Play Mode, so it works with Domain Reload disabled.

Something unclear or wrong? Tell us · Get help