Player Input
Learn about using player input with the Kakara Engine.
Last updated
Was this helpful?
Learn about using player input with the Kakara Engine.
Last updated
Was this helpful?
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.
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 article for more information.
The Nintendo Switch Pro controller will not work proper due to a bug in GLFW. See the bug report .
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.
You can check if a controller button is pressed by using:
An axis is an input that ranges from -1 to 1. This includes things like: Left Stick, Right Stick, and the triggers.
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.
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.
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 is an event relating to Controller Buttons, check out the article for more information.
There are several events relating to Mouse Input, check out the article for more information.