Upgrading Player Controller (Guardians of RPG v1.03 Update)


Hello everyone!

It's Monday which means it's time for another weekly devlog! Today I am going to be going over my progress on upgrading one of the game's basic mechanics, which are its controls. Without further ado, let's get into it.

Old Controls

The old way in which I implemented Player Controls was by using the Input.GetKeyDown(KeyCode) method inside my PlayerController class. What I would do is that I would be able to check inside the Update/FixedUpdate methods if any of the keys have been pressed, and if they were, to do some type of action associated with said button. This method was great for starting a game and learning how it works, but I ran into problems when trying to future proof my game.

1. I needed to add new input commands inside the PlayerController class

Every time I needed to add more controls to the PlayerController class, my Update method would look more and more congested, and as a result, it would be harder and harder to read. The most unfortunate part is that most of the buttons would be doing the same actions such as the WASD and the arrow keys.

2. I needed to make something that would work with multiple platforms

I want my game to be accessible for others using a mouse and keyboard as well as using their phone, or a game controller. This means I would need to future proof my game in a way that will allow me to add as much controls as possible dynamically without causing unnecessary strain on the codebase.

New Controls: InputSystem

The new system that I use to regulate the players controls is through a Unity feature called InputSystem. Through InputSystem, I am able to create a Controller that lists out all of the controls for a mouse/keyboard, game pad, and more, then link/bind those to specific input actions in code with little to no effort. This process has reduced the amount of code inside the PlayerController class by a significant amount, at least 200 lines of code were eliminated just by changing how the game receives inputs.

Future Updates

There are a few things that I still need to work on for this week such as the following:

  • Update PlayerState class
  • Update all InteractableObject classes
  • Add touch screen feature
  • Update NPC Companion Feature

Summary

This week was pretty slow compared to most, but I'm glad I was able to get some good updates in before the end of the week. I want to thank each and every one of you all for supporting me on my journey thus far. Each view, comment, and like really does mean a lot to me. Be sure to check out the game Guardians of RPG v1.02 out if you haven't already, and I will see you all next week.

Leave a comment

Log in with itch.io to leave a comment.