Lost Caves Devlog #7 - Proper Controller Support


Before I begin this, let me just say that Lost Caves does indeed have controls. You can use your keyboard, and you were able to use gamepads with XInput (Xbox controllers basically). That being said, the way gamepad controls were handled prior to last week were really messy, and just overall not very good. The face buttons worked, you could use the d-pad to move, but you couldn't use the sticks for anything, and for the love of god, I could not figure out how. Thank goodness for Unity's new Input System, however. I discovered it a month or two ago, but I couldn't use it because it was for Unity 2019, and at that time, I was still on Unity 2018. I was against upgrading because of how Unity handled prefabs, but at this point, I figured it was gonna be inevitable that I'd upgrade.

Before last week, I was on 2019 since the 2D animation package that lets you rig sprites was only available, or at least easily usable, in that version, so I was all set and ready to go (and I realized the prefab handling wasn't that bad). I also received a wired Xbox controller in the mail finally, so I was able to handle XInput properly (my 8bitdo controllers also do XInput, but I didn't really trust it). In a very short amount of time, I was able to redo the game's gamepad controls and map Michael's movements to a gamepad.

The current way I have it is similar to that of 2D Mario, specifically with the face buttons. 2D Mario games have it so that the jump button is on the A and B, or East and South buttons, if you wanna get general. That makes sense because those buttons are closer to the thumb, and Mario games are all about jumping. The X and Y, or North and West buttons, are used for dashing and shooting fireballs. Lost Caves is not a momentum-based platformer like Mario is, so you don't dash. That said, you do attack with your pickaxe, so I have both buttons mapped to that. It's a simple but effective mapping system, and it gives the user a bit of gamepad real-estate to work with in case the buttons are small.

Adding horizontal movement was pretty simple for both the D-pad and the left stick. However, after adding down-thrust/pickaxe pogo functionality by holding down on the D-pad and stick, I noticed a problem. When holding down on the stick to pogo, sometimes you just won't move forwards. That's because you've moved the stick so far down that you can't move it left or right far enough to get Michael to move. Thankfully, sticks are analog, and return an analog value, so what I did was, instead of simply checking if the stick was held right, left, or down, I checked for a value. If a stick is in its neutral position, its X and Y values are 0. If it moves to the right all the way, its X is equal to 1, down, and Y is equal to -1, left, with X being -1, and up, with Y being 1. Pretty simple, but for movement, I have it so that it checks if the stick's X axis is equal to 0.5 for going right, and -0.5 for going left. Pretty much it just makes the controller more sensitive. That way you don't have to hold it too far to the left or right to get Michael to move, and so you can hold down to pogo while moving more easily. The value for checking when to pogo is also -0.25, which makes it even more easy.

In addition to simply making controller input work properly, I also made graphic that would appear at the beginning of the game, recommending the use of a controller. Given that this game is meant to have the look and feel of 8 bit or 16 bit platformers, it's also meant to be played on a controller. Even keyboard controls demonstrate that, with them being WASD for movement, and the apostrophe key for jumping, and the semicolon for attacking, similar to an NES. The graphic has white line-art of the Xbox, PS4, and Nintendo Switch Pro controllers.

Controller Graphic

"For the Best Experience, Play with a Controller!"

Now, if you've read my previous devlogs (and I hope you have), you'll notice that the art style for those controllers is a bit incongruent with that of the rest of the game. This game isn't undertale; there's not a lot of black and white going on (although there is an undertale Easter egg in the game). The main reason I wanted to go with this design though was because I didn't think fully colored and shaded controllers would look too good on a black background, or at least it would be overkill. I was kinda going for simplicity. Of course, I could simply not use a black background. Heck, I could have made them carvings on a wall like in the title screen. However, the reason I decided not to was so the game could transition to the title screen, which starts black. I don't think having a colored backdrop for this that fades to black, only for you to fade out from black, would look very good, and again, I kinda wanna maintain consistency, and I think this accomplishes that.

Back to actual controller input, though. As nice as the Input System Unity package is, I learned some of its shortcomings. For instance, only one script can handle inputs, or action maps, at a time (action maps being pretty much all the buttons and inputs you do and how they behave). So I can't have a script that handles input for Michael, and another separate one that handles input for the UI, and to be honest, that's really stupid and backwards. I don't know, maybe there's an inherent reason for it, but Unity's sub-par documentation doesn't explain it. Thankfully I can use a component for UI to handle that input. The handicap really made me tear my hair out though. I don't really get why controller mapping and inputs are such a difficult thing for Unity to tackle. Regardless, this is significantly better than the old input system, so I am thankful for that at least.

The boss is coming along very well, and the basic gameplay is pretty much done. I'm adding some other tweaks to it though, but I seem to be on-schedule. I was planning to release the game in early December, but given that so many other games get released at the same time since it's the holidays, it may be a bad idea for me to do it, so I'm probably gonna move it to a later date. I don't want it to be too late, though. If any of you all know of a good time in the year for an indie game to be released, feel free to comment below if you have any thoughts on that. Also, if you like what you read, please give this a like, it's much appreciated!

Get Lost Caves

Buy Now$6.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.