July 31, 2015 Ian McCabe

Dev Blog 4 – Assuming Direct Control

Hi everyone, it’s great to meet you!

My name is Ian and I’m one of the new developers here on the P.A.M.E.L.A. team. I am so honored to be a part of the team and consider myself lucky to be working on this amazing project with such talented individuals.

Mainly I work closely with Christian (who you may have already met in Dev Blog 2) in programming/developing a lot of our systems for the game. Currently I am working on a number of things including the character controller, the item/inventory system, object detection, and even some visual effect systems.

Enough about me though, how about we get to the good stuff!

Alright, so this week I’ll be talking a bit about the process we went through to create our custom character controller. Before I begin, please be aware that all the content shown (including the character model and animations) are in development. For this post, we’ll be focusing more on the camera’s movement in 3D space, rather than it’s associated visuals and animations.

Below I will cover some of our initial goals for the character controller, the challenges we encountered, and the final outcomes we achieved. So let’s “jump” right in.

 

Why make a custom controller?

So you might be wondering “why even make a custom character controller?” Well that’s a great question.

Although there are a number of implementations out there for character controllers (especially for Unity), you might find that none of them seem to “fit” with your game’s style. Depending on the game you’re making and it’s mechanics, you may want to prioritize a character controller that re-enforces the right kind of physics and movement you’ve envisioned. Keep in mind that your character (and furthermore it’s camera) is a window into the world you are trying to create, so you need to make sure that something as simple as moving around a scene is interesting and keeps players’ attention.

Anyway, we decided to create our own character controller because we couldn’t find a good solution to the kind of movement we wanted to achieve. If you’re thinking of doing the same, I would recommend you set aside some time to think about what kind of movement you want first, and how it will affect game play.

Basic Unity Character Controller.

Basic Unity Character Controller.

 

Establishing goals and studying movement

Before I started programming, I sat down with the team to brain storm some ideas about how we wanted the character to move, feel, and resolve obstacle conflicts.

For character movement, we decided that we wanted the input to be quite responsive, yet still have a fair amount of ramping up / down between varying locomotion states. In other words, we wanted movement from a full stop up to a full sprint to be relatively seamless while reducing jumps between different speeds.

For obstacle resolution, we wanted the character controller to take into account small gaps, ledges, ramps, and moving platforms so that movement would feel natural over different types of terrain.

Thanks to Christian, I already had a number of great forward and strafing animations I could use as reference. These animations, combined with our brain storming ideas, gave me a great base to start developing the system.

Below is a simplified graph of how we wanted the speed progression to work. As the character starts moving forward, the speed changes from a walking state into a running state  as the character continues in the same direction (seen in the blue line). When the direction changes, speed is slightly reduced and altered accordingly. As well, the character can start sprinting at any time between the walking and running transitions, causing the character to ramp up to a sprinting speed.

Character Speed Over Time

Graph of the players motor speed as it changes over time.

 

Overcoming Challenges

For our character motor we decided to use Unity’s Character Controller component in combination with some custom physics scripting. One thing to keep in mind when working with physics is that each functionality you add can affect the rest of your movement. There would be times when I would think I had solved small ledge detection issues, only to find that the fix had caused some rather comical “I must go, my people need me” kind of jumping. Suffice to say, small ledges were my nemesis for quite some time.

Small Ledges

During development, ledges became quite a nuisance as even the smallest gap or ledge could cause issues with movement.

 

With that in mind I eventually created a small developer test scene to make sure I was maintaining functionality as I progressed. With the combination of this test scene and some fun physics coding we were able to get functionality for small ledge detection, wall detection, ramp sliding, jumping, terminal velocity falling, and full locomotion tied together in one neat little motor script.

ProgrammingPlayground

This programming playground evolved as we started developing different kinds of movement around the scene.

 

Finally, a lot of development went into transitioning between walking, running, and sprinting. We liked having the slow ramp up from a stopped position to a walking speed as it allowed us to execute fine motor actions such as zeroing in on items and peeking around walls, but we found for more exploratory movement we wanted to move faster without having to initiate a full sprint. As well, foot sliding is always a challenge, so solving that with properly timed speed was also a priority.

With a bit of work, we eventually came up with a pretty cool timing system for transitioning between these states that feels fairly natural and accounts for a loss in speed when changing directions.

 

It’s ALIVE!

As you can see in the video below, we have a pretty wide range of movement that allows for some interesting locomotion within the scene. The smoothing momentum combined with some minor camera bob really adds to the immersion.


Overall, I’m really happy with the results so far. But as always, development is an ever evolving thing, so we’ll be working more on the controller to make it feel even better.

If you are developing your own character controller, I hope this post has given you a bit of a “step” in the right direction. And if not, I hope you found our process interesting, if not entertaining.

 

Thank you for joining me this week, and make sure you tune in next Friday for Alayna’s post where she will be talking all about creating concepts and designing in…

Dev Blog 5 – Birth of a World

 

Also be sure to check out our newsletter if you’d like to receive monthly updates as well as important news about the game.

SIGN UP FOR OUR NEWSLETTER!

About the Author

Ian McCabe
Ian McCabe Ian is a Programmer and Developer at NVYVE Studios.