How to attach a waepon.

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
alfabeta90
Posts: 52
Joined: Wed Dec 06, 2006 5:18 pm

How to attach a waepon.

Post 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.
Last edited by alfabeta90 on Sat Mar 24, 2007 4:49 pm, edited 1 time in total.
Frodenius
Posts: 64
Joined: Sun Aug 29, 2004 11:24 am
Location: Germany/Frankfurt
Contact:

Post by Frodenius »

worst programming style ever seen...
alfabeta90
Posts: 52
Joined: Wed Dec 06, 2006 5:18 pm

Post by alfabeta90 »

Hahaha, funny. I wrote: 'waepon' and they come nothing.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

maybe because it's spelled weapon ??? ;)
try: weapon AND attach
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
alfabeta90
Posts: 52
Joined: Wed Dec 06, 2006 5:18 pm

Post by alfabeta90 »

Ehh, right. :wink:
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

Since everybody is so strict about spelling, i feel like pointing out that weapons are usually not attached to ftp's ;)
If you don't have anything nice to say, don't say anything at all.
liger13
Posts: 119
Joined: Tue Jul 18, 2006 4:17 am

Post 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 ;)
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

right, I don't care about right spelling, but the search function does :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
paradox
Posts: 5
Joined: Fri Mar 23, 2007 8:24 pm

Post by paradox »

Oh and Programming requires good spelling too... :lol:
alfabeta90
Posts: 52
Joined: Wed Dec 06, 2006 5:18 pm

Post 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; 
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post 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...
liger13
Posts: 119
Joined: Tue Jul 18, 2006 4:17 am

Post 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.
alfabeta90
Posts: 52
Joined: Wed Dec 06, 2006 5:18 pm

Post 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;
Post Reply