Skip to content

PlatformerMovement

namespace Griff.Scenes;
public sealed class PlatformerMovement : Component

A platformer’s player with no code: runs with A/D, the arrow keys, the D-pad or the stick, and jumps with the Jump action (Space or the gamepad’s A), forgivingly: a jump pressed just before landing still happens, and one pressed just after running off a ledge still counts. Letting go early makes a short hop. Turn on air jumps, wall jumps and a dash as the game needs them. It climbs Ladders and a tilemap’s ladder tiles, climbs and swings on Ropes, drops through one-way platforms on down and Jump, and plays its Animation’s Idle, Run, Jump, Fall, Climb, Dash and WallSlide clips if it has them. Needs a Body and a collider.

This is a component: its saved properties are on its component page.

public float Acceleration { get; set; }

How quickly it gets up to speed, in units per second per second. 0 is at once.

public float AirControl { get; set; }

How much of its Acceleration and Deceleration it keeps in the air: 1 all, 0 none.

public int AirJumps { get; set; }

Extra jumps in the air before landing again: 1 is a double jump.

public float ClimbSpeed { get; set; }

Climbing speed on ladders, in units per second.

public bool Controllable { get; set; }

Untick it (from a script, in a cutscene) to ignore the player’s input; it still falls and lands. Its Focus action ticks it and unticks it on everything else the player plays (a board, another character), and back.

public float CoyoteTime { get; set; }

Seconds after running off a ledge that a jump still counts.

public bool Dash { get; set; }

The Dash action (Left Shift, K or the gamepad’s B) bursts forward, once in the air until landing again.

public float DashCooldown { get; set; }

Seconds after a dash before the next.

public string? DashSound { get; set; }

A sound played with each dash.

public float DashSpeed { get; set; }

Dash speed, in units per second.

public float DashTime { get; set; }

Seconds a dash lasts.

public float Deceleration { get; set; }

How quickly it stops once let go, in units per second per second. 0 stops dead.

public bool DropThrough { get; set; }

Down and Jump on a one-way platform drops through it.

public string? DustEffect { get; set; }

A prefab spawned at its feet on jumping and landing, e.g. a puff of “Dust”.

public int Facing { get; set; }

Which way it faces: 1 right, -1 left.

public float FallMultiplier { get; set; }

Gravity is this many times stronger while falling, for a snappier jump. 1 falls like it rises.

public bool FlipSprite { get; set; }

Flip its sprite to face the way it’s going (art should face right).

public bool IsClimbing { get; }

True while it’s on a ladder or a rope.

public bool IsDashing { get; }

True while it’s dashing.

public bool IsOnRope { get; }

True while it hangs on a Rope, climbing it or swinging on it.

public bool IsWallSliding { get; }

True while it’s sliding down a wall.

public float JumpBuffer { get; set; }

Seconds before landing that a jump press is remembered.

public float JumpHeight { get; set; }

How high a full jump goes, in world units.

public string? JumpSound { get; set; }

A sound played on every jump, e.g. “Sounds/jump.wav”.

public int JumpsLeft { get; }

Air jumps it has left before landing.

public string? LandSound { get; set; }

A sound played on landing from a fall.

public float MaxFallSpeed { get; set; }

The fastest it falls, in units per second. 0 has no limit.

public bool ShortHop { get; set; }

Letting go of Jump on the way up cuts the jump short, for small hops.

public float Speed { get; set; }

Running speed, in world units per second.

public bool WallJump { get; set; }

Jump while against a wall in the air to kick off it, away from the wall.

public bool WallSlide { get; set; }

Pushing into a wall while falling slides down it slowly, at WallSlideSpeed.

public float WallSlideSpeed { get; set; }

How fast it slides down a wall, in units per second.

public float JumpSpeedFor(float gravity)

The speed a jump of JumpHeight leaves the ground at, under gravity gravity (units per second squared, as a positive number).

public void Launch()

Sent flying by something other than a jump (a Bouncer, an explosion): air jumps and the air dash come back, a dash stops, and letting go of Jump won’t cut the flight short.

public event Action<PlatformerMovement>? Dashed

Raised at the start of each dash.

public event Action<PlatformerMovement>? Jumped

Raised on every jump: from the ground, a wall, a ladder or the air.

public event Action<float>? Landed

Raised on landing from a fall, with how fast it was falling.