CULTIC Dev Diary - Gamepad Support

CULTIC was designed to be played with a mouse and keyboard. That's what I've always used for shooters, so I didn't really even think about gamepads until the first demo came out and folks were asking me about gamepad support. I hadn't really even thought of using a gamepad for a shooter on PC when you've got a perfectly good mouse/keyboard available!
However, clearly there are users who prefer to play this way. In fact, Steam reports that 10% of total game sessions are played on gamepad:
https://store.steampowered.com/news/group/4145017/view/3061855517864424914
I want folks to be able to play CULTIC however they're comfortable, and it would need to be done eventually if I wanted to ever port CULTIC to consoles, so here's what I've been working on:

There was so much that went into gamepad support. I've never been a huge fan of Unity's legacy input system, so I wrote my own that was based more around "actions" rather than key presses. For example, instead of the code polling to see if "Spacebar" was pressed, it instead polls to see if the "Jump" input was triggered, and whatever button or key was assigned to that "Jump" action would cause that to trigger. This made rebinding much easier and more accessible, but I still hadn't ever implemented gamepads to this, or even looked into how to capture raw gamepad input.
Then I stumbled upon Unity's new Input System -

I remember reading about the new Input System a few years ago, but it was very much "in progress", and wasn't part of Unity's official packages, just something you could download from Github and install manually. Since that time, it has grown massively and has several stable releases out, and toted out-of-the-box support for hardware polling and automatically detecting and processing connected gamepads - even telling what kind of gamepad is plugged in, and reflecting the proper keycodes (Square vs. X, etc.)

The best part? This new system was also "Action" based, like my custom system, so after a couple of days of reading and trying to learn this new system, the actual implementation was super easy. It took a big overhaul to get my existing rebind system to work with the new Input System, but in the end it was definitely worth it, and something I'd recommend Unity devs check out if they are struggling with input systems!

With a game that was designed for mouse/keyboard, it became apparent almost immediately that my control scheme was not entirely compatible with a gamepad. There were simply too many different commands the player could input to fit onto a gamepad without convoluted input combinations or heavily contextualizing inputs. This somewhat forced me to take a look at some gameplay elements that I had been waffling on, as I needed to decide for sure what the total roster of player actions would be so I could build a control scheme for them.
Some changes included:
- Inventory Wheel scrapped, replaced with a static directional "pad" of icons.
- Keys switched to auto-use, removing the need for a key/item radial
- TNT/Molotov controls modified to work better with gamepad
- Weapon radial changed - tap to swap to previous, hold to access radial
... among others.

Surely with these changes, the game would be playable on a gamepad now... right?

I guess part of being primarily a PC gamer for the better part of 15 years is that my aim with a joystick is terrible! Beyond that though, target acquisition in a classic style shooter without ADS was kind of rough - especially in frantic combat situations. So I asked some fellow developers how they combat this kind of thing, and of course, the answer was that most shooters played with gamepad employ some kind of aim-assist.

This was actually a pretty fun learning experience. I chatted with some developers about how they'd gone about doing aim-assist, and watched a couple of videos from AAA developers about it as well, and settled on a fairly simple system that does two things:
Soft Aim Magnetism
If your crosshair sweeps over a target within the range of the aim-assist, your turn speed will lower while you're sweeping over them, making target acquisition easier. This will be an optional assist, modifiable in Settings.
Aim Assist
When your aim falls within a certain margin of error around a valid target, the game will make an "estimate" (the red box in the above GIF) of where shot was intended to land. This estimate is based on the nearest point on the enemy collider relative to where your aim ray crossed the aim-assist threshold (the white box in the GIF). Then, depending on how far off your aim is, the resulting shot will be nudged towards the "intended" target. If your shot was only off by a little, it will be nearly fully adjusted to the intended target. If your aim was farther off, it will only be adjusted somewhat, but enough that your weapon's spread may still result in a hit.
This system seems to work well, as I'm actually able to clear a level while using a gamepad, and I am -awful- with gamepads. Hopefully I'll be able to get some feedback from the testing team and folks who are more used to gamepads to see what future improvements can be made!
Thanks for checking out this article! For the most up-to-date CULTIC info, follow the project on Twitter!
https://twitter.com/JasozzGames
https://twitter.com/3DRealms
Wishlist CULTIC and try the free demo!
https://store.steampowered.com/app/1684930/CULTIC/