Moving the camera using W, S, D, A

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.
Post Reply
webnoob
Posts: 17
Joined: Mon Aug 20, 2007 9:28 pm

Moving the camera using W, S, D, A

Post 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?
GameDude
Posts: 498
Joined: Thu May 24, 2007 12:24 am

Post by GameDude »

It should work with anything, you just need to try different things until you get it.
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

pass keymap with desired keys to addCameraSceneNodeFPS() when creating camera. thats it ;]
webnoob
Posts: 17
Joined: Mon Aug 20, 2007 9:28 pm

Post by webnoob »

Any chance you could provide an example?
Wyszo
Posts: 49
Joined: Sun Jun 24, 2007 8:44 am

Post by Wyszo »

Any chance you could search the code snippets subforum?
webnoob
Posts: 17
Joined: Mon Aug 20, 2007 9:28 pm

Post by webnoob »

nvm, I got it now, ty
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post 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);
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Post Reply