shooting in 3rd person view

Started by
1 comment, last by CableGuy 16 years, 4 months ago
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
Advertisement
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
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...

This topic is closed to new replies.

Advertisement