PlatformerMovement
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.
Requires: Body; Collider
Works with: Animation (plays Idle, Run, Jump and Fall 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 = 7. Running speed, in world units per second. (Field: a number.)acceleration: a number = 70. How quickly it gets up to speed, in units per second per second. 0 is at once. (Field: a number.)deceleration: a number = 90. How quickly it stops once let go, in units per second per second. 0 stops dead. (Field: a number.)airControl: a number = 0.8. How much of its Acceleration and Deceleration it keeps in the air: 1 all, 0 none. (Field: a number.)
jumpHeight: a number = 3.4. How high a full jump goes, in world units. (Field: a number.)airJumps: a whole number = 0. Extra jumps in the air before landing again: 1 is a double jump. (Field: a number.)coyoteTime: a number = 0.1. Seconds after running off a ledge that a jump still counts. (Field: a number.)jumpBuffer: a number = 0.12. Seconds before landing that a jump press is remembered. (Field: a number.)shortHop: true or false = true. Letting go of Jump on the way up cuts the jump short, for small hops. (Field: on or off.)fallMultiplier: a number = 1.5. Gravity is this many times stronger while falling, for a snappier jump. 1 falls like it rises. (Field: a number.)maxFallSpeed: a number = 20. The fastest it falls, in units per second. 0 has no limit. (Field: a number.)
wallSlide: true or false = false. Pushing into a wall while falling slides down it slowly, at WallSlideSpeed. (Field: on or off.)wallSlideSpeed: a number = 3. How fast it slides down a wall, in units per second. (Only used when wallSlide is on.) (Field: a number.)wallJump: true or false = false. Jump while against a wall in the air to kick off it, away from the wall. (Field: on or off.)
dash: true or false = false. The Dash action (Left Shift, K or the gamepad’s B) bursts forward, once in the air until landing again. (Field: on or off.)dashSpeed: a number = 20. 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.)
Ladders and Platforms
Section titled “Ladders and Platforms”climbSpeed: a number = 4. Climbing speed on ladders, in units per second. (Field: a number.)dropThrough: true or false = true. Down and Jump on a one-way platform drops through it. (Field: on or off.)
Control
Section titled “Control”controllable: true or false = true. 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. (Field: on or off.)flipSprite: true or false = true. Flip its sprite to face the way it’s going (art should face right). (Field: on or off.)
Sounds and Effects
Section titled “Sounds and Effects”jumpSound: text = null. A sound played on every jump, e.g. “Sounds/jump.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)landSound: text = null. A sound played on landing from a fall. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)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.)dustEffect: text = null. A prefab spawned at its feet on jumping and landing, e.g. a puff of “Dust”. (Names a prefab.) (Field: a name.)
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: a whole number. Which way it faces: 1 right, -1 left.isClimbing: true or false. True while it’s on a ladder or a rope.isOnRope: true or false. True while it hangs on a Rope, climbing it or swinging on it.isDashing: true or false. True while it’s dashing.isWallSliding: true or false. True while it’s sliding down a wall.jumpsLeft: a whole number. Air jumps it has left before landing.
Scripts use it as PlatformerMovement: its methods, events and values that aren’t saved with the scene.