• Advertisement
Sign in to follow this  

Firing a bullet in the right diection and angle.

This topic is 3396 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

How do I get my bullets to move in the same direction and angle I am facing? I have tried several things but nothing works. I really don't know much about trig or algebra. I tried incorperating the same thing as I did in my passivemotion function to move/rotate the camera but that didn't work either. Much Thanks L.J.Bush

Share this post


Link to post
Share on other sites
Advertisement
Have a position vector and a direction vector.

currentBulletLocation = vector(0,0,0);
//bulletDirection is a unit vector +1 on the z-axis
bulletDirection = vector(0,0,1);


//every frame, do this:
currentBulletLocation += bulletDirection;

Share this post


Link to post
Share on other sites
a little add-on

if (fireBulletButtonKeyPressed)
{

//angleThatImFacing is a vector
//currentPositionThatImAt is a vector
currentBulletLocation = currentPositionThatImAt
bulletDirection = angleThatImFacing;

}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement