Sponsored By

PuniTy and Controller Support - Getting thumbsticks to feel good

Here are some tricks I learned from observing other games to get good-feeling thumbstick controls in PuniTy.

Farhan Qureshi, Blogger

September 21, 2015

6 Min Read
Game Developer logo in a gray background | Game Developer

*     *     *

You can download the updated version with controller support on itch.

*     *     *

Despite using Unity for 3 years now I had never implemented controller support for any games I made as I always went with mouse and keyboard, so I was looking forward to finally learning this. I didn't want to use Unity's native support for controllers as I was afraid that would only support a small subset of gamepads (namely just the 360 controller), and multiple people recommended the unity asset Rewired as a robust choice that supports a lot of controllers. So that was my starting point.

I quickly learned that the default configuration for a controller doesn't feel good. I had no idea that the slightest twitch of a thumbstick will register some movement, as I've always experienced controls after they've been refined. Another example of "taking controls for granted" is it's near impossible to turn left and right without moving your head up or down thanks to the super responsive thumbsticks.

Sp by developing gamepad support it made me appreciate other games and the work they put into refining their controller feels. Here are the steps I went through for implementing my own controller support.

Deadzones

I really wanted to get rid of that super-sensitivity, and I didn't understand how important deadzones were until now. They are an essential step towards giving the player more deliberate control over their movement and view. If you've never heard of the term it's simply a region of joystick movement that ignores input, whether completely or partially. A prime example is turning right or left in a first-person view. A classic example is ignoring input when slightly tilting the joystick in any direction to allow more deliberate movements. Another is as mentioned above, if there's no axis deadzone on the analog stick it's near impossible to turn horizontally without some vertical movement as well and vice-versa, as our thumb will rarely ever move the stick perfectly in the four cardinal coordinates. By default a controller has no deadzones (0 on the scale implies no thumbstick tilt, whereas 1 is fully tilted):

For PuniTy's camera I ended up going with this:

A thumbstick tilt between 0 and 0.1 will not register any turning. This helps create deliberate movement for the player and allows complete horizontal and vertical movement without them bleeding into one another. Thumbstick values between the range of 0.1 - 0.9 are remapped to a 0 - 1 range for full motion, and values between 0.9 and 1 are always treated as 1 so there's some relief incase a player doesn't hold the thumbstick at full tilt for maximum camera rotation. For PuniTy's movement I ended with this:

punity movement range

I implemented two speeds for movement, a slow walk and a normal walk. After playing with the numbers I settled with a threshold of 0.65 thumbstick tilt for the normal walk, and below that value for the slow walk. The deadzone below 0.1 is again very important for deliberate movement.

View Speed - Vertical Damping

If you've ever played a first-person game with a controller you might have noticed how your horizontal turn speed is faster than your vertical tilt. One reason is turning horizontally has a 360 degree range whereas vertically only has 180, and covering that smaller range at the same speed used for left and right panning is way too fast. Another reason is most FPS games have important information, such as enemy placement and spatial navigation, happening in your horizontal field of view more so than your vertical boundaries, so a fast vertical tilt speed is further unnecessary (though modern games are also placing important info in the vertical field as well which is fantastic). After playing around some I implemented a vertical look speed that's 0.7 times the horizontal speed. This felt right in the middle of too slow and too fast.

View Speed - Quadratic Interpolation

By default, linear interpolation is used for determining camera rotation based on thumbstick tilt, so you get out exactly what you put in:

But this sucks for higher sensitivities as fine movement is lost when slightly tilting the thumbstick. It also doesn't feel good for medium/lower sensitivities as the thumb placement needed to maintain a certain speed is too precise. What's needed is some sort of quadratic interpolation:

Even using the default curve Unity provides in its animation curves feels fantastic. Now even at higher sensitivities you can maintain fine control over the camera, lower sensitivities have a nice flow to them. Try testing different curves to see what best suits you and your players.

*     *     *

I didn't implement the following features, but they carry varying importance depending on your game.

More Polish - View Acceleration

Something many games feature, such as Halo, Gears of War, and Wolfenstein: The New Order is view acceleration. Simply put, the longer you rotate your view at your thumbstick's maximum tilt, the more the camera will accelerate its movement until hitting a speed cap. Typically this cap is hit between 1 to 2 seconds after maximum tilt is reached. The thought process behind this is if a player needs to scan their environment rapidly or look behind themselves, the acceleration will help them reach their desired view a bit quicker.

More Polish - Movement Axis Deadzones

After putting hours into Dark Souls 1, I immediately noticed this feature implemented in Dark Souls 2 and Bloodborne. When tilting the thumbstick in any of the cardinal directions (North, East, South, West), the axis opposite to the one being used is given a small deadzone to help the player move in those absolute directions:

So if a player wants to move directly forward, a y-axis value between 0 and 1 is needed along with an x-axis value of 0. But as with the view deadzones, it's hard to tilt a thumbstick directly north without bleeding in some horizontal movement, especially from a standing position. Dark Souls 1 didn't have this feature however the subsequent games did, and I found it really helped for precise movement (because those games DEMAND precise movement at times).

Let me know of any other tricks you use to get a good feeling controller in the comments.

Read more about:

Featured Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like