# Motion 2D

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

```
component gameplay.Motion2D
```

Moves a kinematic Body2D by casting its colliders: walking, jumping, slopes, steps and moving platforms, or free top-down movement. Call Move and Jump from a script; the controller acts on the next fixed step.

## Fields

| Name | Script name | Type | Default | Description |
|---|---|---|---|---|
| Mode | `Mode` | `enum` | `platformer` | platformer walks on floors under gravity; topDown moves freely in the plane. |
| Up Direction | `UpDirection` | `Vec2` | `(0, -1)` | Up for floors, jumps and gravity. (0, -1) is up on screen. |
| Max Speed | `MaxSpeed` | `float` | `6` | Top speed in units per second. |
| Accel | `Accel` | `float` | `60` | How fast the speed grows towards the target, units per second squared. |
| Decel | `Decel` | `float` | `50` | How fast the speed falls without input, in units per second squared. |
| Air Control | `AirControl` | `float` | `0.6` | Share of Accel and Decel available in the air: 0 cannot steer, 1 steers as on the ground. |
| Gravity Scale | `GravityScale` | `float` | `1` | Multiplies the physics gravity; 0 turns gravity off for the character. |
| Max Fall Speed | `MaxFallSpeed` | `float` | `20` | Fastest fall in units per second. 0 is unlimited. |
| Jump Height | `JumpHeight` | `float` | `2.2` | Height of a full jump in units; sets the jump speed unless Jump Speed is set. |
| Jump Speed | `JumpSpeed` | `float` | `0` | Upward speed of a jump. 0 derives it from Jump Height and gravity. |
| Jump Cut Multiplier | `JumpCutMultiplier` | `float` | `0.5` | Upward speed is multiplied by this when the jump button is released early. |
| Coyote Time | `CoyoteTime` | `float` | `0.1` | Seconds after leaving a ledge during which a jump still works. |
| Jump Buffer | `JumpBuffer` | `float` | `0.1` | Seconds a jump pressed in the air is remembered until landing. |
| Max Slope | `MaxSlope` | `float` | `45` | Steepest floor in degrees; steeper surfaces are walls. |
| Step Height | `StepHeight` | `float` | `0.2` | Steps up to this height, in units, are climbed without jumping. 0 never steps up. |
| Snap To Ground | `SnapToGround` | `float` | `0.2` | Keeps the character on slopes and steps down by up to this distance, in units. 0 never snaps. |
| Safe Margin | `SafeMargin` | `float` | `0.02` | Gap in units kept to surfaces so casts never start inside them. |
| Max Slides | `MaxSlides` | `int` | `4` | How many surfaces one step may slide along. |
| Collision Mask | `CollisionMask` | `layer mask` | `-1` | Layers the character collides with. |
| Push Bodies | `PushBodies` | `bool` | `true` | Moves through dynamic bodies and pushes them instead of stopping at them. |
| Moving Platforms | `MovingPlatforms` | `bool` | `true` | Carries the character with the body it stands on. |
| Platform On Leave | `PlatformOnLeave` | `enum` | `keep` | keep keeps the platform's velocity after leaving it, drop loses it, add keeps only its horizontal part. |
| Face Movement | `FaceMovement` | `bool` | `false` | topDown: turns the node towards the movement. |
| Dash Gravity | `DashGravity` | `bool` | `false` | Applies gravity during a dash. |
| Ledge Climb | `LedgeClimb` | `float` | `0` | platformer: in the air, moving into a wall whose top is at most this far above the feet climbs onto it. 0 never climbs. |
| Climb Time | `ClimbTime` | `float` | `0.3` | Seconds a ledge climb takes: rising, then stepping onto the ledge. |
| Velocity | `Velocity` | `Vec2` | `(0, 0)` | Runtime state. Velocity in units per second. |
| Grounded | `Grounded` | `bool` | `false` | Runtime state. Whether the character stands on a floor. |
| On Wall | `OnWall` | `bool` | `false` | Runtime state. Whether the character touched a wall in the last step. |
| On Ceiling | `OnCeiling` | `bool` | `false` | Runtime state. Whether the character touched a ceiling in the last step. |
| Wall Normal | `WallNormal` | `Vec2` | `(0, 0)` | Runtime state. Normal of the last wall touched. |
| Floor Normal | `FloorNormal` | `Vec2` | `(0, 0)` | Runtime state. Normal of the floor under the character. |
| Floor Angle | `FloorAngle` | `float` | `0` | Runtime state. Slope of the floor in degrees. |
| Ground Body | `GroundBody` | `NodeRef` | `none` | Runtime state. Body the character stands on. |
| Climbing | `Climbing` | `bool` | `false` | Runtime state. Whether the character is climbing onto a ledge. |

## AddDisplacement

```
func (Motion2D) AddDisplacement(offset Vec2)
```

Moves by an offset in world units on the next step, through walls and slopes like a move, without changing the velocity; root motion of an Animator uses it.

## AddVelocity

```
func (Motion2D) AddVelocity(velocity Vec2)
```

Adds a push once, for knockback.

## Dash

```
func (Motion2D) Dash(velocity Vec2, seconds float)
```

Moves at a fixed velocity for some seconds.

## Jump

```
func (Motion2D) Jump()
```

Jumps on the next step if grounded, within coyote time or later within the jump buffer.

## JumpReleased

```
func (Motion2D) JumpReleased()
```

Cuts a rising jump by Jump Cut Multiplier.

## Move

```
func (Motion2D) Move(x float)
```

Sets the horizontal input, -1..1; it stays until the next Move.

## MoveDir

```
func (Motion2D) MoveDir(dir Vec2)
```

Sets the top-down input; a longer vector is cut to length 1.

## Stop

```
func (Motion2D) Stop()
```

Zeroes the velocity and ends a dash.

## Teleport

```
func (Motion2D) Teleport(position Vec2)
```

Moves to a position on the next step and resets velocity and state.

## Climbed

```
signal Climbed()
```

Fires when the character starts climbing onto a ledge.

## HitCeiling

```
signal HitCeiling()
```

Fires when the character bumps into a ceiling.

## HitWall

```
signal HitWall(normal Vec2)
```

Fires when the character starts touching a wall.

## Jumped

```
signal Jumped()
```

Fires when a jump starts.

## Landed

```
signal Landed(speed float)
```

Fires when the character touches a floor, with the falling speed.

## LeftGround

```
signal LeftGround()
```

Fires when the character walks off a floor without jumping.
