Sign in to follow this  

shooting in 3rd person view

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

Hi Im doing a arcade-airplane game in 3d. I can see the ship in front of me and i can see my crosshair which i move with the mouse (just like in freelancer). When i fire a cannon/missile i want it to travel from the plane to the crosshair. Now, this isnt very simple to do i figured out:) Some thoughts: 1. If something is "under" the crosshair (another plane, a piece of the ground or sea etc) i should get the position of where this is. 2. So i have start and end (plane-position and the found target-position). Now i can create a projectile with the movement-vector that will make it travel towards the target-position. Am i completely off here or is this a smart way to do it? E

Share this post


Link to post
Share on other sites
Hi
It is possible to implement the idea your but the result will be unrealistic. Also there is the obvious question of what happens when you fire and there is nothing under the crosshair.
In reality, if it’s a missile it usually has some sort of homing mechanism, so the crosshair is used for looking the homing mechanism at the target. As for rounds, they never fly in a straight line to begin with (that’s because there are gravity effects and they spin around themselves), so the crosshair and the round overlap only at a specific range from the airplane.
Good luck with game
Doron

Share this post


Link to post
Share on other sites
If I understand you correctly you want to shoot a projectile from your ship's
position to the object under the mouse cursor.
To do this you take the coordinates of the mouse and gluUnproject them
to get back a point in space. Note that you need to supply a z value for
gluUnproject so what you will be getting is a point along the line from your
view position towards the mouse cursor lets call it mousePos.
Then shoot a ray from the camera position with the direction you just got(mousePos-cameraPos) and check which object you hit.
Here having some sore of a bounding shape around your objects would come in handy.

Hope this helps.
EDIT: Oops I accidentally assumed OpenGL but you get the point...

Share this post


Link to post
Share on other sites

This topic is 3662 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this