2.5D Training Progression Report: Movement and Moving Platforms. Unity
Today I follow up on the last progression repot to show what progress have I made so far.
What has been accomplished so far?!
For this prototype, we decided to use the character controller in order to control the movement and physics interactions of the player.
Horizontal movement and Jumping
To control the horizontal movement, I assigned a variable to detect the player’s input along the x-axis. This variable will be assigned to the direction and velocity used for the character controller Move() method.
As for jumping, as long as the player grounded, he can jump once. Once the player jumped, we reset his velocity on the y-axis (to remove any gravity from the last frame) and then add the jump height. This allows for a smoother and more consistent jumping.
Basically this is almost like jumping, but it is done when the player is not grounded. By using a Boolean we control when and how often the player can double jump.
This is a little more complicated. Depending on the very handy method that comes with the character controller (OnControllerColliderHit), we detect when the player collides with a wall(tagged wall). This detection will assign a Vector3 normal based on the hit.normal of the collided surface and allow the player to wall jump.
if (Input.GetKeyDown(KeyCode.Space) && !_canWallJump)
_yVelocity = 0;
_yVelocity += _jumpHeight;
_canDoubleJump = false;
I created a modular moving platform system where it take two or more waypoints and moves the platform from one point to another using the Vector3.MoveTowards method in the FixedUpdate for a smoother movement.
Next up, elevators and push systems.