• 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 Baroque · Mar 31, 2015 at 06:58 AM · physicsunity5wheelcollider

Can you make a freely spinning WheelCollider in Unity5?

I'm simulating a small aeroplane and I was using WheelColliders in Unity 4.5 for the wheels. Since switching to Unity 5 the wheels resist any kind of external forces. When I spin up the propeller and apply forces to the Rigidbody, the plane flips onto its nose!

Here's the problem demonstrated on a cube with wheels:

alt text

The wheels are default WheelColliders, the cube has mass 2000 and I'm applying a force of 10,000 using a very simple script:

 public class Truck : MonoBehaviour
 {
     bool push;
 
     void Update() {
         push = Input.GetKey("p");
     }
 
     void FixedUpdate() {
         if (push)
             GetComponent<Rigidbody>().AddForce(new Vector3(0, 0, 10000));
     }
 }

Other experiments:

  • The truck will roll if you apply a small force before the truck "lands" when the level starts, so it hits the ground rolling ever so slightly.

  • The truck will also roll if you incline the slope to greater than 1.4 degrees (??). Anything less than that and it stays glued to the ground.

What's going on here?

[1]: /storage/temp/43744-physicstest.zip

truck.gif (71.9 kB)
physicstest.zip (24.3 kB)
Comment
Add comment · Show 5
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 Nymisu · Mar 31, 2015 at 01:41 PM 1
Share

I tried to recreate your issue, but with completely out of the box settings, sans offsetting centers on (roughly) the corners of a 1,1,3 scale unity box with 2000 rigidbody mass, it rolls just fine.

Perhaps there's something else in your script that's causing the strange behavior, because i can move the box with even exceptionally small amounts of force.

avatar image Baroque · Mar 31, 2015 at 02:33 PM 0
Share

There's really not much else going on in the script, which is why I was confused. You're using the default settings on the Unity 5 WheelCollider?

(Edited my post to add the complete code after deleting all the other stuff.)

avatar image Nymisu · Apr 02, 2015 at 08:52 AM 0
Share

There must be something wrong with hierarchy, or scene. I just made a 1,1,3 scale box with 4 completely default setting wheelcolliders, outside of their offsets, attached to empty gameobjects as its children in a similar setup to your's and it works fine.

Try using transform.forward*10000 ins$$anonymous$$d of vector3(0,0,10000)

avatar image Baroque · Apr 02, 2015 at 10:03 AM 0
Share

Really appreciate you looking into it, even if you're not seeing the same results.

I've tried it with a hierarchy like this:

  • Truck
    • Cube

    • Wheel

    • Wheel

    • Wheel

    • Wheel

and like this:

  • Cube
    • Wheel

    • Wheel

    • Wheel

    • Wheel

Both of which exhibit the same behaviour. transform.forward*10000 is equal to 0, 0, 10000 but I tried it anyway and see the same problem.

I've attached a zip file of an absolute bare bones project that has the problem on my version of Unity (5.0.0f4 Personal). I created it completely from scratch just now using default settings.

avatar image JigneshKoradiya · Jul 08, 2015 at 04:04 PM 0
Share

https://www.youtube.com/watch?v=jNySyx2RrP0

check this video to solve problem of wheel collider bouncing on unity5

2 Replies

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

Answer by Baroque · Apr 03, 2015 at 05:21 AM

On further research, this seems to be a known issue with the WheelColliders in Unity 5.

See these forum posts:

  • http://forum.unity3d.com/threads/unityfs-flight-simulation-toolkit.171604/page-8

  • http://forum.unity3d.com/threads/unity-5-wheelcollider-component-is-unusable.307099/

There is a simple workaround though: Create an Awake() function that gives the wheels a non-zero motor torque and they will spin freely.

 void Awake() {
     foreach (WheelCollider w in GetComponentsInChildren<WheelCollider>()) 
         w.motorTorque = 0.000001f;
 }

This is low enough that the vehicle won't start driving away but apparently enough that the wheels will turn freely.

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 unitynewb · Aug 16, 2016 at 06:00 AM 0
Share

Thanks, that resolved my issue, but I have one question. I have a model which rotates based on the wheels rpm and this decreases the rpm which causes a constant rotation. I could check and only rotate the wheel if the motortorque does not match 0.000001f, but then it does not rotate if it is freely rolling.

Here is my code: (wheelVisualRotate would be my model)

 if (wheelCollider.motorTorque != 0.000001f)
 {
         wheelVisualRotate.Rotate(-wheelCollider.rpm / 60 * 360 * Time.deltaTime, 0, 0);
 } 

avatar image
0

Answer by JigneshKoradiya · Jul 08, 2015 at 04:04 PM

https://www.youtube.com/watch?v=jNySyx2RrP0

check this video to solve problem of wheel collider bouncing on unity5

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Wheelcollider Settings to Match Default Unity 4 0 Answers

Car - WheelCollider - Why the side is getting up? 2 Answers

Is there any way to tell a wheel collider which way gravity is without Physics.Gravity? 2 Answers

Question about Wheel collider use 1 Answer

My space bar refuses to work 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