• 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 H3core · Jan 11, 2013 at 04:42 AM · 2drotation

Unity Car Tutorial Rotate Snippet Chaos

So, i took this little code snippet from the Unity's Car Tutorial to rotate my 2D Car Game Wheels, for accurate rotation:

     w.wheelVelo = rigidbody.GetPointVelocity(wh.point);
     w.groundSpeed = w.wheelGraphic.InverseTransformDirection(w.wheelVelo);
                         print (w.wheelVelo);
                         print (w.groundSpeed.x);
                         print (w.groundSpeed.y);
  //w.wheelGraphic.Rotate(Vector3.forward * (-w.groundSpeed.x / wheelRadius) * Time.deltaTime * Mathf.Rad2Deg);


And in the Debug the values printed look like so:

(13.8, 0.0, 0.0) 13.80005 -0.00028884

(17.2, 0.0, 0.0) 17.20007 -0.0003456686

Looking perfect for a 2D game being left, right (x-axis), up, down (y-axis), so whats the problem...... The catch is that the rotate part is actually commented

If the comment is removed these are the values returned:

(19.4, 0.0, 0.0) 3.437649E-05 19.40008

(20.9, 0.0, 0.0) 4.99693E-05 20.90008

And guess what it doesn't end there if i change the groundspeed from .x to .y like so to fix that bug in value:

 w.wheelGraphic.Rotate(Vector3.forward * (-w.groundSpeed.y / wheelRadius) * Time.deltaTime * Mathf.Rad2Deg);

Guess what, you guessed right, the values returned are now are :

(15.7, 0.0, 0.0) 15.70005 -0.005213013

(16.7, 0.0, 0.0) -16.70006 -0.001558624

So, where does this leave us, to WTF, and me hoping im blind to something cause ive been scripting the whole day, trying hard to believe that that is no hidden unity button thats called F-Over user for some fun, and trying even harder not to say UNITY is F-IN STUPID.

Any help, insight to this wonderful encounter to Unity's Daily Coding Shafts as i would like to call it, probably fit for a YouTube Series name, it would be really great :)

Until then have a great day, and please find a way this is reported to Unity Developers

Thanks

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

0 Replies

· Add your reply
  • Sort: 

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

9 People are following this question.

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

Related Questions

Disabling the Z axis? 1 Answer

2D camera rotating relatively to game object speed 0 Answers

2D sprite that always faces the player? 1 Answer

Script gives wrong rotation. 1 Answer

Rotating a 2D GameObject on Z regardless of the distance. 2 Answers

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