Page 1 of 1

How to attach a waepon.

Posted: Sat Mar 24, 2007 2:20 pm
by alfabeta90
With function of irrlicht engine attach a object(model) into camera(fps). I want to attach a waepon to camera likes most fps.

Posted: Sat Mar 24, 2007 3:01 pm
by Frodenius

Posted: Sat Mar 24, 2007 3:09 pm
by alfabeta90
Hahaha, funny. I wrote: 'waepon' and they come nothing.

Posted: Sat Mar 24, 2007 4:12 pm
by Acki
maybe because it's spelled weapon ??? ;)
try: weapon AND attach

Posted: Sat Mar 24, 2007 4:32 pm
by alfabeta90
Ehh, right. :wink:

Posted: Sat Mar 24, 2007 4:48 pm
by Luben
Since everybody is so strict about spelling, i feel like pointing out that weapons are usually not attached to ftp's ;)

Posted: Sat Mar 24, 2007 6:24 pm
by liger13
its not that people are strict about spelling its just that the search engine wont work w/ weapon misspeled :)

http://irrlicht.sourceforge.net/phpBB2/ ... ght=weapon

if you cant find it ;)

Posted: Sat Mar 24, 2007 7:51 pm
by Acki
right, I don't care about right spelling, but the search function does :lol:

Posted: Mon Mar 26, 2007 10:39 am
by paradox
Oh and Programming requires good spelling too... :lol:

Posted: Mon Mar 26, 2007 4:00 pm
by alfabeta90
One more question:

Why doesn't this code work propably? It's start's a sound when key W is pressed. PS. Do u know a cool footsteps sound?

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; 

Posted: Mon Mar 26, 2007 5:22 pm
by xDan
Because you haven't gone through the tutorials!!

Code: Select all

              if(keyMap[0].KeyCode = KEY_KEY_W)
             {
                keyMap[0].Action = EKA_MOVE_FORWARD;
                sound->play2D("pl_step4.wav");
             }
Scrap that if statement, and go and look in the tutorials for how to create an event receiver.

Then on the input event you will play the sound.

EDIT: something like

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;
	}
};
but for a proper footstep sound you should play it looped, starting on a move event and stopping when they are stationary.

Actually you don't even need an event receiver, you could just in your main loop, store the last position, and then if the current position is different, you are moving and may start the sound (if it's not already playing), otherwise stop the sound...

Posted: Mon Mar 26, 2007 9:04 pm
by liger13
although that could make the gameLoop rather large and slow if you had to check through every player or human class if you had to many. You could create a character class that, with other things, checks the possition and stuff like xDan said.

Posted: Mon May 14, 2007 4:44 pm
by alfabeta90
Can you check of this code is good?

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;