Horizontal Movement Formulas

From Minecraft Parkour Wiki
Other languages:

On every tick, the game does these three steps:

  1. Acceleration is added to the player's velocity.
  2. The player is moved (new position = position + velocity).
  3. The player's velocity is reduced to simulate drag.

We'll start by introducing Multipliers in an effort to make formulas more readable.


Multipliers

Movement Multiplier (See 45° Strafe)



Effects Multiplier (See Status Effects)



Slipperiness Multiplier (See Slipperiness)



Linear Formulas

These simplified formulas only apply to linear movement (no change in direction). While this condition might seem very restrictive, these formulas are very useful to analyze conventional jumps and momentum We'll later expand on these formulas by including angles.


Definition:
  • is the player's initial speed (default = 0).
  • is the player's speed on tick .


Ground Speed:


Jump Speed:


Air Speed:


Complete Formulas

Let's introduce two more variables:

  • , The player's Direction in degrees (defined by their inputs and rotation)
  • , The player's Facing in degrees (defined by their rotation only)


In reality, angles aren't as simple as that, as there are a limited number of significant angles (see Facing and Angles).

For the purpose of simplicity, we'll ignore this fact.


Definition:
  • and correspond to the player's initial velocity.
  • and correspond to the player's velocity on tick

Ground Velocity:
Jump Velocity:
Air Velocity:


Stopping Conditions

Horizontal speed is set to 0 if the player hits a wall, or if the speed is considered to be negligible.


Wall Collision:
If the player hits a X-facing wall, then momentum is cancelled, and only includes acceleration.
If the player hits a Z-facing wall, then momentum is cancelled, and only includes acceleration.
In either of these case, the player stops sprinting.


Negligible Speed Threshold:
If then momentum is cancelled, and only the acceleration is left.
If then momentum is cancelled, and only the acceleration is left.
In 1.9+, they are compared to 0.003 instead.


Source Code

[...]