Ship trajectories

This topic is 4879 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi guys, I'm working on a StarFox-ish game for my Computer Graphics class. For the main ship, I keep a yaw, pitch, and roll. The ship constantly thrusts forward, and each frame I take the forward vector and multiply it by the appropriate rotation matrices to get it to move in the proper direction. Now let's say I have a second ship. The second ship also has the same basic properties. I want to take the second ship and have it 'track' the main ship in a dog-fight style fashion (ie, it will try to take an intersecting course to get a good shot at the main ship). My initial impulse is to take the first and second ship and calculate a normal given their trajectories and then calculate the angle between them, then gradually rotate the second ship so that it starts to 'chase' after the first. I'm not sure how to implement this solution, though, or even if it's a suitable solution. I was wondering if anyone had any insights, resources, etc, on this problem. Any help would be greatly appreciated. Cheers, --Brian

Share on other sites
First of all, it's a bad idea to maintain a ship's trajectory as roll, pitch, and yaw. This seems like a good idea at first, but becomes extremely unwieldy when you need to progressively change the trajectory. I suggest storing the trajectory as a quaternion.

In any case, if you want the chase plane to try to turn towards the lead plane, first you need to figure out the vector from the chase plane to the lead plane. Then you need to figure out the current "forward" vector of the chase plane. You can use a PD-controller to figure out, based on these two vectors, how hard and in what direction to turn.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 9
• 15
• 14
• Forum Statistics

• Total Topics
634070
• Total Posts
3015333
×