Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by ggweg · Mar 10, 2014 at 11:18 PM · rotationgameobjecttransformeulerangles

GameObject Rotation is always postive

Sorry if a post like this already exists (couldn't find it).

I'm trying to calculate how many flips the player has done on their bike but since I'm always getting a positive value I can't calculate it properly.

So this raises a few questions:

  • Is there a way to make the rotation go into the negative? If so, how?

  • How can I check if the rotation value falls below 0 and jumps to a value between 300-360?

So you know, I've been using "GameObject.transform.rotation.eulerAngles.z" to get the rotation value.

Thank you for your time and help.

Comment
Add comment · Show 3
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 robertbu · Mar 10, 2014 at 11:21 PM 1
Share

Here is an alternate method of counting flips.

http://answers.unity3d.com/questions/651849/count-the-amount-of-flips-and-object-makes.html

avatar image ggweg · Mar 10, 2014 at 11:31 PM 0
Share

Thank you. The code works, however one flips counts as two. Believe this to be down to there not being negative rotation.

avatar image robertbu · Mar 10, 2014 at 11:43 PM 1
Share

There are some potential issues with the way you are doing things for general 3D rotations, but it will work for some situations. If you think it is working except for the problem you outline, then normalize the rotation into some framework. For example:

 var angle = transform.eulerAngles.z;
 if (angle > 180.0) 
     angle = angle - 360.0;

This way you will get rotations between -180 and 180.

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.

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

Why Local Rotation Faster than World Rotation (Degrees/Second) 1 Answer

how to get the absolute direction? 1 Answer

Camera rotation the same as player rotation 1 Answer

Limit gameobject rotation to -480 and 480 degrees? 2 Answers

Problem about Rotating the Character 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