Jump to content
  • Advertisement
Sign in to follow this  
Kurt-olsson

Fire velocity and position

This topic is 2293 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 am making a FPS game and have encountered a problem when getting the fire vector and fire startPosition.

if i subtract my viewVector - posVector = the direction from me to center. But i then want to get the point that is in the right corner so my fire goes from corner to center.

how can i do this?

Share this post


Link to post
Share on other sites
Advertisement
What engine/SDK are you using? Some might have dedicated methods for similar things, others not so much. Or you could have a gun object which is connected to your camera with a 3D offset, and just experiment until it looks right. Then shoot from the position of the gun rather than the camera.

Share this post


Link to post
Share on other sites
If you use a gun model, give the model a "muzzle point" (if it doesn't already have one) which is the location the bullet should exit the gun, and transform it into world space upon rendering, that'll give you the correct initial position from which to subtract the target's position to get the fire vector for your physics simulation.

If the point is properly placed and your gun is on-screen it'll look like the bullet came from the gun (since it effectively did) instead of from the center of the camera.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net 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!