Physically correct spaceship movement that is not a pain in the as.... tronaut?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Physically correct spaceship movement that is not a pain in the as.... tronaut?

      Hello everyone,

      i am always confused where to put my threads here, so i am trying it here this time ;)

      Again, i am working on some physic simulation stuff and i somehow cant figure this problem out...

      Basically what i am trying to do is to create the controls for a spaceship flown by the player. Since all the flying stuff is controlled by the physic part of the engine i want to do this "physically" correct.

      I started by implementing the most basic stuff, moving forwards, backwards and strafing. Those are easy to do, i just have to get the "look" vector (its the direction the object is facing) of the object i want to steer and move it back and forth or i have to get the cross product of the look vector and the up vector to get a vector on which i can move it sideways.

      Rotation around the look vector (i think its called rolling :) ) is easy, too. There are two ways to do this:

      - Apply torque to the whole object so it rotates.
      - Apply a force somewhere above the object and the same force in the opposite direction below the object to get a rotation (Take a look at the attachment to hopefully understand what i tried to describe!). I prefer this approach because its more like the "i have mini thrusters to do fancy stuff (rotating) in space" thing that modern spacecraft tend to use.

      And now here is my problem: The last part i need is a convenient way to control the flight direction. It is more or less easy to apply the same concept for rotation around the look vector to make it possible to change the viewing direction. I take the mouse position and calculate the distance from the center in both 2dimensional axis to get a direction where to move to and apply a force to the look vector of my object to get it to "look" to the right direction.
      This works great, i can turn and spin around like crazy but i cant smoothly fly around. If i start into on direction and then turn the ship it continues to move in the old direction.
      I know this is like it would happen in space, als long as there is no other force i would continue the movement. But this is not the steering behaviour we want to have. We want something that doesnt break the whole idea of simulated physic by using forces to interact with objects but makes it possible to change the flight direction... There has to be a way... I hope... Well at least i hope someone understands what i just wrote and what my problem ist ;)
      Files
    • You could use impulses, you would keep track of your own force variable (velocity), and add this as an impulse to the current look velocity, impulses are different than forces in that they are a large amount of energy applied in a very short amount of time, in physics engines it is almost always an instantaneous change.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Your goals are somewhat at odds with each other. You're not going to get a realistic space sim while trying to apply atmospheric properties. The reason a jet can be gliding forward with no thrust and turn right is because it's catching the air, which pushes to the side. Is that what you want? If so, I would look at modeling an aircraft flying in an atmosphere without gravity. Most space sims seem to do something like that.

      -Rez
    • Yeah thats kind of what I was thinking, this is more of a Star Fox like physics.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Thats what we are saying though, either you want space like movement, which has negligible drag , or you want atmospheric like movement which has a great deal of drag.

      When it comes down to it though the only difference is the drag, in space you spin freely, and add force in relation to your propulsion direction, which will change your velocity vector gradually to eventually point in the direction you are firing in.

      If that same space ship was to be in a high drag environment, like say a dense nebula, the gases that its profile collide with would exert drag and exaggerate its turning and quickly alter its heading.

      Remember one thing though, these are games, and sometimes you may not desire to have realistic physics to make a game fun, for instance star fox which uses atmospheric physics in space, would have been a struggle to play if you had to deal with realistic dragless movement.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Well, i just wanted it to be physically correct :) But if physically correct means less fun, then screw physics ;) I will try that solution and see if it works like intended.

      It is interesting how you sometimes have a blind spot on things... I have already programmed a simple "flight simulator" and it included drag... I never thought of it being the relevant part, but once you think about it, it becomes clear :)