space movement

hey,

i got a little problem…
i made this spaceship that will have to travel trough space…
since there is no drag in space it has to rotate the ship to fly to another direction.
so if i will turn off the engines and rotate the ship it has to move the same direction on and on.
and if i turn on the engines it has to start moving to that direction… but that piece of scripting is a huge :?: … can anyone help me with that?!

this is what is have.

``````var turnSpeed = 10.0;
var IonEngineaccl = 0.09;
var ImpulseEngineaccl = 0.2;
var maxspeed = 15.0;
var currspeed = 0.0;

private var y : float;
private var x : float;

function Update ()
{
// x is used for the x axis.  set it to zero so it doesn't automatically rotate
x = 0;

// check to see if the W or S key is being pressed.
x = Input.GetAxis("Vertical") * turnSpeed * Time.deltaTime;

// Move the character forwards or backwards
if (toggleParticles.Impulseon) Impulseaccl=ImpulseEngineaccl; else Impulseaccl=0;
if (toggleParticles.Ionon) Ionaccl=IonEngineaccl; else Ionaccl=0;

currspeed=currspeed+(Impulseaccl+Ionaccl) * Time.deltaTime;
if (currspeed > maxspeed) currspeed = maxspeed;
print(currspeed);
transform.Translate(Vector3.right, Space.World);

// Check to see if the A or S key are being pressed
if (Input.GetAxis("Horizontal") * Time.deltaTime * currspeed)
{
// Get the A or S key (-1 or 1)
y = Input.GetAxis("Horizontal") * Time.deltaTime * turnSpeed;
}
// rotate the character based on the x value
transform.Rotate(0, y, 0);
transform.Rotate(0, 0, x);
}
``````

i got this from the WOW camera orbit script.

thnx

Just use the physics engine; that will make things simple.

–Eric

Right. I have modeled space flight fairly easily using the built in physics. Many times, I will bypass the buil-in system because it doesn’t handle some aspects of physics, but modeling space flight is as straight forward as your explanation of what you are trying to accomplish.