Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
FBz
Mar 8, 2004
FatboYgw got me this account for my birthday!
I've decided to dive back into XNA again and mess about with it again, but this time in 3D.

I have a spaceship (one of the models you are given with the SDK) and I have it moving around in 3D space quite well. You point it in any direction (up/down/left/right/back/fourth etc.) and it flies along that vector, I've implemented quat’s for proper rotations and all that jazz. What I'd like to do is add proper acceleration. At the moment it accelerates along the vector until it hits full speed, but when you turn it just flies off in that direction instantly, which doesn't really happen in the real world. What I'd like is smoother turning and acceleration, ie. It flies off in one direction then when you turn somewhere else and hit the thrusters again instead of insta-accelerating it gradually gets into its new vector. I have implemented something that half does this but it's totally wrong as it doesn't work 100% of the time. I've tried looking up how to do this but I am blinded by science and formulas and I am not sure how to implement it at all.

What I have so far is:
A vector in which the ship is currently moving (momentum I guess)
A Vector which the ship is pointing in
Current thrust level (could be zero, leaving the ship to 'float' on it's current vector)

I am guessing I need to go from the momentum vector to the new direction vector based on the amount of thrust, but I don't know how.

If someone can tell me how to implement acceleration or point me to a good tutorial (I've looked at loads but most are either 2D and I can't figure out how to translate that to 3D, or they just ramble on about something quite unhelpful) I'd be most grateful. I think I really need an example or it spelt out in English with little words that I can understand :)

Adbot
ADBOT LOVES YOU

FBz
Mar 8, 2004
FatboYgw got me this account for my birthday!
Thanks fryzoy and TSDK, that worked a treat! Now I need to figure out how to limit the speed, but I think I have an idea on how to do that.

FBz
Mar 8, 2004
FatboYgw got me this account for my birthday!
Just to clarify, is |V| the Length of the Velocity Vector? If so, I think I understand what you're getting at. I'll give this a try when I get home this evening.

What I had before is that I pre-calculated the maximum momentum vector based on my desired maximum speed and prevented the velocity vector from increasing any further when it hit this value, the ship would be travelling in a straight line when it hit this value. I think this was broken (or poorly implemented).

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply