Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Cjones110 · Aug 26, 2011 at 04:18 PM · lookatsuspension

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...

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by aldonaletto · Aug 27, 2011 at 08:02 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cjones110 · Aug 30, 2011 at 07:55 AM 0
Share

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!

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Lock rotation axis? 4 Answers

Incorrect script for slerp rotation 1 Answer

Look at multiple cameras 2 Answers

LookAt GameObject but never rotate in Y Axis 1 Answer

AddTorque to rotate rigidbody to look at a point 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges