# MotionCore Basic A Rigidbody character controller for Unity 6. Basic owns locomotion and the infrastructure around it: walking, sprinting, crouching, jumping, slopes, stairs, moving platforms, ground detection, animation hooks, events, and the extension points other systems plug into. It is deliberately scoped. Basic does not contain combat, weapons, inventory, stats, or a gameplay camera — see [Extending MotionCore Basic](#extending-motioncore-basic) for where those live. --- ## Contents - [Quick start](#quick-start) - [Requirements](#requirements) - [Configuration](#configuration) - [Architecture](#architecture) - [Reading character state](#reading-character-state) - [Events](#events) - [Extension points](#extension-points) - [Replacing the input source](#replacing-the-input-source) - [External forces](#external-forces) - [Moving platforms](#moving-platforms) - [Animation](#animation) - [Debugging](#debugging) - [Extending MotionCore Basic](#extending-motioncore-basic) - [Troubleshooting](#troubleshooting) --- ## Quick start 1. Drag `Core/prefabs/Player.prefab` into your scene. 2. Make sure your ground has colliders and is included in the controller's **Ground Layer Mask**. 3. Press Play. WASD moves, Shift sprints, Space jumps, C crouches. The prefab ships with tuned defaults, so it should feel right before you change anything. Two other ways in: - **`Tools > Character Controller > Setup Wizard`** converts an existing GameObject (your own model, your own rig) into a working character. - **`Tools > Character Controller > Build Demo Scene`** generates a movement gym with stairs, ramps, steep slopes, uneven terrain, a low ceiling, a jump course, and a moving platform. If something does not work, open `Tools > Character Controller > Validation Window`. It checks the common setup mistakes and offers one-click fixes. --- ## Requirements - Unity 6000.0 or newer - Input System package (`com.unity.inputsystem`) - UI package (`com.unity.ugui`) for the demo HUD only --- ## Configuration Everything below lives on `PlayerController`, grouped into collapsible inspector sections. Every field has a tooltip; this section covers the ones worth understanding before you tune. ### Movement `Speed` is the baseline ground speed. `Walk Speed` and `Sprint Speed` are **absolute target speeds**, not bonuses added to `Speed`. `Ground Acceleration` and `Ground Deceleration` control how quickly the character reaches and leaves its target speed, in m/s². Higher is snappier. Deceleration slightly above acceleration makes stopping feel crisp rather than slippery. ### Sprint `Sprint Activation` is `Hold` or `Toggle`. In toggle mode a press flips sprinting on and off, and releasing the movement input ends it — so the character does not silently sprint again the next time the player moves. ### Jump `Jumping Force` is launch speed in m/s. Jump height is roughly `force² / (2 × gravity)`, so with the default gravity, a force of 6.5 gives about 1.6 m. `Variable Jump Height` gives tap-versus-hold height control: releasing the jump button while rising scales the remaining upward speed by `Jump Cut Multiplier`. It needs an input source that reports `IsJumpHeld`. Jumps started from the buffer or from `TryJump()` always reach full height, so a scripted jump is never cut short. `Coyote Time` keeps the jump available briefly after walking off a ledge. `Jump Buffer Time` remembers a press made just before landing and fires it on touchdown. Both default to values that feel forgiving without feeling floaty. `Air Acceleration` and `Air Deceleration` are the airborne equivalents of the ground values. Low air deceleration preserves jump momentum; set `Can Move While Jumping` off for a fully committed jump. ### Gravity `Gravity Scale` scales `Physics.gravity` for this character only, so you can make one character heavy without touching project physics. `Fall Gravity Multiplier` adds extra gravity **only while falling**. Above 1 the descent is faster than the rise, which is what most action games want — it reads as responsive rather than floaty. Set it to 1 for a pure ballistic arc. `Max Fall Speed` is terminal velocity. It keeps long drops controllable and stops fast falls from tunnelling through thin floors. ### Crouch and stance Three stances: standing, crouching, prone. Each has its own speed and capsule height. The controller refuses to stand up into a ceiling, so a character crouched under a low overhang stays crouched until there is room. ### Ground detection `Ground Check Distance` is how far below the feet still counts as grounded. This is the value to reach for if jumps feel mushy (too large) or the character flickers airborne on bumps (too small). `Ground Snap Distance` pulls the character back onto the surface when walking over crests and down stairs, which is what stops the "launch off every step" problem. `Ground Stick Force` holds contact on slopes and platforms; it is never applied while rising, so it cannot eat a jump. `Ground Layer Mask` must include your ground. `Stairs Layer Mask` is optional — colliders on it use the more forgiving `Max Stairs Angle`, which keeps stair noses walkable. ### Slopes and steps `Max Slope Angle` is the steepest surface the character can stand on; anything steeper becomes a slide. `Step Height` is the tallest step it can climb without jumping. `Align To Slope Normal` tilts the character to match the surface. It suits third-person characters leaning into a hill; leave it off for upright or first-person characters. The shipped prefab has it off. ### Abilities Dash, slide and vault have their own sections, each with its own input action, cooldown and tuning. Every optional ability has an **Allow** toggle: `Allow Sprint`, `Allow Jump`, `Allow Crouch`, `Allow Prone`, `Allow Dash`, `Allow Slide`, `Allow Vault`. Turning one off disables it for that character with no code and no component surgery — an NPC that only walks, or a game without prone, is a checkbox. Design-time toggles and runtime modifiers resolve through the same gate, so `IsCapabilityAllowed(MovementCapability.Dash)` gives one answer whether dashing was switched off on the prefab or denied by a status effect this frame. ### Advanced These exist so you never have to edit the controller to change a behaviour, but most projects will not touch them: - `Jump Grace Duration` — the protected window after launch where ground stick, snapping and coyote refresh stay off. Raise it only if jumps are being swallowed. - `Use Supplementary Ground Rays`, `Supplementary Ray Spread`, `Ground Probe Lift Offset`, `Ground Probe Epsilon` — ground probe shape. Turning the extra rays off saves six raycasts per physics step on simple geometry. - `Ceiling Probe Radius Scale`, `Stance Clearance Radius Scale` — widths of the head and stand-up checks. Lower them slightly if the character refuses to stand in tight spaces it should fit. - `Airborne Launch Velocity Threshold`, `Fall Detection Velocity Threshold` — how much vertical speed counts as launched or falling. - `Configure Rigidbody On Start`, `Rigidbody Interpolation`, `Rigidbody Collision Detection` — turn the first off to keep whatever you configured on the Rigidbody yourself. - `Max Slope Slide Speed` — speed cap while sliding down slopes too steep to stand on. - `Air Dash Downward Boost` — downward slam when dashing out of a jump. 0 keeps the dash level. - `Vault Ground Offset` — how far above the landing surface a vault finishes. ### Presets `Character Motor Settings` is a ScriptableObject holding a complete movement feel. Assign one and its values overwrite the controller's movement fields on validate and on start, so one asset can re-feel every character using it. Four starter presets ship in `Core/Data/`: Tactical FPS, Arcade FPS, Third-Person RPG, and Parkour Lite. Leave the field empty to tune a character directly in the inspector. **A preset owns how movement feels, not what the character can do.** It covers speeds, acceleration, the jump arc, gravity, slopes, stairs and the ground probe tuning. It deliberately does *not* cover the ability toggles or Sprint Activation, because a preset overwrites the controller every time it validates — anything stored in one could never be overridden per character. So "does this character have a dash?" stays a per-character decision, and swapping presets to try a different feel never silently adds or removes a verb from your game. The four shipped presets differ most obviously in their jump arc: | Preset | Jump | Fall gravity | Character | | --- | --- | --- | --- | | Tactical FPS | fixed height | 1.35 | deliberate, weighty landings | | Arcade FPS | tap-to-hop, cut to 45% | 1.6 | responsive and forgiving | | Parkour Lite | tap-to-hop, cut to 35% | 1.45 | momentum, precise platforming | | Third-Person RPG | fixed height | 1.2 | weighty, reads well against authored animation | Fixed height is not a limitation — it is the right choice when jumps are animation-driven or when the game wants every jump to commit. --- ## Architecture ``` PlayerController (partial class, one file per responsibility) ├─ .cs lifecycle, serialized configuration, update loop ├─ .Movement.cs velocity solve, slope-following, speed targets ├─ .Grounding.cs ground probe, snapping, stepping, platforms ├─ .Stance.cs stand / crouch / prone and capsule resizing ├─ .Actions.cs jump, coyote time, input buffers, jump cut ├─ .Observability.cs locomotion state, events, read-only state ├─ .Extensions.cs movement modifiers and capability gates ├─ .Input.cs input source resolution, sprint activation ├─ .Vaulting.cs vault target detection ├─ .Camera.cs camera reference used to orient input ├─ .Modules.cs SkillModule registration and ticking ├─ .API.cs snapshots, gates, external forces └─ .Debug.cs overlay and gizmos CharacterGroundProbe capsule sweep + supplementary rays, foot-relative distances CharacterMotorSettings movement feel preset InputHandler Input System binding, implements ICharacterInputSource CharacterAnimatorBridge publishes state to an Animator MovingPlatform marks a platform the character should ride ``` Locomotion runs as a small state machine. Ground states (`IdleState`, `MovingState`, `CrouchingState`, `ProneState`, `PlayerSlideState`) implement `IGroundLocomotionState`; airborne and transient states (`JumpingState`, `FallingState`, `DashingState`, `SlidingState`, `VaultingState`) do not. All of them derive from `PlayerStateBase`. **You should not need to reference those classes.** They are implementation detail and may change. Read `MovementState` instead — see below. Each physics step runs in this order: movement modifiers are re-evaluated, the active state solves velocity, then the controller applies gravity, ground snapping, ground stick and platform motion. --- ## Reading character state `PlayerController` exposes the character's state directly: ```csharp LocomotionState state = controller.MovementState; // Idle, Walking, Running, Sprinting, // Crouching, Prone, Jumping, Falling, // Sliding, Dashing, Vaulting, Custom bool grounded = controller.IsGrounded(); bool airborne = controller.IsAirborne; Vector3 velocity = controller.CurrentVelocity; Vector3 planar = controller.PlanarVelocity; float vertical = controller.VerticalVelocity; Vector3 normal = controller.GroundNormal; float slope = controller.GroundAngle; bool walkable = controller.IsOnWalkableGround; PlayerStance stance = controller.CurrentStance; ``` `LocomotionState` is the stable contract. `GetStateSnapshot()` returns the same information as one immutable struct when you want to capture or transmit it. --- ## Events Subscribe instead of polling, and instead of modifying Basic: ```csharp controller.MovementStateChanged += (previous, next) => { }; controller.Grounded += () => { }; // regained ground contact controller.LeftGround += () => { }; // jumped or walked off an edge controller.StartedMoving += () => { }; controller.StoppedMoving += () => { }; controller.SprintStarted += () => { }; controller.SprintEnded += () => { }; controller.CrouchStarted += () => { }; controller.CrouchEnded += () => { }; controller.JumpStarted += () => { }; controller.Landed += () => { }; controller.StanceChanged += (previous, next) => { }; controller.SlideStarted += () => { }; controller.SlideEnded += () => { }; controller.VaultStarted += () => { }; controller.VaultEnded += () => { }; ``` `Grounded` / `LeftGround` and `StartedMoving` / `StoppedMoving` fire once per transition, not once per frame. The movement threshold is configurable under **Advanced**. --- ## Extension points This is how other systems influence movement **without editing Basic**. Register an `ICharacterMovementModifier`. Each one can scale speed and deny capabilities; speed contributions multiply and denials combine, so the result never depends on registration order. ```csharp public sealed class StaminaGate : MonoBehaviour, ICharacterMovementModifier { [SerializeField] private PlayerController controller; [SerializeField] private Stamina stamina; private void OnEnable() => controller.AddMovementModifier(this); private void OnDisable() => controller.RemoveMovementModifier(this); public void ApplyMovementModifiers(ref CharacterMovementModifiers modifiers) { if (stamina.Current <= 0f) modifiers.Block(MovementCapability.Sprint); if (stamina.Current < stamina.Max * 0.2f) modifiers.MultiplySpeed(0.8f); } } ``` For a value some other code toggles, skip the interface and take a handle: ```csharp _heavyArmor = controller.CreateMovementModifier("heavy armor"); _heavyArmor.SpeedMultiplier = 0.75f; _heavyArmor.BlockedCapabilities = MovementCapability.Sprint; // later controller.RemoveMovementModifier(_heavyArmor); ``` Capabilities that can be denied: `Move`, `Sprint`, `Jump`, `Crouch`, `Prone`, `Slide`, `Dash`, `Vault`, `Look`. Query the combined result: ```csharp controller.CanMove; // nothing is blocking locomotion controller.CanSprint; controller.IsCapabilityAllowed(MovementCapability.Jump); controller.EffectiveSpeedMultiplier; // SpeedMultiplier × all modifiers controller.BlockedCapabilities; // flags, for debug UI ``` Modifiers whose owning component is destroyed stop contributing automatically, so a character can never be left permanently rooted by a deleted status effect. `SkillModule` remains available for features that need their own update tick alongside the state machine — `DoubleJumpModule` is a worked example. --- ## Replacing the input source Basic never reads key bindings. It reads `ICharacterInputSource`: ```csharp public interface ICharacterInputSource { Vector2 MoveDirection { get; } bool IsMoving { get; } bool IsSprinting { get; } bool IsWalking { get; } bool IsCrouching { get; } bool IsProne { get; } bool IsJumpHeld { get; } event Action JumpPerformed; event Action DashPerformed; event Action CrouchPerformed; event Action PronePerformed; } ``` `InputHandler` is the shipped implementation, bound to an Input System action map. Action names are configurable on the `InputHandler` under **Action Names**, so your map can call them whatever you like — there is no need to rename your actions to match, and no code to edit. Clear a name to disable that input entirely. A named action that is missing from the map logs one warning naming the action and the map, which you can silence with `Warn On Missing Actions`. To drive the character from AI, a replay, a network stream, or your own input stack, implement the interface and either assign the component to **Advanced > Input Source Behaviour** or call: ```csharp controller.SetInputSource(myInputSource); // null restores the default ``` --- ## External forces Use these for knockback, explosions, launch pads and ability pushes: ```csharp controller.AddImpulse(direction * 12f); // survives locomotion, decays over time controller.SetExternalVelocity(windVelocity); // replaces rather than adds controller.ClearExternalVelocity(); controller.Teleport(position, rotation); ``` `AddImpulse` is the one you almost always want. It is tracked separately from locomotion velocity, so the character keeps steering normally while being pushed instead of having the push erased on the next physics step. It bleeds off at `External Force Drag`. An upward impulse leaves the ground and enters the airborne state immediately. `AddForce(force, mode)` is a raw Rigidbody passthrough. Its horizontal component is overwritten by locomotion on the next step, so it only suits continuous physics applied every step, or purely vertical forces. --- ## Moving platforms Add a `MovingPlatform` component to any platform the character should ride. Translating and rotating platforms are both supported; the character inherits platform motion, keeps relative position under rotation, and carries sensible inherited velocity when jumping off. A platform driven by a Rigidbody works without the component, but `MovingPlatform` gives more stable results for transform-driven platforms because it tracks the delta per fixed step. --- ## Animation Basic works with no Animator at all. To drive one, add `CharacterAnimatorBridge` (already on the prefab) and assign a `CharacterAnimatorParameters` asset. The bridge writes `Speed`, `PlanarSpeed`, `Forward`, `Strafe`, `IsGrounded`, `IsFalling`, `IsJumping`, `IsSprinting`, `IsCrouching`, `IsProne`, `IsSliding`, `Stance` and `MovementState`, and fires triggers for jump, land, slide and vault. Every parameter name is configurable on the asset, and the bridge silently skips parameters your controller does not declare — so you can wire up only the ones you use without console noise. No locomotion state depends on an Animator state name. --- ## Debugging Under **Debug** on the controller: - an on-screen overlay with state, grounding, slope angle and velocity - scene gizmos for the ground probe, step-up probe, velocity, movement direction and surface normal The inspector also shows a **Live State** panel during play with the locomotion state, ground angle, speeds, active speed multiplier and which capabilities are currently blocked. Turn `Enable Debug Tools` off for release builds; the overlay and gizmo code then costs nothing. --- ## Extending MotionCore Basic Basic is the locomotion foundation. Genre systems live in separate packages that build on it through the public API described above — they do not fork or patch Basic. **MotionCore FPS** adds first-person gameplay: FPS camera and mouse look, weapon architecture, aiming and ADS, recoil, weapon sway, weapon switching, hitscan and projectile firing, reloading, interaction, damage and hit feedback, footsteps and surfaces, and an FPS parkour set. **MotionCore RPG** adds RPG gameplay: an orbit and lock-on camera, combat and targeting, stats and attributes, health/mana/stamina, equipment and inventory, abilities, and RPG interaction patterns. The boundary is consistent, and it is the same boundary your own code should use: | Concern | Owner | | --- | --- | | `CanMove`, `CanSprint`, `MovementCapability`, speed multipliers | Basic | | Stamina emptying, so sprint is denied | Your game, or RPG | | Generic impulse API | Basic | | Explosion knockback values and falloff | Your game, or FPS | | `MovementState`, grounding, events | Basic | | Attack animation locking movement | Your game, or RPG | If you find yourself wanting to edit Basic to add a gameplay rule, there is almost certainly an extension point for it — a modifier, an event, or the input source. --- ## Troubleshooting **Character falls through the floor.** Ground Layer Mask does not include the floor's layer, or the floor has no collider. **Jumps feel mushy or the character seems to float.** Ground Check Distance is too large for the capsule. **Character flickers between grounded and falling on bumpy ground.** Increase Ground Snap Distance, or Ground Check Distance slightly. **Character launches off stairs.** Ground Snap Distance is 0, or Step Height is smaller than the step. **Cannot stand up from crouch.** There is geometry overhead. This is intentional; the check uses the standing capsule height. **Character will not move.** No input source, the action map name does not match, or something has blocked `MovementCapability.Move` — check the Live State panel's "Blocked" row during play. The full manual, including the FPS add-on, is at `Assets/Character Controller/MANUAL.md`.