Hi
I've a serious problem with the shoot part of my game (an FPS).
I don't know how to create a shoot system... that works correctly...
I've tryed many many many many many times, but my code works not correctly ç_ç
How can I create a shoot system (serious and professional) for my FPS?
Please HELP ME
Shooting in an FPS
Shooting in an FPS
The best italian GM related site
www.gamemaker.it
www.gamemaker.it
I think a good idea would be to create a weapon class, and all the weapons you have would just be instances of this class.
So, in each you'd have a shoot function which could find if there has been an hit (with getSceneNodeFromScreenCoordinatesBB(), or if a different weapon type, eg. rocket launcher, check if the target is within the radius for splash damage) and return a pointer to the target node if there was a hit.
So, in each you'd have a shoot function which could find if there has been an hit (with getSceneNodeFromScreenCoordinatesBB(), or if a different weapon type, eg. rocket launcher, check if the target is within the radius for splash damage) and return a pointer to the target node if there was a hit.
"The reputation of a thousand years may be determined by the conduct of one hour."
-Japanese Proverb
-Japanese Proverb
Argh... my english is too bad
The problem is not to check the collision between the bullet and target...
I don't know how to shoot! I would create the bullet node at same position of model of my shotgun, and how to move the bullet in same direction of cane of the shotgun...
Thx
The problem is not to check the collision between the bullet and target...
I don't know how to shoot! I would create the bullet node at same position of model of my shotgun, and how to move the bullet in same direction of cane of the shotgun...
Thx
The best italian GM related site
www.gamemaker.it
www.gamemaker.it
I've used this code... but don't work correcly...
Can anyone post a better code? I would want to obtain the same effect of a commercial FPS...
Code: Select all
vector3df start = (camera->getPosition());
vector3df end = camera->getTarget() - start;
start = shotgun->getAbsolutePosition();
end.normalize();
end = end * camera->getFarValue();
IAnimatedMesh* mesh_bullet = smgr->getMesh("bullet.3ds");
IAnimatedMeshSceneNode* bullet = smgr->addAnimatedMeshSceneNode( mesh_bullet, 0, -1, shotgun->getAbsolutePosition() );
bullet->setMaterialTexture(0, driver->getTexture("texture_bullet.bmp"));
bullet->setMaterialType(EMT_SPHERE_MAP);
bullet->setMaterialFlag(EMF_LIGHTING, true);
ISceneNodeAnimator* anim = 0;
anim = smgr->createFlyStraightAnimator(start, end, 5000, false);
bullet->addAnimator(anim);
anim->drop();
The best italian GM related site
www.gamemaker.it
www.gamemaker.it
your problem seems kind of related to mine http://irrlicht.sourceforge.net/phpBB2/ ... php?t=3268
because the bullet in techdemo has as start point the camera not the weapon model... and if i set as start point the shotgun, code don't work correctly
The best italian GM related site
www.gamemaker.it
www.gamemaker.it
This took me a while to get right because of my poor matrix knowledge. Here's what you need to do. Node is the node of your weapon. Range is the maximum distance your weapon will fire
Now you can feed ray to the getSceneNodeFromRayBB function.
Make sure that you've done jox's fixe for the matrix4::operator*
Code: Select all
matrix4 mat=node->getAbsoluteTransformation();
vector3df vec=mat.getTranslation();
matrix4 targetmat;
targetmat.setTranslation(vector3df(range,0,0));
targetmat= mat * targetmat;
line3d<f32> ray(vec, targetmat.getTranslation()); /*set one point to the position of the weapon, the other to the X axis
note that the line is the maximum length that the weapon can shoot*/
Make sure that you've done jox's fixe for the matrix4::operator*
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars