Skip to content
This repository was archived by the owner on Aug 14, 2019. It is now read-only.

PlayerMovementController.cs

Erik edited this page Apr 22, 2019 · 1 revision
Dependencies (What do I need to include to use this script in another projec?):
  • Rigidbody2D
  • "Horizontal" input axis configured
  • A "Ground" layer created and assigned to any objects that the player can jump from.
Public Methods:
  • None
Public Events:
  • None
Configurable Fields:
  • horizontalSpeed - The maximum horizontal speed (in units per second) that the player can reach via player input.
  • horizontalAxis - The Input Axis' name.
  • jumpForce - The continuous force added to the player to jump. Affected by the player Rigidbody2D's mass.
General Overview:

The controller gradually speeds the player up in whatever direction is pressed until maximum speed is reached. Jumping grants a one-tick upward force that stacks additively onto the player's velocity (if the player is falling, the jump will reduce downward velocity but may not actually push the player upward. If the player is already moving upward, the jump will increase vertical velocity).

Clone this wiki locally