Adding Weapons to a camera, and hud to game
Adding Weapons to a camera, and hud to game
Ok I have this little FPS and you are just a camera. I want to know how to attach a weapon or a child mesh to that camera also how to rotate or cycle through several guns by pressing the 1 key 2 key and so on. Also how to create impact on a enemy mesh and after say 3 shots they die.
Maybe also how to add weapons to enemys.
Also with a Hud I have read the 2d sprite tutorial and have tried to insert a image into my game but failed... I got the image in but then the 3d game was frozenn...
Sorry I know this is a lot to ask I don't really want you to write my code just point me in the right directions maybe some examples. And documentation referances
Thanks for all your help
Maybe also how to add weapons to enemys.
Also with a Hud I have read the 2d sprite tutorial and have tried to insert a image into my game but failed... I got the image in but then the 3d game was frozenn...
Sorry I know this is a lot to ask I don't really want you to write my code just point me in the right directions maybe some examples. And documentation referances
Thanks for all your help
Programming Blog: http://www.uberwolf.com
Re: Adding Weapons to a camera, and hud to game
Make a node a child of the camera, with a gun mesh. Stick it a little in front of the camera.dejai wrote:Ok I have this little FPS and you are just a camera. I want to know how to attach a weapon or a child mesh to that camera also how to rotate or cycle through several guns by pressing the 1 key 2 key and so on. Also how to create impact on a enemy mesh and after say 3 shots they die.
Maybe also how to add weapons to enemys.
Also with a Hud I have read the 2d sprite tutorial and have tried to insert a image into my game but failed... I got the image in but then the 3d game was frozenn...
Sorry I know this is a lot to ask I don't really want you to write my code just point me in the right directions maybe some examples. And documentation referances
Thanks for all your help
Use setVisible on your weapon nodes to change weapons.
Give your enemy mesh a health variable. Cast a line from the camera and if that line hits your enemy mesh reduce its health. When its health is 0 use some sort of kill function. You can just use setVisible again for a start.
Easiest way would be to include their weapon in the mesh and animate it. Give them some AI to decide when to fire and cast a line and see if it intersects with the player.
Did you draw your scene manager every frame? This should be in your main loop:
smgr->drawAll();
guienv->drawAll();
-
- Posts: 199
- Joined: Wed Nov 29, 2006 4:07 am
-
- Posts: 10
- Joined: Wed Jul 11, 2007 11:03 am
- Location: UK
I want to do this as well. Here's the code I've got so far:
As you can see, I've commented out the scale because I haven't had the mesh even displayed yet. I don't know about the position, either.
Code: Select all
scene::IAnimatedMesh* gunmesh = smgr->getMesh("gun.3ds");
scene::ISceneNode* gunnode = 0;
.........
if(gunmesh)
{
gunnode = smgr->addAnimatedMeshSceneNode(gunmesh, gunnode);
camera->addChild(gunnode);
gunnode->setPosition(vector3df(0, 0, 0));
//gunnode->setScale(vector3df(1, 1, 1));
}
I created this FaceTarget() function specifically for fixing my HUD icons in front of the camera. Just call FaceTarget( pCam->getTarget() )
-
- Posts: 10
- Joined: Wed Jul 11, 2007 11:03 am
- Location: UK
-
- Posts: 10
- Joined: Wed Jul 11, 2007 11:03 am
- Location: UK
I'm not sure what you mean. Does the gun not stay fixed in front of the camera? I don't have a gun in my app, but I do have a compass and it stays put.although that code is great for HUDs, it isn't so hot when it comes to adding a 3D gun to the camera
Of course, you do have more bob's in your moniker, so you have me beat there.
-
- Posts: 199
- Joined: Wed Nov 29, 2006 4:07 am
-
- Posts: 10
- Joined: Wed Jul 11, 2007 11:03 am
- Location: UK
-
- Posts: 10
- Joined: Wed Jul 11, 2007 11:03 am
- Location: UK