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.

The Code:

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. :)

--

--

--

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Introduction to Figma - https://youtu.be/g6rQFP9zCAM

CSS Preprocessor — SASS, LESS and Stylus

5-) Singleton Design Pattern

ReactiveKit and Bond Part 1.2

Code for San Jose Presents Inclusive Product Week

You Must Take This Course Before Diving Into Cybersecurity

Installing and Configuring RTKRCV (RTKLIB) on Windows 10 Using WSL

Using Indirect Multipliers To Balance Lighting Costs And Results

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Taylor

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

More from Medium

Set Up & Trigger A Timeline Sequence In Unity

Adding a burst laser powerup

Making a 2.5D Character Controller in Unity Part 1

Upgrading Controls on a Forklift to the new Unity Input System