TopDownMovement
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.
Requires: Body; Collider
Works with: Animation (plays Idle and Run clips)
Takes the player’s input only while it has focus (its Controllable): its Focus action hands it the input and takes it from everything else the same player plays.
In a network game, the player it moves for runs it on their own machine and sends where they are.
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
speed: a number = 6. World units per second. (Field: a number.)acceleration: a number = 60. How quickly it gets up to speed, in units per second per second. 0 is at once. (Field: a number.)deceleration: a number = 80. How quickly it stops once let go, in units per second per second. 0 stops dead. (Field: a number.)fourWay: true or false = false. 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. (Field: on or off.)isometric: true or false = false. 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. (Field: on or off.)
dash: true or false = false. The Dash action (Left Shift, K or the gamepad’s B) bursts the way it’s moving, or facing. (Field: on or off.)dashSpeed: a number = 18. Dash speed, in units per second. (Only used when dash is on.) (Field: a number.)dashTime: a number = 0.15. Seconds a dash lasts. (Only used when dash is on.) (Field: a number.)dashCooldown: a number = 0.35. Seconds after a dash before the next. (Only used when dash is on.) (Field: a number.)dashSound: text = null. A sound played with each dash. (Only used when dash is on.) (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
Control
Section titled “Control”controllable: true or false = true. 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. (Field: on or off.)flipSprite: true or false = true. Flip its sprite to face left or right as it moves (art should face right). (Field: on or off.)
Actions
Section titled “Actions”What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).
Focus. Gives its entity the player’s input: whatever there and inside it has focus, and everything else the same player plays loses it (a platformer’s player stops on the arrow keys while a board takes them).
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
facing: [x, y]. The way it last moved, as a unit vector: down to start with.isDashing: true or false. True while it’s dashing.
Scripts use it as TopDownMovement: its methods, events and values that aren’t saved with the scene.