getInput
This function is only accessible in a component function
getInput is a useful fucntion for your component if you want to check if player do something with the keyboard or mouse click.
To check this there is 4 functions :
getKey()
getKeyDown()
getKeyUp()
getAxis()
How to use these functions ?
void onUpdate() {
//vertical variable take a value between -1.0f and 1.0f
float vertical = getInput().getAxis("Vertical");
//check is there is action with a key (but do not precise the actions)
if (getInput().getKey(KapEngine::Events::Key::UP)) {
//do something
}
//check if key is pressed
if (getInput().getKeyDown(KapEngine::Events::Key::UP)) {
//do something
}
//check if key is released
if (getInput().getKeyUp(KapEngine::Events::Key::UP)) {
//do something
}
}
Last updated
Was this helpful?