Skip to content

TopDownMovement

namespace Griff.Scenes;
public sealed class TopDownMovement : Component

A top-down player with no code: moves in eight directions (or four) with WASD, the arrow keys, the D-pad or the stick, never faster diagonally, with an optional dash. It ignores gravity, so it works in a game that has some. Plays its Animation’s Idle and Run clips if it has them (and IdleUp, IdleDown, RunUp and RunDown, facing that way). Needs a Body and a collider. On an isometric Tilemap, turn on Isometric so it walks over the diamonds.

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 bool Controllable { get; set; }

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

public bool Dash { get; set; }

The Dash action (Left Shift, K or the gamepad’s B) bursts the way it’s moving, or facing.

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 Vector2 Facing { get; set; }

The way it last moved, as a unit vector: down to start with.

public bool FlipSprite { get; set; }

Flip its sprite to face left or right as it moves (art should face right).

public bool FourWay { get; set; }

Only up, down, left and right: for grid-like games. The way pressed last wins. With Isometric, the four ways are along the diamonds’ edges instead: up goes up to the right, right down to the right, down down to the left and left up to the left, and two ways held together go that way on the screen.

public bool IsDashing { get; }

True while it’s dashing.

public bool Isometric { get; set; }

Walks over an isometric map’s ground (a Tilemap whose Shape is Isometric): up and down go half as fast on the screen as left and right, as the ground is seen at a slant, so up and right together run along the diamonds’ edges. Speed is how fast it goes across the screen.

public float Speed { get; set; }

World units per second.

public override string? SetupNote()

On an isometric map with Isometric off, a reminder to turn it on.

public event Action<TopDownMovement>? Dashed

Raised at the start of each dash.