Crouch while key pressed issue
Posted: Thu Nov 03, 2005 5:43 pm
Hi everyone,
I've successfully managed to get crouching down (no pun intended) thanks to help from other posts in the forum. However, there's an issue which I don't think has been addressed yet. Here's my code:
bool OnEvent(SEvent event) {
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown) {
switch(event.KeyInput.Key) {
case irr::KEY_KEY_C: { // crouch
core::vector3df vCrouching = Camera->getPosition();
vCrouching.Y -= 50;
Camera->setPosition(vCrouching);
return true;
}
}
}
The problem is: the crouching happens after I press and release the 'c' key, but I want to crouch when I first press the 'c' key (and stay crouching as long as I hold it) and then when I release the 'c' key I'll stand back up again. I can't figure out how to do that.
Can anyone help?
Thanks.
I've successfully managed to get crouching down (no pun intended) thanks to help from other posts in the forum. However, there's an issue which I don't think has been addressed yet. Here's my code:
bool OnEvent(SEvent event) {
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown) {
switch(event.KeyInput.Key) {
case irr::KEY_KEY_C: { // crouch
core::vector3df vCrouching = Camera->getPosition();
vCrouching.Y -= 50;
Camera->setPosition(vCrouching);
return true;
}
}
}
The problem is: the crouching happens after I press and release the 'c' key, but I want to crouch when I first press the 'c' key (and stay crouching as long as I hold it) and then when I release the 'c' key I'll stand back up again. I can't figure out how to do that.
Can anyone help?
Thanks.