Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed Feb 24, 2015 at 09:04 PM by Abacab for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Abacab · Feb 24, 2015 at 03:32 PM · c#transformrotatelocaleulerangles

Wheels Rotate or Turn, but not both

Hello!

I have problem with my wheel rotation. It works if I just make them rotate or if I just make them turn, but not both at the same time! What am I doing wrong?

 public Transform wheelFLTrans;
 public Transform wheelFRTrans;
 public Transform wheelBLTrans;
 public Transform wheelBRTrans;
 
 void FixedUpdate ()
     {
         // 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);
 
         // Steering rotation
         wheelFLTrans.localEulerAngles = new Vector3 (0, wheelFL.steerAngle * 2, 0);
         wheelFRTrans.localEulerAngles = new Vector3 (0, wheelFR.steerAngle * 2, 0);
     }
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

  • Sort: 
avatar image
1
Best Answer

Answer by LaireonGames · Feb 24, 2015 at 08:48 PM

Its because you are setting the steering rotation directly. Basically ona simple level you are doing this:

 float x = 1;

 x *= 5;    
 x = 3;

Its the localEurlerAngles that is your culprit here. To fix change it rotate as your other lines do and convert your steer angle from degress to Radians (Mathf.DegtoRad)

Comment
Add comment · Show 4 · 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 · Feb 24, 2015 at 08:56 PM 0
Share

How exactly do I do that? mathf.Deg2Rad is a little unclear to me.

avatar image LaireonGames · Feb 24, 2015 at 09:02 PM 0
Share

First hit on Google...

http://docs.unity3d.com/ScriptReference/$$anonymous$$athf.Deg2Rad.html

Just multiply your wheelFL.steerAngle etc by it and job done

  wheelBRTrans.Rotate (0, wheelFL.steerAngle * 2 * $$anonymous$$athf.DegtoRad, 0);

avatar image Abacab · Feb 24, 2015 at 09:03 PM 0
Share

That is the same link I posted in my comment, but thanks!

avatar image LaireonGames · Feb 24, 2015 at 09:07 PM 0
Share

Ah sorry my bad I thought the example was pretty clear. Basically natural angles (as I call degress) need to be convert to Pi essentially.

$$anonymous$$G a complete rotation of a circle is 2Pi so all you are really doing is relating that to 360 which is what euler angles work in

Follow this Question

Answers Answers and Comments

20 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

Related Questions

Unity 3d(Space) Questions 1 Answer

How i can equal 2 Tranform Rotations? 1 Answer

Translate from JS to C# localEulerAngles 1 Answer

Distribute terrain in zones 3 Answers

C# Mathf.PingPong Rotate Back and Forth 2 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