GameDevHQ Crash Course #26 CharacterControllers
CharacterControllers in Unity are a good way of having your character move around a game world. It also collides with other colliders you can you use it effectively in a platformer based game.
So lets make one. First we set ourselves up some platforms and add some colliders to them, then add ourselves a charactercontroller to the player capsule.
Then inside our player script we need to make some way of controlling the character, first lets add some movement.
this will allows us to move left and right as long as we are not falling, but currently we are always falling because we have not set ourselves a gravity, so lets add gravity.
we set gravity to a variable that works for our game world, we make it a variable so we can modify if we wish for different levels or some mechanics,
then we also add our velocity from the previous image to the y axis, which is our left and right and we now have movement and gravity and the ability to jump.
however we now have a platform that is out of reach of the character, and it has a tasty orb to collect on it, so lets add the ability to double jump to reach the platform.
this will allow the character to double jump once, we add the doublejump as a variable because it limits the ability to double jump here, also we can reset it through code if we wish later.
Now we have one way of reaching our orbs, lets make them into a collectable.
The first we use in a new coin script which when the player enters the collider of this object calls the method in player to add coins, then we send that information to our UIManager to show us how many coins we have collected.