WASD for FPS Camera

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
TheBeef
Posts: 25
Joined: Wed Feb 20, 2008 4:38 am

WASD for FPS Camera

Post by TheBeef »

Now, I use the .NET wrapper for irrlicht, so some of my terms or whatever might be a little off, but any help is welcome :)

When I make the built-in FPS camera, it is only controlled through the arrow keys. If I wanted it to be a traditional FPS-style camera, how would I go about setting it to be controlled by WASD? Would I have to check for keypresses each frame and move the camera accordingly, or is there some other built-in function to switch the controls?

Thank you! :]
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Excuse me but that's the 3rd post in a row that's pretty stupid :x
Search the freaking forum and look on the freaking docs - WHY DO YOU THINK THEY'RE AVAILABLE FOR YA!! HA!! :x
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
TheBeef
Posts: 25
Joined: Wed Feb 20, 2008 4:38 am

Post by TheBeef »

MasterGod wrote:Search the freaking forum and look on the freaking docs
Searching the BBS and the wiki (and the camera class in the API) returns nothing of relevance.

Thanks for the help! :D
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

The scenemanager class in the API gives you the answer: SKeyMap. It's a parameter of the function that creates the FPS camera.
Image Image Image
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

TheBeef wrote:
MasterGod wrote:Search the freaking forum and look on the freaking docs
Searching the BBS and the wiki (and the camera class in the API) returns nothing of relevance.

Thanks for the help! :D
Freaking API :D wrote:virtual ICameraSceneNode* irr::scene::ISceneManager::addCameraSceneNodeFPS ( ISceneNode * parent = 0,
f32 rotateSpeed = 100.0f,
f32 moveSpeed = 500.0f,
s32 id = -1,
SKeyMap * keyMapArray = 0,
s32 keyMapSize = 0,
bool noVerticalMovement = false,
f32 jumpSpeed = 0.f
) [pure virtual]

Adds a camera scene node which is able to be controlled with the mouse and keys like in most first person shooters (FPS).

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 );

Parameters:
parent,: Parent scene node of the camera. Can be null.
rotateSpeed,: Speed with which the camera is rotated. This can be done only with the mouse.
moveSpeed,: Speed with which the camera is moved. Movement is done with the cursor keys.
id,: id of the camera. This id can be used to identify the camera.
keyMapArray,: Optional pointer to an array of a keymap, specifying what keys should be used to move the camera. If this is null, the default keymap is used. You can define actions more then one time in the array, to bind multiple keys to the same action.
keyMapSize,: Amount of items in the keymap array.
noVerticalMovement,: Setting this to true makes the camera only move within a horizontal plane, and disables vertical movement as known from most ego shooters. Default is 'false', with which it is possible to fly around in space, if no gravity is there.
jumpSpeed,: Speed with which the camera is moved when jumping.

Returns:
Returns a pointer to the interface of the camera if successful, otherwise 0. This pointer should not be dropped. See IReferenceCounted::drop() for more information.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Jgoldnight
Posts: 31
Joined: Thu Jun 07, 2007 6:23 pm
Location: New York
Contact:

Post by Jgoldnight »

I thought people on the forums just ignored repeated posts, not bashed those individuals who asked the questions.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

MasterGod wrote:Excuse me but that's the 3rd post in a row that's pretty stupid :x
As you can see I was a little in a bad mood but I gave him the answer after all didn't I?.. :roll:
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

MasterGod wrote:Excuse me but that's the 3rd post in a row that's pretty stupid :x
Search the freaking forum and look on the freaking docs - WHY DO YOU THINK THEY'RE AVAILABLE FOR YA!! HA!! :x
What the... I don't remember making this post. I may be drunker than I thought tonight. :?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply