Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ParityCheck

Bullets don't shoot right?

This topic is 5392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working on a simple 3d shooter game program. I have a createBullet class that creates an instance of a cube object which I''m for now using as a bullet, that goes in the direction of where my camera is currently facing. The problem is that my ''bullet'' only shoots in one direction no matter what direction I''m facing it just shoots in one freaking direction (not the direction I''m facing) I''m emulating the shooting by d3dxmatrixtranslate and I''m passign to the bullets shoot method the cameras currentposition and its target position and am incrementing the bullets position using. currentpos.x+=targetpos.x etc But still he keeps ''flying south '' no matter what direction I''m facing. How do I fix it so that my bullet flies in the direction of my camera target. I must be missing something, any suggestions guys

Share this post


Link to post
Share on other sites
Advertisement
Please post the code where you actually build the world matrix for the bullet.

_______________________________________
Understanding is a three edged sword...

Share this post


Link to post
Share on other sites
The following code is the function what actually moves my bullet forward.

D3DXMATRIX matrixTranslateFront, matrixTranslateBack ,matrixMovement;

D3DXMatrixTranslation(&matrixTranslateFront, SourcePos.xPos+=TargetPos.xPos*2, -(SourcePos.yPos+=TargetPos.yPos*2),SourcePos.zPos+=TargetPos.zPos*2);//, i);
D3DXMatrixTranslation(&matrixTranslateBack, -(SourcePos.xPos+=TargetPos.xPos*2), SourcePos.yPos+=TargetPos.yPos*2, SourcePos.zPos+=TargetPos.zPos*2);//, i);
D3DXMatrixMultiply(&matrixMovement,&matrixTranslateFront,&matrixTranslateBack);

lpDevice->SetTransform(D3DTS_WORLD, &matrixMovement);
Bullet->RenderShape();

The variables SourcePos, TargetPos are passed to the object on construction in its constructor. SourcePos is the cameras position and TargetPOs is the cameras view direction.
Do u suppose that the targetPos variable isn''t being properly updated. My camera moves and rotates around perfectly. Just that it shoots in just one direction nomatter where I''m facing.
I coudl be facing south and pushing shoot and he''d still shoot north. What could be the problem ?

Share this post


Link to post
Share on other sites
Please say you don''t really have all those += in your arguments.

I''m not going to take the time to dissect what''s happening to those variables, and what''s being passed to the functions, with that code. I don''t imagine anyone else will either. Perhaps if you cleaned up the code you might spot your bug.

Share this post


Link to post
Share on other sites
Gee I mean actually I only want my bullets position to shift to its target position at each increment, what would be an easier way to do so. I do admit that code is well a ''little'' messy :D but I''d like some suggestions as to how to actually implement a shooting bullet. please

PS. should I mail just my bullet code..

Share this post


Link to post
Share on other sites
quote:

I'm not going to take the time to dissect what's happening to those variables, and what's being passed to the functions, with that code. I don't imagine anyone else will either. Perhaps if you cleaned up the code you might spot your bug.



Agreed, if you want us to debug your code you really need to refactor it into a more understandable format. Also it would help if you would use source tags; you can read about source tags in the FAQ at the upper right corner of the screen. Here is what you code looks like with source tags:


D3DXMATRIX matrixTranslateFront, matrixTranslateBack ,matrixMovement;

D3DXMatrixTranslation(&matrixTranslateFront, SourcePos.xPos+=TargetPos.xPos*2, -(SourcePos.yPos+=TargetPos.yPos*2),SourcePos.zPos+=TargetPos.zPos*2);//, i);

D3DXMatrixTranslation(&matrixTranslateBack, -(SourcePos.xPos+=TargetPos.xPos*2), SourcePos.yPos+=TargetPos.yPos*2, SourcePos.zPos+=TargetPos.zPos*2);//, i);

D3DXMatrixMultiply(&matrixMovement,&matrixTranslateFront,&matrixTranslateBack);

lpDevice->SetTransform(D3DTS_WORLD, &matrixMovement);
Bullet->RenderShape();


_______________________________________
Understanding is a three edged sword...


[edited by - Sean Doherty on November 14, 2003 2:26:26 PM]

Share this post


Link to post
Share on other sites
Ugh just email me, I am not at my home comp., this bullet stuff is babies work. I myself would cast a ray for it. But increment aint so bad. But your collision system will have to account for it, and assuming you can''t get this right, I am sure you dont have a working collisions system.

My camera works off just 2 vectors. A position vector and a normalized sphere rotate vector. So standing at (0,0,0) and looking at (0,1,0) will look up. Then you use your normalized (0,1,0) to create a vel vector for the bullet... which is incremented not by frame but by time... ugh why by frame!? I would run it into Opcode (check google) get a close AABB proximity and then do a sphere-tri collision for an exact point on the remaining. Toss on a decal and then you have a bullet hitting a wall.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
u cocky lil guy. some peepol arent "as smart as u"... damn.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!