How to attach a waepon.
Posted: Sat Mar 24, 2007 2:20 pm
With function of irrlicht engine attach a object(model) into camera(fps). I want to attach a waepon to camera likes most fps.
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Code: Select all
SKeyMap keyMap[4];
if(keyMap[0].KeyCode = KEY_KEY_W)
{
keyMap[0].Action = EKA_MOVE_FORWARD;
sound->play2D("pl_step4.wav");
}
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;
Code: Select all
if(keyMap[0].KeyCode = KEY_KEY_W)
{
keyMap[0].Action = EKA_MOVE_FORWARD;
sound->play2D("pl_step4.wav");
}
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT &&
event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
sound->play2D("pl_step4.wav");
return true;
}
}
return false;
}
};
Code: Select all
ICameraSceneNode wezelKamery = oknoGry.SceneManager.AddCameraSceneNodeFPS(null, 100, 300, 0);
wezelKamery.Position = new Vector3D(1000, 1000, 500);
wezelKamery.Rotation = new Vector3D(0, 180, 0);
ICameraSceneNode weapon = oknoGry.SceneManager.AddMeshSceneNode("weapon.x", wezelKamery, 1);
wezelKamery.AddChild(weapon);
oknoGry.CursorControl.Visible = false;