KeyMapping doesn't work! in Irrlicht 1.4

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
konrad
Posts: 15
Joined: Wed Oct 03, 2007 7:07 pm
Location: Poland

KeyMapping doesn't work! in Irrlicht 1.4

Post by konrad »

Why the KeyMapping doesn't work? :(

Code: Select all

//! Class Player  -------------------------------------------
class CPlayer
{
private:
   // KeyArrays
   SKeyMap keyMap[5];
   keyMap[0].Action=EKA_MOVE_FORWARD;     keyMap[0].KeyCode=KEY_KEY_W;
   keyMap[1].Action=EKA_MOVE_BACKWARD;    keyMap[1].KeyCode=KEY_KEY_S;
   keyMap[2].Action=EKA_STRAFE_LEFT;      keyMap[2].KeyCode=KEY_KEY_A;
   keyMap[3].Action=EKA_STRAFE_RIGHT;     keyMap[3].KeyCode=KEY_KEY_D;
   keyMap[4].Action=EKA_JUMP_UP;          keyMap[4].KeyCode=KEY_SPACE;
public:
   // Node Create
   scene::ICameraSceneNode* Node;
   scene::ISceneNodeAnimator* Anim;
   // Object Create
   CPlayer(unsigned _id,string _name,core::vector3df _pos,float _rotspd,float _movspd,float _jumpspd)
   {
      Node=smgr->addCameraSceneNodeFPS(0,_rotspd,_movspd,_id,keyMap,5,true,_jumpspd);
      Node->setPosition(_pos);
      Node->setName(_name.c_str());
   }
   // Add Collision to Scene
   int addCollision(scene::ITriangleSelector* _world,core::vector3df _elipse,core::vector3df _elipse2,float _gravity)
   {
      Anim=smgr->createCollisionResponseAnimator(_world,Node,
               _elipse,
               core::vector3df(0,_gravity,0),
               _elipse2);
      Node->addAnimator(Anim);
      Anim->drop();
   }
};
I using irrlicht 1.4 :)
Thanks for any helps ;p
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Hi,

Could you try putting the assignation of the variable inside CPLAYER?
I'm not used to assign values inside a variable definition (PRIVATE). I don't know if it's ok.

But I've used the keymaps and compiled with 1.4 and it worked.
I'm used to declare the content in a function like below.

Like this

Code: Select all

//! Class Player  ------------------------------------------- 
class CPlayer 
{ 
private: 
   // KeyArrays 
   SKeyMap keyMap[5]; 
  public: 
   // Node Create 
   scene::ICameraSceneNode* Node; 
   scene::ISceneNodeAnimator* Anim; 
   // Object Create 
   CPlayer(unsigned _id,string _name,core::vector3df _pos,float _rotspd,float _movspd,float _jumpspd) 
   { 
      keyMap[0].Action=EKA_MOVE_FORWARD;     keyMap[0].KeyCode=KEY_KEY_W; 
      keyMap[1].Action=EKA_MOVE_BACKWARD;    keyMap[1].KeyCode=KEY_KEY_S; 
      keyMap[2].Action=EKA_STRAFE_LEFT;      keyMap[2].KeyCode=KEY_KEY_A; 
      keyMap[3].Action=EKA_STRAFE_RIGHT;     keyMap[3].KeyCode=KEY_KEY_D; 
      keyMap[4].Action=EKA_JUMP_UP;          keyMap[4].KeyCode=KEY_SPACE; 
      Node=smgr->addCameraSceneNodeFPS(0,_rotspd,_movspd,_id,keyMap,5,true,_jumpspd); 
      Node->setPosition(_pos); 
      Node->setName(_name.c_str()); 
   } 
   // Add Collision to Scene 
   int addCollision(scene::ITriangleSelector* _world,core::vector3df _elipse,core::vector3df _elipse2,float _gravity) 
   { 
      Anim=smgr->createCollisionResponseAnimator(_world,Node, 
               _elipse, 
               core::vector3df(0,_gravity,0), 
               _elipse2); 
      Node->addAnimator(Anim); 
      Anim->drop(); 
   } 
};
konrad
Posts: 15
Joined: Wed Oct 03, 2007 7:07 pm
Location: Poland

Post by konrad »

Thanks for fast reply and help for me ;p
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I don't have a compiler handy, so I was wondering: did your original code even compile?
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