If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
tank202
Competition winner
Posts: 40 Joined: Mon Jan 21, 2013 8:34 pm
Location: Lithuania, Kaunas
Post
by tank202 » Thu Mar 07, 2013 5:28 am
Hi,
I've come across many topics on this problem but I couldn't get decent solution on how to handle multiple inputs.
The problem is that I need my fps character to be able to sprint and when I write such condition :
Code: Select all
if(event.KeyInput.Key == KEY_KEY_W || event.KeyInput.Key == KEY_LSHIFT)
it wont work
In the past I've managed to accomplish similar thing but if shift was pressed earlier that the movement key it wouldn't work also.
I think you get what I mean
- HELP!!!
Last edited by
tank202 on Thu Mar 07, 2013 8:32 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9944 Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:
Post
by CuteAlien » Thu Mar 07, 2013 10:01 am
There is event.KeyInput.Shift which gives you the information if shift was pressed the moment when that key-event has been generated.
tank202
Competition winner
Posts: 40 Joined: Mon Jan 21, 2013 8:34 pm
Location: Lithuania, Kaunas
Post
by tank202 » Thu Mar 07, 2013 7:17 pm
Its no good. If I press 'w' first and the shift, sprint function wont work
tank202
Competition winner
Posts: 40 Joined: Mon Jan 21, 2013 8:34 pm
Location: Lithuania, Kaunas
Post
by tank202 » Thu Mar 07, 2013 8:31 pm
Nop, I couldn't understand what the hell they were doing in that forum so I've managed to find a solution:
As the event receiver loops several times before every rendering, I've decided to exclude movement key handling condition when the shift event was processed, so I've implemented such code:
Code: Select all
if(event.KeyInput.Key == KEY_KEY_W && event.KeyInput.PressedDown == true) Keyboard.ForwardKey = true;
else if(event.KeyInput.Key != KEY_LSHIFT) Keyboard.ForwardKey = false;
And from then my sprint was working perfectly. And they lived happily ever after