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, 2010 at 01:49 AM

Mentalist4006 gravatar image

Mentalist4006
150 53 42 52

(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, 2010 at 01:53 AM

Peter G gravatar image

Peter G
17.8k 33 66 176

(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:

x3161
x2220
x1180
x481
x92

asked: Dec 15, 2010 at 01:49 AM

Seen: 5179 times

Last Updated: Dec 15, 2010 at 01:49 AM