Platformer Player Controller
A downloadable asset pack
This is a player controller I have been making for some. I have tested many movement and jumping methods for the player. After much testing, I found it the best player movement solution. I would like to here from you guys if you have any suggestions or found any issues. Many beginners make platformers as their first game. So hopefully they can learn something from this.
First you have to setup the inputs for the player. This asset includes a user input system. Using this input system , we can easily make custom inputs and give players the ability to change the inputs for moving our character in the game. To set-up the player inputs, make an empty GameObject and attach "UserInputSettings.cs". Here you can assign any key to a specific function.
Make an empty GameObject and Attach "PlayerMovementController.cs". RigidBody2D and BoxCollider2D components will be automatically added. Here you can tweak many variables to fit your player character's needs.
These are the variables in Player Movement Controller:
- Move Speed - this is basically how fast your character move.
- Jump Speed - this is how high your character can jump.
- Grounded Remember Time - It allows you to jump in air after leaving the ground. It is also called Coyote Time.
- Jump Delay - It increases the time in which a player can press the jump button in air and will jump straight after the player landed. The value of 0.2 will be fine for most games. You can do experimentation for getting the best result.
- Max Velocity - It will limit the velocity of the player. Player velocity cannot exceed this value.
- Linear Drag - This variable changes the linear drag value of RigidBody2D component when there is no move input. This recreates the effect of friction.
- Gravity - It is the default gravity value for player.
- Fall Multiplier - It increases the value of gravity when the player is falling. This gives jump a specific feel that can be seen in popular platformers.
- Ground Layer Mask - You can define the ground layer on which the player can jump.
The base of our player is done. This assets also include player animations controller. First make an empty GameObject Under the child of Player Component and make another Gameobject the child of that object we just made before. Like this:
Obviously you can name them anything you want. Now set the position of "CharacterHolder" to -1 along Y.
And set the position of "CharacterAnimatons" to 1 along Y. The reason why we are creating other gameObject for holding the character and character animations, is that we want to change the localTransform of Player Sprites without effecting RigidBody2D and BoxCollider2D of the Player. In PlayerAnimations, You can create animations for the player.
Now under the Player GameObject, we can setup jump squeeze animations.
Bring in the CharacterHolder GameObject and animator components of the PlayerAnimations in the fields and set the values for jump and land squeeze.
You have to make four bool parameter is your animator like this:
If you have any other questions, feel free to ask in the comments. Also criticism and suggestions for improvement of the assets will be highly appreciated. Enjoy!
Click download now to get access to the following files:
Leave a comment
Log in with itch.io to leave a comment.