x


Rotation Force on a model

How would you rotate a plane? I'm trying to use rigidbody.AddTorque, but I want it to work for turning left and right.

var turnSpeed = 5.0;

function FixedUpdate() {
    if (Input.GetButtonDown("Horizontal")){
        rigidbody.AddTorque(transform.left * turnspeed);
    }

Is there a way to make it work both directions? Horizontal won't work with only "transform.left"; it has to go right as well when needed.

more ▼

asked Dec 15 '10 at 01:49 AM

Mentalist4006 gravatar image

Mentalist4006
150 20 20 29

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Use horizontal as an axis.

var turnSpeed = 5.0;

function FixedUpdate() {

  rigidbody.AddTorque(transform.left * turnspeed * Input.GetAxis("Horizontal"));
  //Will multiply the result times 1 if right key is pressed all the way to -1 for left arrow based on pressure.

}

more ▼

answered Dec 15 '10 at 01:53 AM

Peter G gravatar image

Peter G
17.3k 22 51 149

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2716
x1887
x1051
x420
x77

asked: Dec 15 '10 at 01:49 AM

Seen: 3989 times

Last Updated: Dec 15 '10 at 01:49 AM