Explains the purpose of each variable in PlayerData.cs

Enable Actions

Move - Disables the transitions to Move State

Sprint - Disables the transitions to Sprint State

Crouch - the transitions to both Crouch Idle and Crouch Move

Jump - Disables the transitions to Jump State

Dash - Disables the transitions to Dash State

LedgeHang - Disables the transitions to Ledge Hang State

LedgeClimb - Disables the transitions to Ledge Climb State

WallGrab - Disables the transitions to Wall Grab State

WallClimb - Disables the transitions to Wall Climb State

WallSlide - Disables the transitions to Wall Slide State

WallJump - Disables the transitions to Wall Jump State

Debug

State Change Debug - Logs information to console about state changes for debugging. Includes, the class that initiated the state change, the state it’s transitioning to, and the time when this change was initiated.

FROM --> PlayerGroundedState TO --> Momentum.States.PlayerJumpState   ||   [Time] 7.757771

Tip

Each Gizmo is updated in realtime, run your game in the editor and change some variables in the PlayerData Scriptable Object.

Grounded Check Gizmo - Enables visualization of Grounded Boxcast. Cast below the player and used to check whether the player is grounded.

Uncrouch Check Gizmo - Enables visualization of Uncrouch Boxcast. Casts a box the size of Stand Box Collider Size at the player position when crouched to determine if the player can uncrouch.

Ledge Check Gizmo - Enables visualization of Ledge Check RayCast. If Ledge Check 2 hits a wall but Ledge Check 1 does not, then the player is able to perform ledge actions. For this reason Ledge Check 2 must be lower than Ledge Check 1.

Ledge Hang Check - Enables visualization of Ledge Hang Check Boxcast. It is cast where the player will be teleported to when entering Ledge Hang State and used to insure there is nothing in the way.

Ledge Climb Check - Enables visualization of Ledge Climb Check Boxcast. It is cast where the player will be teleported to when exiting Ledge Climb State and used to insure nothing is in the way.

Wall Check Gizmo - Enables visualization of Wall Check RayCasts. Three rays are cast from the player in the direction it’s facing. Three more rays in the exact opposite direction will also be cast if WallCheckBothSidesForWallJump is set to true. Used to determine is wall actions are available.

Wall Grab Check Gizmo - Enables visualization of Grab Check Boxcast. Cast between the player and the wall before entering a wall state to insure nothing is between the player and the wall.

LayerMask

Tip

You can assign the same layer to Ground Layer Mask and Wall Layer Mask to make the player be able to perform wall and ground actions on the same object

Ground Layer Mask - Any object that is assigned this layer will be considered ground, meaning they are able to walk, jump and do other ground actions on it.

Wall Layer Mask - Any object assigned this layer is considered a wall. The player is able to perform wall and ledge actions only on objects within this layer.

Cant Exist In - When teleporting the player (after ledge climb) or when changing box collider sizes (when uncrouching) a box is cast to insure there aren’t any objects in the way. This Boxcast only detects objects within these layers. For example, bushes or greenery might be excluded form this since the player might not be able to collide with it.

Box Collider

Stand Box Collider - Default box collider size. Used in all grounded substates excluding Crouch Idle and Crouch Move. Additionally used in Dash, Jump, Wall Jump, Fall, and Fly.

  • Stand Box Collider Size - Defines the size of the box collider
  • Stand Box Collider Offset - Defines the offset the box collider

Crouch Box Collider - Used in Crouch Idle and Crouch Move

  • Crouch Box Collider Size - Defines the size of the box collider
  • Crouch Box Collider Offset - Defines the offset the box collider

Ledge Box Collider - Used in Ledge Hang and Ledge Climb

  • Ledge Box Collider Size - Defines the size of the box collider
  • Ledge Box Collider Offset - Defines the offset the box collider

Wall Box Collider - Used in wall substates, Wall Grab, Wall Climb, Wall Slide

  • Wall Box Collider Size - Defines the size of the box collider
  • Wall Box Collider Offset - Defines the offset the box collider

Movement

Grounded Box Check Length - Sets the y length of the Grounded Check BoxCast. As this value increases, the box is extruded downward.

Grounded Box Check Shrink X - Shrinks the Grounded Check BoxCast horizontal length by this value. When 0, the Grounded Check BoxCast x length is equal to the Stand BoxCollider x length.

Bug

When set to 0, if the player is touching a wall in midair, the player will still be considered grounded. Set this to a very small number to prevent this (0.01f).

Move Speed - The speed at which the player moves while in MoveState. Additionally used in Fly and Fall State.

Sprint Speed - The speed at which the player moves while in Sprint State

Crouch Move Speed - The speed at which the player moves while in Crouch Move State

Acceleration - Multiplied to the movement speed, changing this value makes all three move speeds above go faster or slower.

Velocity Power - When 1, it has no effect, and the closer it gets to 0 the longer it takes the player to achieve full velocity.

Ground Friction Amount - When at 0 does not add any friction, and higher values lets the player stop faster after moving.

Jump

Variable Jump Height - When true the player can ‘cancel’ jump by letting go of space early.

Amount of Jumps - Is equal to the amount of times you can jump before you have to land.

Example

When set to 1, the player must be grounded to jump. When set to anything more than 1, the player can initiate a jump from midair but has to land to reset the amount of jumps left.

Jump Height - Inversely related to Jump Distance. The higher this value is the higher the jump.

Jump Distance - Inversely related to Jump Height. The higher this value is the lower the jump.

Jump Y Thresh - When the y velocity of the player is below this value and the Player is in Jump State, they are able to exit Jump State

Jump Buffer - After we hit jump, a timer is set to this value and counts down. When the timer is above 0, jump is ‘still pressed’.

Why is this necessary?

When the player presses jump a frame before they are grounded the player will not jump without a Jump Buffer. This makes the movement feel unresponsive. Instead we recognize that the Player wanted to jump and we aid them.

Coyote Time - After leaving the ground, we have this amount of seconds to still jump.

Why is this necessary?

When the player presses jump a frame after they fall off the ledge, the player will not jump without Coyote Time. With CoyoteTime we recognize that the Player intended to jump and we aid them.

Jump Cooldown - The amount of time after jumping the player has to wait before being able to jump again.

Bug

When Coyote Time is enabled, the player is able to spam jump and do a triple jump and sometimes jump higher than normal. Setting this equal to CoyoteTime prevents this.

Min Jump Time - The minimum amount of time to spend in Jump State before we can transition out. Helpful for establishing a minimum jump height with Variable Jump Height enabled.

Jump Cut Velocity - With Variable Jump Height enabled and when we release jump, the player’s y velocity is set to this value.

Crouch

Fix Cant Uncrouch When Touching Wall - When this is disabled and we uncrouch, the uncrouch check BoxCast’s x length is set to the stand box collider’s x length, however, if the stand box collider’s x value is greater than the crouch box collider x value, the player will not be able to uncrouch when touching a wall. With this enabled, the uncrouch check’s x value is set to the crouch box collider’s x value.

Info

If the above explanation was too complicated leave this setting enabled, for most use cases it will be fine.

Uncrouch Check Shrink - Shrinks the x and y length of the uncrouch check BoxCast by this variable’s value, allowing room for a tiny amount of error.

Ledge

Auto Ledge Climb - When entering Ledge Hang State, we immediately transition to Ledge Climb State without waiting for Player input.

Ledge Check Length - Changes the length of both Ledge Check RayCasts that extends outward from the player in the direction they are facing.

Ledge Check 1 Offset Y - Is added to the y position of Ledge Check 1. When set to 0, the RayCast’s y position is the top of the box collider facing the player’s direction.

Ledge Check 2 Offset Y - Is added to the y position of Ledge Check 2. When set to 0, the RayCast’s y position is the top of the box collider facing the player’s direction.

Warning

This value must be smaller than LedgeCheck1OffsetY or Ledge Hang/Climb will not work

Ledge Climb Check Shrink - This Vector2 is subtracted from the size of the Ledge Climb Check Boxcast. Allows for a small amount of error.

Ledge Hang Check Shrink - This Vector2 is subtracted from the size of the Ledge Hang Check Boxcast. Allows for a small amount of error.

Ledge Climb Offset - Added (when facing left) or Subtracted (when facing right) from the Ledge Corner Position which is the position of the nearest top corner on the object you are climbing on.

Ledge Hang Offset - Added (when facing left) or Subtracted (when facing right) from the Ledge Corner Position which is the position of the nearest top corner on the object you are climbing on.

Air

Can Move In Air - Allows the player to move left or right while in the air to give more control to the player.

Fall Gravity Multiplier - When in Fall State, multiply the gravity by this value to make the player feel more weighted and reduce the ‘floaty’ feel.

Max Fall Force - Clamp the y velocity when falling to this number. When combined with Can Move In Air allows the player to dodge platforms while falling as a game mechanic.

Slope

Add Force Parallel To Slope - Normally, when this is disabled, the velocity is applied along the x-axis which means on slopes the player will move slower going upwards, and faster moving downwards. However, with this enabled, while on a slope (objects that are rotated to anything but 90-degree increments) the velocity is added parallel to the rotation of the slope.

Hint

If you would like to see this in action, create a Debug.DrawRay with the RigidBody2D velocity to see the direction the velocity is being applied.

Prevent Bouncing On Slope - When enabled and we are in a Grounded substate but not fully in contact with the ground apply a velocity downward equal to Anti Bounce Force. This prevents the player from leaving the ground due to the Physics being enabled.

Anti Bounce Force - Changes the intensity of the force applied when Prevent Bouncing On Slope is enabled.

Prevent Sliding On Slopes When Idle - When enabled change the Physics Material 2D’s friction value on the Player’s BoxCollider2D to Slope Friction’s value while Idle on a slope (Any ground object not rotated in 90-degree increments is considered a slope).

Note

In order to change the player’s friction during runtime, the BoxCollider is disabled and enabled in the same frame after changing the friction.

Normal Friction - The default friction to set while not Idle on a slope.

Slope Friction - The friction amount to set while Idle on a slope.

Dash

DashTowardMouse - When enabled, makes the Player dash toward the mouse, when disabled dash in the direction of WASD input. If there is no WASD input, the player does a horizontal dash in the direction they are facing.

Amount of Dashes - Amount of total dashes available, one will be consumed each time the player dashes.

Dash Curve - While in Dash State, it evaluates this curve up to the x value of Dash Length while the y value is a percent of Dash Strength. Read more about AnimationCurves here.

Note

To make full use of this curve, your last key should ideally be at x = Dash Length and y = 1

Dash Strength - The strength of your Dash.

Dash Length - How long we should keep Dashing (continuously adding Dash Strength velocity).

Tip

A short Dash Length and a high Dash Strength value will make your dash feel snappy

Dash Hang Time - After Dash has ended, spend Dash Hang Time amount of seconds easing the Player’s y velocity to 0 to prevent an abrupt end to Dash.

Time Between Dashes - The amount of time after exiting Dash State before you can enter Dash again (provided you have more than 1 dash left).

Dash Regeneration Cooldown - The amount of time it takes for one Dash to regenerate.

Wall

Wall Grab Check Shrink - Shrinks the Wall Grab Check BoxCast by this Vector2 to allow for small error margin.

Wall Check Distance - The length of the Wall Check RayCasts, extends out from the player in the direction the Player is facing

Wall Check 1 Height - Calculated as a percent with 100% being the top of the Player’s box collider and 0% being the y position of the bottom of the box collider.

Wall Check 2 Height - Calculated as a percent with 100% being the top of the Player’s box collider and 0% being the y position of the bottom of the box collider.

Wall Check 3 Height - Calculated as a percent with 100% being the top of the Player’s box collider and 0% being the y position of the bottom of the box collider.

Should Have Grab Stamina - If enabled we can only stay in Wall Sub States for Grab Stamina amount of time before we can only Wall Slide. Resets once player is grounded.

Grab Stamina - Amount of time we can stay in Wall Sub States like Wall Climb and Wall Grab before we are transitioned to Wall Slide State. Active when Should Have Grab Stamina is enabled.

Wall Climb Speed - The speed at which the player climb.

Wall Slide Speed - The speed the player slides down walls.

Slide Speed Smooth Time - The amount of time we ease from the current y velocity to the Wall Slide Speed, this helps make the transition natural instead of immediately setting the velocity to Wall Slide Speed when we transition to Wall Slide State.

Wall Jump

Wall Check Both Sides For Wall Jump - When enabled mirrors the Wall Check RayCasts on the other side of the player so we can wall jump from a wall even when we aren’t facing it. If disabled, the player must face the wall they are trying to wall jump from.

Wall Jump Move Speed - Set the movement speed used to let the player have some control during wall jump, a higher number will result in the player being able to easily override the natural wall jump trajectory.

Return Movement Control Timer - The amount of time after entering wall jump it will take to let the player have full horizontal movement control of the player. We LERP from 0 to Wall Jump Move Speed, and it will take the amount of seconds this variable is set to before the player is allowed to move at the speed specified in Wall Jump Move Speed. Setting this to 0 means the player can instantly have full control.

When is this useful?

This is useful if you don’t want the player to have the ability to climb a wall just by repeatedly wall jumping on it.

Wall Jump Time - The amount of time wall jump force is applied.

Wall Jump Y Thresh - The y velocity the player must be below to transition out of Wall Jump State (only applies after Wall Jump Time is over).

Wall Jump Cooldown - The amount of time after exiting Wall Jump before we can wall jump again.

Linear Wall Jump Force - The amount of force to apply in the x and y axis when wall jump is initiated.