x


Suspension arm

I hate 3dsMax, It screws up the pivots of objects and makes using them really difficult,

This should be easy to do but I can't for the life of me figure it out, Hope someone can help.

My Car has a suspension arm which is attached to the wheel, I want to make the suspension arm travel up and down when the wheel bounces up and down.

I figured the way to do this is to put the pivot in the right place on the suspension arm, and then use a "look at" using the target as the wheel's transform.

However, doing this, when the car goes up or down a slope, the object appears to "twist" - I figure I need to lock one of the axis's of the look at - and here's the question:

When I use LookAt - the object appears to completely disregard it's children status, (it doesn't add the cars heading or tilt to the look at equation.)

Is there another method I should use, I want a subject object suspension arm to move it's pivot up and down based on the height of an attached wheel - but thats it, no fancy rotations or anything like that, just bounce up and down...

more ▼

asked Aug 26 '11 at 04:18 PM

Cjones110 gravatar image

Cjones110
1 2 2 2

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

1 answer: sort voted first

You can use LookAt, but you must specify the second parameter, worldUp. It's a vector that defines the up side; if not specified, Unity assumes Vector3.up - that's why the arm stays horizontal even when the vehicle is on a slope.
If the suspension arm is childed to the vehicle's body, you can use this attached to the arm:

var wheel: Transform; // drag the wheel here

function Update(){
    transform.LookAt(wheel, transform.parent.transform.up);
}

If the arm isn't a vehicle child, you can define the vehicle's transform in a variable, like this:

var wheel: Transform; // drag the wheel here
var vehicle: Transform; // drag the vehicle's body here

function Update(){
    transform.LookAt(wheel, vehicle.up);
}

For this to work, the arm model Z axis must point to the wheel, and its pivot must be correctly set. If you have problems with this, create an empty game object, rotate it to have Z pointing to the wheel, then set its position at the correct point in the vehicle's body. Attach the script to the game object, and child your arm model to it.

more ▼

answered Aug 27 '11 at 08:02 PM

aldonaletto gravatar image

aldonaletto
41.3k 16 42 195

Aha, Brilliant, I knew that there was something I was missing with the world up parameter, just wasn't sure how to use it. Thanks for the answer!

Aug 30 '11 at 07:55 AM Cjones110
(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:

x327
x12

asked: Aug 26 '11 at 04:18 PM

Seen: 645 times

Last Updated: Aug 30 '11 at 10:01 AM