Collection: Paudric Smith - GD4 Portfolio

Player Controls

 

Home

Design

The player controls as you journey through the game must be enjoyable while also feeling realistic. Any first person game can get frustrating it the controls are janky and are not bound to an ergonomic key. My main focus of this role was to give the user many controls without taking away gameplay and time as the game has many parts where the player is being chased so there would be no time to look at the keyboard for the '#' key for eg. and loss focus and not have a chance to sprint away.

WASD is a universally known set of keys that has taken over the arrow keys so much that in recent years even gaming keyboards and laptops highlight them a different colour than the rest. It makes it easier for the PC gamer as the space between their mouse hand and key hand is at a comfortable distance.
Screenshot 2022-03-12 1651252.png


The equip/unequip flashlight key is 'F' and the equip/unequip gun key is 'G' for good reason. Not only do the letters stand for the object but they are both on the same keyboard line to the right of the 'D' key (strafe right) which is the users left hand index finger. This means the user after little time of practice won't have to look away from the screen but just feel the key with his finger.
Screenshot 2022-03-12 192153.png.1


Sprint and Crouch keys were chosen to be the 'LShift' and 'LCtrl' key respectively because of their close proximity to the users little finger on their left hand. By default the users little finger rests on the 'LShift' key and just below that is the 'LCtrl' key meaning every control is connected and reduces the amount of time needed to look at the keyboard which can be spent by gameplay.
Screenshot 2022-03-12 1651253.png


When it came to deciding what key to use for the player jump the only one that made sense was the 'Space-bar' since it is big enough so as not to miss it. Although it is not connected to the other keys it actually sits comfortably under the thumb.
Screenshot 2022-03-12 192157.png


The 'E' key is used for interacting with items in game like levers, fortune tellers, keys etc. Although the letter 'E' has nothing to do with interactions, the location of the key made me choose it as it is connected to the rest of the keys just above the 'D' key and index finger.
Screenshot 2022-03-12 1651255.png.3


I tried to keep the middle finger the center of all the keys used and let the index and little finger do the moving to help the user from hitting the wrong key. The index finger being the most dexterous appendage of the hand it made sense for it to do most of the work, having 4 keys to find. 
1 = THUMB FINGER, 2 = INDEX FINGER, 3 = MIDDLE FINGER, 4 = RING FINGER, 5 = LITTLE FINGER
Screenshot 2022-03-12 1651256.png.1


I used the mouse movement to represent the players head movement so if the user moves the mouse left or right the player will look left or right and if the user moves the mouse forward or backwards the player will look up or down with a clamp set to stop the player looping vertically. This gave a more realistic feel to the player as if you were really controlling his head. Left click has only one use which is to shoot the player's gun. Having this action tied to one button gives gravity to the weapon and can not be confused with anything else while in the heat of a chase.

Unity New Input System

I chose to use the new input system because it can be used with any kind of Input Device to control your Unity content and is a more extensible and customizable alternative to Unity’s classic input system. Unity's New Input System.

When you first make your "Input Action Asset" you will be able to generate a Mono script so you can make changes to the controls through that script instead of dragging and dropping input events in the editor. I named mine "PlayerControls".
Screenshot 2022-03-14 132135.png


The "InputManager" Class takes in 4 scripts with logic for movement, mouseLook, flashlight and gun using composition over Inheritance.
I made and instance of "PlayerControls" and it's "PlayerActions" that I made above.
Then made two local variables, "horizontalInput" for "movement" script and "mouseInput" for "mouseLook" script.
Screenshot 2022-03-14 130011.png.1

I initialized all the player controls in the Awake() of the "InputManager" Class.
Screenshot 2022-03-14 135051.png

"Update()" calls the "ReceiveInput" methods in the "Movement" and "MouseLook" Class which updates  the player movement and mouse look variables.
Lastly we must make sure to enable and disable our controls when they start and stop.
Screenshot 2022-03-14 135146.png

Using the player camera, mouse look on the horizontal was achieved by rotating around an "up vector3" by the mouse X delta received from the "InputManager" script through the "ReceiveInput" method. Mouse look vertically came from the mouse Y delta received from the "InputManager" script through the "ReceiveInput" method then clamping it's rotation so the player cannot look vertically infinitely.MouseLook.jpg

The "Movement" script works similar to the "MouseLook" script. The "ReceiveInput" method updates the local Vector2 "horizontalInput" variable with the movement input from the "InputManager" which comes from the new input system when either w, a, s, or d is performed.
Screenshot 2022-03-14 141344.png

Screenshot 2022-03-14 141920.png

Screenshot 2022-03-14 142058.png