• 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
1
Question by hencz · Dec 10, 2010 at 08:45 PM · errorrigidbodywheelcollider

WheelCollider requires an attached Rigidbody to function.

Hi

I have a car GameObject with RigidBody component and children with WheelColliders my hierarchy looks like this:

  • Car (RigidBody)
    • Mesh
      Body (Mesh Renderer, Mesh Filter, Box Collider)
      Wheel_1 (Mesh Renderer, Mesh Filter)
      Wheel_2 (Mesh Renderer, Mesh Filter)
      Wheel_3 (Mesh Renderer, Mesh Filter)
      Wheel_4 (Mesh Renderer, Mesh Filter)
    • Wheels
      Wheel_1 (WheelCollider)
      Wheel_2 (WheelCollider)
      Wheel_3 (WheelCollider)
      Wheel_4 (WheelCollider)

When the scene is loaded the wheels give the following error:
"WheelCollider requires an attached Rigidbody to function."
However they work as they should. How can I eliminate this error message?

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

3 Replies

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

Answer by Edy · Feb 24, 2011 at 05:01 PM

Your hierarchy is correct. That problem surely comes from some script trying to configure functions at the WheelColliders prior to the rigidbody to be initialized.

Try setting up an empty scene containing a car with same hierarchy and no scripts at all. There should be no error here. Add your scripts one by one until you receive the error. Then try commenting out portions of the offending script until you find the exact code that causes the problem.

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 Jrgen Heiling · Mar 04, 2011 at 12:34 PM 1
Share

There is also a bug in the WheelCollider. I have no problem when I instantiate my car, but when I load a new scene after calling DontDestroyOnLoad(myCar) I get the "WheelCollider requires an attached Rigidbody to function" error.

avatar image Pilot · Oct 15, 2011 at 07:46 AM 0
Share

I get the same when switching controllers (vehicle to player). Are there any new developments/ workarounds to address this bug? Or should this error simply be ignored (it doesn't seem to be effecting my game)?

avatar image
1

Answer by zeropoint · Jun 23, 2011 at 06:59 AM

Following should solve ur problem suppose goCar is gameobject referring to Car (root of ur hierarchy), then while activating/re-activating the gameobject do this:

 goCar.active = true;
 goCar.SetActiveRecursively(true); // now wheel colliders will be able to find rigidbody since it has been made available in previous line

First line ensures that the rigidbody is already activated for the children activated by the second line.

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
avatar image
0

Answer by Justin Warner · Dec 10, 2010 at 09:23 PM

It's asking for a Rigidbody on the WheelCollider (Being the Wheel_1---4), so on those, add a Rigidbody under the components>physics tab up top...

And you could always take out the code where it says it requires it...

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 hencz · Dec 11, 2010 at 08:18 AM 0
Share

It doesn't link to code, it comes from the WheelColliders. If I add rigidbodies the wheels will fall down.

avatar image Pilot · Oct 15, 2011 at 07:50 AM 0
Share

I am having the same problem when switching controllers (vehicle to player), and as hencz said, adding a Rigidbody to each wheel makes them simply fall through the floor! Does anyone know a workaround for this Unity bug?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Why is rigidbody.AddForce not working? 3 Answers

Unknown problem with MissingReferenceException 0 Answers

NullReferencException: Object reference not set to an instance of an object 1 Answer

the object of type rigidbody has been destroyed 3 Answers

Firing Rocket From A Car 0 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