weapon

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.
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

weapon

Post by jimowns »

hey
now i'm trying to add weapon intro my source code .
i maded a code to see my wapen .
but i add the code and i can see my weapon but not by me .
i 'm trying to make a weapon on my richt side so i can see it .
i add here my code .
but i realy dont know whats wrong in it .
( sorry for my bad english )

here is my own code

Code: Select all

IAnimatedMesh* player_mesh = smgr->getMesh("Guns/AK-47.md2");                             
IAnimatedMeshSceneNode* player_node = smgr->addAnimatedMeshSceneNode( player_mesh );

weapon_mesh->drop(); 
weapon_node->setScale(core::vector3df(0.25,0.25,0.25));
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Don't drop the weapon mesh, you shouldn't do that unless you've called weapon_mesh->grab() and i doubt you'll want to be doing that yet. You can see in IUnknown in the API a little explanation on when to call drop and when not to i think. basically if your object has been created with a createXXX() function call you DON'T drop it, but if it's been created with an addXXX() function call then you DO drop it.

To solve your problem you just have to use weapon_mesh->setPosition(vector3df(x,y,z))

try small values for each of x y and z until you get the gun placed right, basically trial and error!
Image Image Image
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Post by jimowns »

i did what you sayd but its keep dropping it

Code: Select all

IAnimatedMesh* weapon_mesh = smgr->getMesh("3Ddata/Guns/AK-47.md2");               
IAnimatedMeshSceneNode* weapon_node = smgr->addAnimatedMeshSceneNode(weapon_mesh); 

weapon_mesh->grab(); 
weapon_mesh->setPosition(core::vector3df(50,20,80));
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

grab() does not mean your player will physically grab the weapon. You are also setting the position of the mesh, you must set the position of the node.

IAnimatedMesh* weapon_mesh = smgr->getMesh("3Ddata/Guns/AK-47.md2");
IAnimatedMeshSceneNode* weapon_node = smgr->addAnimatedMeshSceneNode(weapon_mesh);

weapon_node->setParent(player_node);
weapon_node->setPosition(core::vector3df(*,*,*));
// * = your own values
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah that's my bad about telling you to set the position of the mesh! I wasn't thinking much whilst typing! But yeah you don't want to be calling grab i shouldn't think, there are times when you would want to but this isnt one of them and i guess in time you'll learn when you would need to, generally you just dont need to so just forget about it for now ;)
Image Image Image
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Post by jimowns »

i tryd what zeno60 syad and its not working .

i testing other codes but i can't find it whats the probelm is .

Code: Select all

IAnimatedMesh* player_mesh = smgr->getMesh("3Ddata/Guns/test.md2");
IAnimatedMeshSceneNode* player_node = smgr->addAnimatedMeshSceneNode( player_mesh ); 

IAnimatedMesh* weapon_mesh = smgr->getMesh("3Ddata/Guns/weapon2.md2"); 
IAnimatedMeshSceneNode* weapon_node = smgr->addAnimatedMeshSceneNode(weapon_mesh); 

weapon_node->setParent(player_node); 
weapon_node->setPosition(core::vector3df(-200,-150,-150)); 
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

What's the problem you're having? the gun's not lining up with the player properly? Have you tried varying the position you set the gun to?
Image Image Image
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Post by jimowns »

if a looks on the ground i see my weapon on the grond .
but if i move my weapon dont moving .
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Post by jimowns »

please can someone help me .
i try that code and its keep dropping my gun .
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Are you trying to attach the gun to the player_node or to the camera? (Hint: I told you how to attach it to the player_node, you should be able to figure out, if you wanted to, how to attach it to the camera)

Use the search link on the forums and try searching for "attach and gun and camera."
Last edited by zeno60 on Tue Dec 19, 2006 5:05 pm, edited 1 time in total.
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Post by jimowns »

normaly i'm trying to get my gun on my richt side of my screen .
like counter strike and more schooter games.
blendermen
Posts: 14
Joined: Sat Mar 11, 2006 11:11 am

Post by blendermen »

If somebody has problem with that:

http://irrwizard.sourceforge.net/wiki/i ... g_a_weapon


black on white
Irrlicht is really simple - just try !!
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Post by jimowns »

its giveing me so many errors

Code: Select all

------ Build started: Project: Project1, Configuration: Debug Win32 ------
Compiling...
game.cpp
.\game.cpp(89) : error C2065: 'pManager' : undeclared identifier
.\game.cpp(89) : error C2227: left of '->getDevice' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(89) : error C2227: left of '->getSceneManager' must point to class/struct/union/generic type
.\game.cpp(89) : error C2227: left of '->getMesh' must point to class/struct/union/generic type
.\game.cpp(90) : error C2227: left of '->getDevice' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(90) : error C2227: left of '->getSceneManager' must point to class/struct/union/generic type
.\game.cpp(90) : error C2227: left of '->addAnimatedMeshSceneNode' must point to class/struct/union/generic type
.\game.cpp(90) : error C2227: left of '->getSceneManager' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(90) : error C2227: left of '->getActiveCamera' must point to class/struct/union/generic type
.\game.cpp(93) : error C2227: left of '->getDevice' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(94) : error C2227: left of '->getVideoDriver' must point to class/struct/union/generic type
.\game.cpp(94) : error C2227: left of '->getTexture' must point to class/struct/union/generic type
.\game.cpp(98) : error C2227: left of '->getSceneManager' must point to class/struct/union/generic type
        type is ''unknown-type''
.\game.cpp(98) : error C2227: left of '->getActiveCamera' must point to class/struct/union/generic type
Build log was saved at "file://c:\Documents and Settings\Eigenaar\Bureaublad\Counter strike 9.0 my game\Project1\Debug\BuildLog.htm"
Project1 - 14 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

You cannot copy and paste that code into your own project and expect it to work without knowing what it does, you really need to take some C++ lessons, these are all basic C++ problems you are facing.
jimowns
Posts: 62
Joined: Thu Sep 28, 2006 5:28 pm
Location: X-Gamers

Post by jimowns »

i only can programming in Console , this is my first 1 week in irrlicht .
but is there not a tutorial for irrlicht ?
Post Reply