Hi
I'm creating my fps... now, i'm writing the shot part.
I've an FPS camera and a child shotgun attach to it. I should to calculate the line for the staight animator (bullet's trajectory). When I select as start point the camera position, all work correctly and irrlicht create bullet at same position of camera. but... if I select as start point the shotgun position... irrlicht create the bullet at position 0,0,0... WHYYYYYY (I've controlled the position of shotgun many times and it is NOT 0,0,0 )
Shotgun is a child of camera, and it's position not would have to be approximately the same position of camera?
Plese help me and excuse my bad english
Argh!
Argh!
The best italian GM related site
www.gamemaker.it
www.gamemaker.it
-
- Posts: 92
- Joined: Sat Nov 29, 2003 8:30 pm
- Contact:
Instead of:
try using:
Code: Select all
yourShotGunNode->getPosition ();
Code: Select all
yourShotGunNode->getAbsolutePosition ();
Using "getAbsolutePosition()" problem is partially resolved... now, irrlicht create bullet at same position of my shotgun... but the bullet dosen't fly in correct direction. I use this code:
I think that code is correct but the bullet have a strange trajectory... can anyone help me?
Code: Select all
if (shotgun != 0 && event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
if (ok == 1) {
if (ammo > 0) {
vector3df start = (shotgun->getAbsolutePosition());
vector3df end = (camera->getTarget()-start);
end.normalize();
end = start + (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();
}
}
}
return true;
The best italian GM related site
www.gamemaker.it
www.gamemaker.it
Nobody can help me?
Then... exists some tutorial that explains how to make?
Thanks
Then... exists some tutorial that explains how to make?
Thanks
The best italian GM related site
www.gamemaker.it
www.gamemaker.it
Bullets leaving from the right place
Man I solved this problem this way:
Code: Select all
vector3df start = gun->getAbsolutePosition();
float xModulus = camera->getTarget().X - camera->getPosition().X;
float yModulus = camera->getTarget().Y - camera->getPosition().Y;
float zModulus = camera->getTarget().Z - camera->getPosition().Z;
vector3df gunTarget = vector3df(gun->getAbsolutePosition().X + xModulus,
gun->getAbsolutePosition().Y + yModulus,
gun->getAbsolutePosition().Z + zModulus);
vector3df end = (gunTarget - start);
end.normalize();
end = start + (end * camera->getFarValue());
I ignore the camera in my shooting code, after all I might not always want to shoot where the camera is pointing and I consider it bad form to depend on the camera. Get the transformation matrix of the shotgun. You can create a target vector like this
vector3df(targetDist,0,0) targetVec;
matrix.transformVect(targetVec);
Assuming the x axis is the front of the shotgun (plenty use Z instead) and that the variably matrix holds the absolute transformation of the shotgun. You can now create a line with the shotgun position at one endpt and the transformed targetVec at the other endpt.
vector3df(targetDist,0,0) targetVec;
matrix.transformVect(targetVec);
Assuming the x axis is the front of the shotgun (plenty use Z instead) and that the variably matrix holds the absolute transformation of the shotgun. You can now create a line with the shotgun position at one endpt and the transformed targetVec at the other endpt.
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