Player Input
Learn about using player input with the Kakara Engine.
The Kakara Engine has many ways to handle input, in this tutorial we will only cover the basic way. The Kakara Engine supports Mouse, Keyboard, and Controllers. The basic way to handle input is through the Input
utility class.
Keyboard Input
Checking for Keyboard input can be as simple as this:
That checks if a key is held being held down and executes code if it is. That if statement would be put in an update method.
There are 2 events relating to KeyInput, check out the EventSystem article for more information.
Controller Input
The Nintendo Switch Pro controller will not work proper due to a bug in GLFW. See the bug report here.
Like Keyboard input, the Input
class can be used with Controllers. Controllers have two kinds of input: Axis and Button. Controllers also have an ID, like a controller slot on consoles. There can be 16 controllers connected at once. ControllerID.CONTROLLER_ONE
is an example of an ID.
Controller Buttons
The triggers are considered axes instead of a button.
You can check if a controller button is pressed by using:
There is an event relating to Controller Buttons, check out the EventSystem article for more information.
Controller Axes
An axis is an input that ranges from -1 to 1. This includes things like: Left Stick, Right Stick, and the triggers.
Controller Rumble
As of right now controller rumble is not supported by the Engine since GLFW does not support it yet. This feature might be added in the future.
Special Controller Features
Any special features a controller might have, like Haptic Feedback, are not supported by the Engine. You will need to add that feature in yourself.
Mouse Input
Unlike Controller and Keyboard, the Input
class is not used. Instead the GameHandler
contains a MouseInput
class.
The code snippet above just covers a small slice of the MouseInput
class.
There are several events relating to Mouse Input, check out the EventSystem article for more information.
Last updated