x


How to turn a tank?

I have made a sript which allows u to drive a tank. I used the wheelcolliders and the motortorque, however I have a problem: I don't Know how to rotate it. I only know that if a tank wans to turn left or right he has to turn forward the wheels on the left, while turns back the wheels on the right. I have a problem however: it doesn't turn on his pivot axes, but it goes a little forward and backward. Please, help

 var fwdDrive = Input.GetAxis("Vertical")*power;
 var h = Input.GetAxis("Horizontal")*maxSteer;

     for (var i = 0; i < 5; i++)

        wheelColliders[i].motorTorque = h+fwdDrive;



     for (i = 5; i < 10; i++)

        wheelColliders[i].motorTorque = -h+fwdDrive;

obviously it's in the fixedupdate function

more ▼

asked Dec 12 '11 at 05:25 PM

anwe gravatar image

anwe
114 31 34 38

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

1 answer: sort voted first

This code seems ok for me: you apply the common drive torque added to a differential torque to each side according to the steer control.
Compared to a car, a thank has low sideways friction relative to its huge mass. Maybe you should reduce the sidewaysFriction.stiffness to a low value, 0.2 or 0.3, to ease the tank rotation.

more ▼

answered Dec 12 '11 at 09:16 PM

aldonaletto gravatar image

aldonaletto
41.6k 16 42 197

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

x5099
x1964
x101
x60
x55

asked: Dec 12 '11 at 05:25 PM

Seen: 736 times

Last Updated: Dec 12 '11 at 09:17 PM