use of Torque

Hi,

Still working on my spaceship game, I solved the rotation on z axis problem so now I’m working on movement.

The old one was, well, old.

var forwardSpeed= 20; 

if (Input.GetKey (KeyCode.W)) {
transform.position += transform.forward * forwardSpeed * Time.deltaTime;
}

What I would like is to use Torque to make the forward/backward smoother. It uses acceleration.
Does anyone know how to use that in a simple way here?

thanks,

As far as I know, torque measures how hard something is rotated about an axis. How do you intend to use it for smoother acceleration for a space ship? If smooth acceleration is your goal, there are a lot of ways to do that – but if you want to use torque for it, can you elaborate on how you envision it working?

Do you mean “force”?

In the FixedUpdate method, you could use something like:-

if (Input.GetKey (KeyCode.W)) { 
    rigidbody.AddForce(transform.forward * forwardThrustForce); 
}

Thanks for the responses.

Here’s what I have now:

var forwardThrustForce= 10;

function Start () {    
    initialRot = transform.rotation; 
} 

function Update() { 

   Debug.Log(Input.GetAxis ("Mouse X")*-5); 
   if(Input.GetAxis("Mouse X") != 0) { 
		transform.Rotate(0, 0 , Input.GetAxis ("Mouse X")*-5, Space.Self);
   } 
   
	Debug.Log(Input.GetAxis ("Mouse Y")*-5); 
	if(Input.GetAxis("Mouse Y") != 0) { 
		transform.Rotate (Input.GetAxis ("Mouse Y")*-5, 0 , 0, Space.Self);
	} 
   
if (Input.GetKey (KeyCode.W)) {
//transform.position += transform.forward * forwardThrustForce * Time.deltaTime;
rigidbody.AddForce(transform.forward * forwardThrustForce); 
}

if (Input.GetKey (KeyCode.S)) {
rigidbody.AddForce(transform.forward * -forwardThrustForce); 
}
    
}

This however is making it more difficult. If you go forward, steering isn’t really helping and I can’t add the Space.Self to it. So now your almost throwing a stone.

I’d like for my plane to have a standard speed of 10, and if you press forward (W) it should build up to 30, if you press backward (S) it should slow down to 5. And then I have to find a way that the mouse regains control over the direction the plane is heading.

Maybe there’s another way to make a smooth buildup of speed which doesn’t use rigidbody stuff? But then I have to give the mouse a sensitivity so that you can’t make a quick “180”

Thanks,

The axis settings in the Input manager (menu Edit > Project Settings > Input) have two values called sensitivity and gravity. The first controls the speed at which the axis builds up to its maximum value and the second controls how quickly it falls back to the zero/neutral position. You can probably get the effect you want by setting a slower speed for sensitivity and gravity on your inputs.