Creating An Advanced 2D Player Controller Without Any Unity Components! (Part 5)
In this post, I will be adding wall-climbing and sliding.
Today’s Objective: Add the ability to wall-climb and wall-slide to my 2D player controller, so the player can bounce between walls to get to higher positions.
I want to allow easy toggling of these 2 abilities, so I need 2 booleans. I also need 2 floats:
Now, since the wall climbing will happen when the player is not touching the ground, I will put most of the code in the AirborneBehaviour method which is called from Update whenever the player is not grounded.
Next I’ve made an If Statement checking if _isWallSliding is true.
Within the Jump method (created in my past post), I simply add the behavior for wall jumps into the existing switch statement:
I close off the behaviour by updating the animations in the event method which is called whenever the player becomes airborne (including jumping/falling from a climbable wall).
If anyone didn’t noticed, since yesterday’s post I’ve added a player model and lots of animations to my game. Looking much better now, isn’t it? More to come though. :)