• 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 Abacab · Dec 14, 2014 at 12:59 AM · carwheelcolliderplaymodewheel

Front wheel rotates in play mode

Hello!

My front right wheel looks all right when I am in scene mode, but once I enter play mode it rotates 180 degrees and is facing inside. This is not happening to any other wheel.

The problem goes away if I delete the Steering rotation portion of the code. Can you spot the problem? Thanks in advance!

 void Update ()
         {
                 // Steering rotation
                 Vector3 wheelFLTransAngle = wheelFLTrans.localEulerAngles;
                 Vector3 wheelFRTransAngle = wheelFRTrans.localEulerAngles;
                 wheelFLTransAngle.y = wheelFL.steerAngle - wheelFLTrans.localEulerAngles.z;
                 wheelFRTransAngle.y = wheelFR.steerAngle - wheelFRTrans.localEulerAngles.z;
                 wheelFRTrans.localEulerAngles = wheelFRTransAngle;
                 wheelFLTrans.localEulerAngles = wheelFLTransAngle;
 
                 // Wheel rotation
                 wheelFLTrans.Rotate (wheelFL.rpm / 60 * 360 * Time.deltaTime, 0, 0);
                 wheelFRTrans.Rotate (wheelFR.rpm / 60 * 360 * Time.deltaTime, 0, 0);
                 wheelBLTrans.Rotate (wheelBL.rpm / 60 * 360 * Time.deltaTime, 0, 0);
                 wheelBRTrans.Rotate (wheelBR.rpm / 60 * 360 * Time.deltaTime, 0, 0);
 
         }
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 EvilTak · Dec 14, 2014 at 03:06 AM 0
Share

What is the original rotation of the front right wheel in scene view?

avatar image EvilTak · Dec 14, 2014 at 12:48 PM 0
Share

Try removing the portion when you subtract the localeulerangles z component. Just leave it as wheelFL.steerAngle.

avatar image Abacab · Dec 14, 2014 at 12:52 PM 0
Share

I managed to get the front right wheel to face the right way, but the car still steers a little to the right when I start accelerating from 0.

Any idea what might cause it?

avatar image EvilTak · Dec 14, 2014 at 12:54 PM 0
Share

Those are wheelcollider bugs... Search around and there are many people who have the same question. Look at the related questions... BTW how did you manage to get it rotating in the right way?

avatar image Abacab · Dec 14, 2014 at 12:55 PM 0
Share

I changed the front right wheel rotation from 180 to 0 and entered play mode. It still was rotated inside so I just rotated it to 180 and it was ok. Weird?

1 Reply

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

Answer by JA_555 · Dec 14, 2014 at 08:56 AM

Maybe in scene view you could have the wheel already facing inside? Then in play mode, it would do its rotation and face the right way. As for why it even does the rotation, compare the back right wheel and the front right wheel, and maybe there will be slight difference in rotation that you can spot in the inspector.

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 Abacab · Dec 14, 2014 at 09:24 AM 0
Share

The front right wheel is facing the right way in scene view when play mode is on. Both the front right and back right wheel's rotation is set to 0,0,0.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Car wheels not stopping when I brake 0 Answers

How do I Instantly stop wheels (WheelCollider) from moving ? 0 Answers

WheelCollider Setup from car? 0 Answers

C# WheelHit.force display wheel suspensions on meshes 0 Answers

Vehicle issues. 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges