Go to the release page on Github and download the latest .unitypackage file.
Importing Momentum
Open or make a new Unity project - it is recommended to use a new project, however, it should work fine on an existing one
Pick the latest stable version (LTS)
Use the 2D or 2D (URP)template
Name your project and set the project location
Import Momentum
Go to Assets → Import Package → Custom Package → then select the .unitypackage from the File Browser
Click on Import
If you were not asked to install the Input System and it is not already installed
Go to Window → Package Manager → Select ‘Packages: Unity Registry’ in the top bar of the window → Search ‘Input System → Click on Install
The files will be located in Assets/Momentum
Configure Momentum
Express Setup
Go to Assets/Momentum/Demo in the Project window
Double click on Demo.unity to open the scene
Set object layers
In the Hierarchy expand the Ground Parent and click on the Ground object
In the Inspector go to Layer → Add Layer
Add the Ground and Player layers on User Layers 3 and 6 respectively. This will automatically set Ground and Player objects to the correct layer. (This might already be set)
To check click on a Ground object and ensure the layer is set to Ground, if not manually set it to the Ground layer. Do the same for Player object
Check Player Data variables are correct
In the Project window go to Assets/Momentum/ScriptableObjects, right the PlayerData.asset file and select Properties
Check that these variables are correctly set, if not follow the instructions below
Grounded Layer Mask is set to Ground
Wall Layer Mask is set to Ground
Cant Exist In is set to Ground
Dash Curve is not empty
How to set Layer Masks in Player Data
Set the Layer Masks from Nothing to their respective layers. Hover over the name of the variable to receive additional information about what it does
Select Ground Layer Mask and set it to the Ground layer
The player is only considered ground when on an object within these layers
Select Wall Layer Mask and set it to the Ground layer
Only objects within these layers permit the player to perform wall (and ledge) actions
Select Cant Exist In and set it to the Ground layer
Set this to the layers that are supposed to be solid, the player should not be able to be within their bounds
Tip
If you have a separate Wall and ground Layer, consider setting this layer mask to both Wall and Ground if you want to be able to walk on top of Wall objects
How to set Dash Curve in Player Data
Copy the JSON string below and right click the Dash Curve variable then click paste
The demo scene ledge climb is instant since there is no animation for it, consider adding one.
Manual Setup
You only need assets located in Assets/Momentum/Scripts, the others are only required for the express setup.
Create assets
Right click in the Project window then go to Create → Player Data, this will create a Player Data asset file
Right click → Create → 2D → Physics Material 2D
Create the Player object
In the Hierarchy window right click → Create Empty to create an empty game object. Name it Player (or a name you prefer)
Click on the Player object to select it
Add the following components using the Add Component button in the Inspector window
Sprite Renderer
Animator
RigidBody2D
BoxCollider2D
Player
PlayerChecks
PlayerReferences
Go to the PlayerReferences component on the Player object and drag the Player Data asset created in step 1.1 into the field P Data
Go to our BoxCollider2D component and drag the Physics Material 2D we created in step 1.2
Set the Sprite variable on the Sprite Renderer component (The first frame of your Idle animation is fine, or you can use the Default Sprite provided by Momentum)
Create Animation Controller
In the Project window right click → Create → Animation Controller
Add states to the Animation Controller with your own animations (See Assets/Momentum/Animation Controller/CustomAnimator for examples)
Copy the animation names over to the fields in Player component on the Player object if they are different. These fields must match the name of the state that is in the Animation Controller or else they will not be played.
Go to the Animator component on the Player object and drag your Animator Controller into the Controller field
Go to the Ledge Climb animation in your Animation Controller that you created and add an animation event on the last frame using the Animation window (See Assets/Momentum/Animation Controller/Animation/Static Ledge Climb.anim for how the Animation Event looks like)
Select the Player → Go to your Animation window → Click on the dropdown to select the different animations → Select the Ledge Climb animation → Click on the animation event → In the Inspector, go to the Function property and set it to Player → Methods → LedgeClimbAnimationFinished()
Make the Manager object
In the Hierarchy create an empty object. Name it Manager (or a name you prefer)
Add the InputManager.cs component to it
Make the Ground object
Right click in the Hierarchy window → 2D Object → Sprites → Square
Add the BoxCollider2D component
Make Player and Ground layer (and Wall layer if desired)
Click on the Player object, in the Inspector window click on Layer and select Add Layer
Add Ground and Player layers
Go to your Ground and Player objects and set their Layer to their respective layers
Select your Player Data asset and in the Inspector window set the following variables
Grounded Layer Mask - Objects to be considered as ground, the Player can only jump from these objects
Wall Layer Mask - What is considered a wall? The Player can only perform wall (and ledge) actions on these objects. Most will have this set to whatever Ground is.
Cant Exist In - What should the player collide with, ensures the player is not teleported within these objects. This doesn’t handle collisions, but when teleporting the player (like during Ledge Climb) it makes sure nothing within this Layer Mask is in the way.
Finally, set the Dash Curve
Paste the JSON string below into the Dash Curve variable within the Player Data asset.
Copy the code, then right click the variable, and click paste
Go to your Animation window (Window → Animation → Animation)
Select your Player game object
Select the animation you want to set the box collider for, click play, and then pause to stop the animation on a frame
There are 4 types of box collider groups contained in the Box Collider section of Player Data
Stand Box Collider - Used by default, unless the state explicitly changes the box collider
Example states (non-exhaustive), Idle, Move, Sprint, Jump, Wall Jump, Dash
Crouch Box Collider
Used for Crouch Move and Crouch Idle
Ledge Box Collider
Used for Ledge Hang and Climb
Wall Box Collider
Used for sub-states of WallState → Wall Grab, Climb, Slide
Go to your BoxCollider2D component on the Player and click Edit Bounds
Now return to the Scene window and edit the bounds however you like
Copy the Offset and Size fields on the BoxCollider2D component into the corresponding fields in Player Data, for example
Offset → Crouch Box Collider Offset
Size → Crouch Box Collider Size
Setting Ledge Offsets
When setting the Ledge Offsets make sure the player’s BoxCollider2D does not collide with the ground. You can see the player’s collider by clicking the edit bounds button the BoxCollider2D component.
In the Hierarchy make a Ground object and position it away from other ground objects so that we are able to ledge climb on it
Add the LedgeClimbAndHangOffsetFinder component
Drag the Player object into the Player field
Make sure Show Offset Value is selected
If you’re going to position the player on the left side of the ledge, select Top Left for the Corner field otherwise select Top Right
Enter Play mode
Select the Player and in the Inspector window set the Body Type on the RigidBody2D component to Static
To flip the Player sprite so they are facing the ledge, either use the A and D or check and uncheck the Flip X field on the Sprite Renderer component
Return to the Scene view
Select the Player, go to the Animation window, and select Ledge Hang or Climb animation. Hit play then pause so a frame of the animation shows on the player
Now select the move tool and position the Player near the ledge so it looks like they are grabbing it
In the Console window, a Vector2 will be printed continuously, this is your Ledge Climb/Hang offset (depending on whether you chose to do the Hang or the Climb animation)
Copy this into the Ledge Hang Offset or the Ledge Climb Offset, depending on which animation you chose
In most cases your Ledge Hang Offset will be the same as your Ledge Climb Offset. However, if your Ledge Climb animation’s 1st frame does not look similar to the Ledge Hang animation, then perform the same steps but for the Ledge Climb Animation