Advertisement Jump to content
Sign in to follow this  

3d - projectile from point A to point B

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

Hello - In my 3D game, I want to fire a projectile (a slow-moving ball of energy) from a ship sitting at Vector A, and I want it to travel a distance of D units, then stop (explode). For direction, I know the Yaw and Pitch of the ship, expressed in degrees. No gravity, no outside forces, just a straight line through 3D space. I thought that I knew enough about vector math to handle this, but I am having trouble. Can someone help get me on track? Thanks in advance!

Share this post

Link to post
Share on other sites
If the ship only yaws (about the world up axis) and pitches (about the local side axis) you can use spherical coordinates to find the direction vector. There are different ways to do the spherical-to-cartesian conversion depending on which axis is up and which is forward, and which direction the side vector points. So don't expect equations you find online to necessarily work as is; you may have to adapt them to your needs.

Alternately, you could do it with Euler angles. Create a matrix for yaw around world up and a matrix for pitch around the world side vector. Then, if you're using column vectors:

M = yaw * pitch;

Row vectors:

M = pitch * yaw;

The forward vector can then be extracted from M. Plus, you have the rotation matrix available for other purposes if you need it.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!