Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 float · May 27, 2014 at 08:46 PM · setuplocal axis

WheelJoint2D Local Axis

The Manual states that there is an Option for the suspension in the WheelCollider2D: Local Axis, Direction along which the suspension travels.

I did not see this option in the editor and i also cannot find it via the script.

So how exactly do i need to setup a WheelJoint2D so that it bounces straight up and down? (The angle does not seem to do the trick. The wheels jump around in every direction like a with a normal spring joint.)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by taylank · May 28, 2014 at 09:53 PM

Do you have the WheelJoint on the wheel object itself? For a wheel, that means the suspension goes every which way as the wheel turns. You can either place the joint on the connected body instead, or fix the angle in every frame.

Doing this in Update() worked for me:

 void FixSuspensionDirection () {
         WheelJoint2D wheel = GetComponent<WheelJoint2D> ();
         JointSuspension2D sus = wheel.suspension;
         Vector2 facingDir = transform.InverseTransformDirection(wheel.connectedBody.transform.right);
         float angleOffset = Mathf.Atan2(facingDir.y, facingDir.x) * Mathf.Rad2Deg;
         
         sus.angle = angleOffset+90;
         wheel.suspension = sus;
     }

 
Comment
Add comment · Show 2 · 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 float · May 29, 2014 at 12:51 AM 0
Share

Thank you. Yes, i did find that solution too: jointSuspension = wheel.suspension; jointSuspension.angle = 90f + car.rotation.eulerAngles.z; wheel.suspension = jointSuspension;

I have my car object, some supension objects(with the WheelJoint) and then each of the wheels have a hinge-joint(i use for the motor). Is that maybe too much? It looks like my car is slightly jittering when it moves.

avatar image taylank · May 29, 2014 at 04:29 PM 0
Share

I'd remove the hinge joints, as WheelJoint2D comes with a motor you can use too. Also try changing the suspension frequency and/or damping to see whether it behaves more like you expect it to. It takes a lot of fiddling to get the right feel you are ai$$anonymous$$g for. I've found higher frequency and damping (stiffer suspension) works better for me but it could be different for your game.

avatar image
0

Answer by ZANTcr · Aug 05, 2014 at 01:10 AM

Hi I did a 2D Vehicle Control for the asset store, in my script the WheelJoint2D are created automatic, but some tips for your vehicle are:

Make your wheels child of the carbody. The carbody and the wheels need a rigidbody2d. In your carbody add 2 WheelJoint2D. In the WheelJoint2D drag and drop you wheel to connected rigidbody option. Adjust the anchor option of the WheelJoint2D. Your wheel object dont need WheelJoint2D, just your carbody.

Comment
Add comment · 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

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

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

64 bit Support for Unity? 1 Answer

How create a default setup for user? 0 Answers

Unity build with multiple .exe files 2 Answers

How to keep an object level to horizontal? 2 Answers

I Can't Assign Something To Local Space's X Axis 1 Answer


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