You know how in the Nintendo 64 Zelda games, you can lock on to enemies by holding down a button? (Or, if you don't, basically you press and hold a button and your focus goes to the enemy closest to you.) I'd like to replicate that in Irrlicht. I'm just using the demo as my base for the game. Now, I already have the basic code in:
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_KEY_E &&
event.KeyInput.PressedDown == true)
{
OutputDebugString("You just pressed the lock-on key.\n");
device->getSceneManager()->getActiveCamera()->setTarget(model2->getPosition());
}
Now, this works perfectly; as long as I'm not pressing any of the movement buttons. Then it doesn't recognize it. Is there any way for me to have both the locking-on key and a movement key (WASD) get recognized at the same time? Does it have to do with the fact that the WASD keys are in the currentScene switch and not in OnEvent? Here's my (read: demo code + one change) OnEvent code in its' entirety:
Also, another thing: When you press and hold E, it will lock on for a second, then stop locking on, then start again. I don't know the way it is in OSX, and I don't know if Linux/X11 does this, but in Windows, open up a text editor and hold down any character key. H, F, O, anything. See how it pauses for a second before repeating that letter? That's what is happening to me in the game.
Your problem is that you're not checking key state but key changes.
You only get an event when a key is pressed or released, not in between.
If you are getting repeating presses, that's because you also get releases before them.
Go to the FAQ forum. Look for the "bool keys[]" thread. The code isn't perfect (the updown and downup code doesn't work the way it should) but it'll get you started.