FPS-Camera with WSAD Keys

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
Innocence
Posts: 2
Joined: Sun Jun 26, 2005 8:56 pm
Location: Germany/Hessen

FPS-Camera with WSAD Keys

Post by Innocence »

Hello together,

I would like to set up a FPS camera with "WSAD" input, but I do not point really like it functioned.

I hope someone can help me!?
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

You can change the code in CCameraFPSSceneNode.cpp to use wasd instead of the arrows.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
area51
Posts: 338
Joined: Thu Mar 18, 2004 10:20 pm
Location: UK
Contact:

Post by area51 »

Another way would be to create a Keymap, and pass this in when you addCameraSceneNodeFPS.

Code: Select all


//! Key map added to allow multiple keys for actions such as
//! movement. ie Arrow keys & W,S,A,D.
   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;

   m_pCamera = pManager->getSceneManager()->addCameraSceneNodeFPS(0, 50, 200, -1, keyMap, 8);


________
Girlfriend Pic
Last edited by area51 on Tue Feb 22, 2011 1:05 pm, edited 1 time in total.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

Code: Select all

//wasd navigation
	SKeyMap keyMap[8];

	keyMap[1].Action = EKA_MOVE_FORWARD;
	keyMap[1].KeyCode = KEY_KEY_W;

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

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

	keyMap[7].Action = EKA_STRAFE_RIGHT;
	keyMap[7].KeyCode = KEY_KEY_D;
and add the keymap to the camera as well:

Code: Select all

//fps cam
	scene::ICameraSceneNode* camera = 0; 
	camera = smgr->addCameraSceneNodeFPS(0,80.0f,300.0f,-1, keyMap, 8);
edited: just noticed it's the same as area's but without the arrow keys!! :oops: :oops:
Innocence
Posts: 2
Joined: Sun Jun 26, 2005 8:56 pm
Location: Germany/Hessen

Post by Innocence »

It works great! Thank you very much! :D
RacerD
Posts: 5
Joined: Sun Sep 17, 2006 1:03 pm

Post by RacerD »

sorry about the question:

which value controls the speed of the movement?
or how can i manage the speed of that?
luckymutt
Posts: 453
Joined: Sun Mar 06, 2005 11:56 pm
Location: C-Ville

Post by luckymutt »

from the API:

Code: Select all

ICameraSceneNode* irr::scene::ISceneManager::addCameraSceneNodeFPS 	( 	                 
      parent = 0, 
		f32 	rotateSpeed = 100.0f, 
		f32 	moveSpeed = 500.0f, 
		s32 	id = -1, 
		SKeyMap * 	keyMapArray = 0, 
		s32 	keyMapSize = 0, 
		bool 	noVerticalMovement = false
	) 	
The values shown here are the default values.
Join us in the Irrlicht chatroom:
[url]irc://irc.freenode.net/irrlicht[/url]

I love deadlines. I like the whooshing sound they make as they fly by. -D.Adams
RacerD
Posts: 5
Joined: Sun Sep 17, 2006 1:03 pm

Post by RacerD »

thank you
Post Reply