Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
0
Question by sunrisepulp · Sep 30, 2018 at 02:07 PM · rotationplayerdegrees

Read when player has done a 90 degree turn at all times.

Hello there!

I have a basic setup, a controller that rotates with the mousekeys or thumbsticks on gamepad.

I wanna read if the player has done a turn that is over 90 degrees fast, not slowly.

Are there any good ways to do this?

I tried to code something already, but it only works sometimes, and it really don't work if i go oblique directions:

  //Checks where the player is turned over 90 degrees.
         if(((transform.localRotation.eulerAngles.y >= 0) && (transform.localRotation.eulerAngles.y <= 80)) || ((transform.localRotation.eulerAngles.y >= 342) && (transform.localRotation.eulerAngles.y <= 360)))
         {
             if (HundreandEightyDegrees)
             {
                 Debug.Log("Quick turned to 0 degrees from 180!");
                 ZeroDegrees = true;
                 NinityDegrees = false;
                 HundreandEightyDegrees = false;
                 TwohundreandseventyDegrees = false;
             }
             else
             {
                 ZeroDegrees = true;
                 NinityDegrees = false;
                 HundreandEightyDegrees = false;
                 TwohundreandseventyDegrees = false;
             }
         }
 
         if ((transform.localRotation.eulerAngles.y >= 81) && (transform.localRotation.eulerAngles.y <= 175))
         {
             if (TwohundreandseventyDegrees)
             {
                 Debug.Log("Quick turned to 90 degrees from 270!");
                 ZeroDegrees = false;
                 NinityDegrees = true;
                 HundreandEightyDegrees = false;
                 TwohundreandseventyDegrees = false;
             }
             else
             {
                 ZeroDegrees = false;
                 NinityDegrees = true;
                 HundreandEightyDegrees = false;
                 TwohundreandseventyDegrees = false;
             }
         }
 
         if ((transform.localRotation.eulerAngles.y >= 177) && (transform.localRotation.eulerAngles.y <= 265))
         {
             if (ZeroDegrees)
             {
                 Debug.Log("Quick turned to 180 degrees from 0!");
                 ZeroDegrees = false;
                 NinityDegrees = false;
                 HundreandEightyDegrees = true;
                 TwohundreandseventyDegrees = false;
             }
             else
             {
                 ZeroDegrees = false;
                 NinityDegrees = false;
                 HundreandEightyDegrees = true;
                 TwohundreandseventyDegrees = false;
             }
         }
 
         if ((transform.localRotation.eulerAngles.y >= 270) && (transform.localRotation.eulerAngles.y <= 335))
         {
             if (NinityDegrees)
             {
                 Debug.Log("Quick turned to 270 degrees from 90!");
                 ZeroDegrees = false;
                 NinityDegrees = false;
                 HundreandEightyDegrees = false;
                 TwohundreandseventyDegrees = true;
             }
             else
             {
                 ZeroDegrees = false;
                 NinityDegrees = false;
                 HundreandEightyDegrees = false;
                 TwohundreandseventyDegrees = true;
             }
         }


I also tried to store euler angle and then add 90 degrees to it, and then after 0.1 sec if the transform rotation right now was more and equal to the stored one it had done a 90 degree turn. But this had a lot of problem, because when you should store and read if it has changed..

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.

Follow this Question

Answers Answers and Comments

198 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 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 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 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 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 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 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 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 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 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

My Player rotates on the Z axis, but not the X axis. Why? 0 Answers

Camera rotate X degree based on player rotate 0 Answers

FPS camera jitters while moving and turning 0 Answers

I want to make my players Y rotation rotate with my Cameras X rotation(Third Pearson Camera). What did I do wrong? 0 Answers

localEulerAngles command does not work well.. 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