Page 1 of 1

Moving the camera using W, S, D, A

Posted: Thu Aug 23, 2007 7:50 pm
by webnoob
Hiya,

Is there any tutorials on moving the FPS camera using different keys? I have gone through the movement tut but that only seems to work with other nodes and not the FPS one, am I wrong?

Posted: Thu Aug 23, 2007 7:54 pm
by GameDude
It should work with anything, you just need to try different things until you get it.

Posted: Thu Aug 23, 2007 8:04 pm
by roxaz
pass keymap with desired keys to addCameraSceneNodeFPS() when creating camera. thats it ;]

Posted: Thu Aug 23, 2007 8:29 pm
by webnoob
Any chance you could provide an example?

Posted: Thu Aug 23, 2007 8:53 pm
by Wyszo
Any chance you could search the code snippets subforum?

Posted: Thu Aug 23, 2007 9:27 pm
by webnoob
nvm, I got it now, ty

Posted: Sat Aug 25, 2007 12:53 pm
by MasterGod
Taken straight from the "Irrlicht Engine 1.3.1 API documentation "

Code: Select all

Look with the mouse, move with cursor keys. If you do not like the default key layout, you may want to specify your own. For example to make the camera be controlled by the cursor keys AND the keys W,A,S, and D, do something like this: 

SKeyMap keyMap[8];
keyMap[0].Action = EKA_MOVE_FORWARD;
keyMap[0].KeyCode = KEY_UP;
keyMap[1].Action = EKA_MOVE_FORWARD;
keyMap[1].KeyCode = KEY_KEY_W;

keyMap[2].Action = EKA_MOVE_BACKWARD;
keyMap[2].KeyCode = KEY_DOWN;
keyMap[3].Action = EKA_MOVE_BACKWARD;
keyMap[3].KeyCode = KEY_KEY_S;

keyMap[4].Action = EKA_STRAFE_LEFT;
keyMap[4].KeyCode = KEY_LEFT;
keyMap[5].Action = EKA_STRAFE_LEFT;
keyMap[5].KeyCode = KEY_KEY_A;

keyMap[6].Action = EKA_STRAFE_RIGHT;
keyMap[6].KeyCode = KEY_RIGHT;
keyMap[7].Action = EKA_STRAFE_RIGHT;
keyMap[7].KeyCode = KEY_KEY_D;

camera = sceneManager->addCameraSceneNodeFPS(0, 100, 500, -1, keyMap, 8);