Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by alexdevAo · Apr 08, 2020 at 01:20 AM · transform.rotationridgidbody

How to get the exact rotation that is in Transform?

I used Rigidbody.angularVelocity to make the game object rotate, and when I go to get the object's rotation, I get a different rotation than the Transform

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

· Add your reply
  • Sort: 
avatar image
1

Answer by Vipertex13 · Apr 08, 2020 at 05:24 AM

@alexlukanga

Hello!

I assume your code is not correct so I found out this way to find the rotation of an object

 float x;
 void Update () 
     {
         x += Time.deltaTime * 10;
         transform.rotation = Quaternion.Euler(x,0,0);
     }
 

Hope This Helps!

Comment
Add comment · Show 2 · 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 alexdevAo · Apr 08, 2020 at 11:40 AM 0
Share

Thanks @Vipertex13

I would like the rotation to be according to the Swipe Count. And don't rotate all the time

     void Update()
     {
 // Calculate the distance
         swipeDelta = Vector2.zero;
         if(isDraging)
         {
             if (Input.touchCount > 0)
             {
                 swipeDelta = Input.touches[0].position - startTouch;
             }
             else if (Input.Get$$anonymous$$ouseButton(0))
             {
                 swipeDelta = (Vector2)Input.mousePosition - startTouch;
             }
         }
 
         // Did we cross the deadzone
         if (swipeDelta.magnitude > 125)
         {
             // Which direction?
             x = swipeDelta.x;
             y = swipeDelta.y;
 
             if($$anonymous$$athf.Abs(x) > $$anonymous$$athf.Abs(y))
             {
                 // Left or Right
             }
             else
             {
                 // Up or Down
                 if (y > 0 && canPlay)
                 {
                     swipeUp = true;
                     gameStarted = true;
                 }
                 else
                     swipeDown = true;
             }
                 if (swipeUp)
                 {
                     gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, upSpeed * y * Time.deltaTime, 0);
                     gameObject.GetComponent<Rigidbody>().angularVelocity = new Vector3(rotateSpeed * y * Time.deltaTime, 0, 0);
                     swipeUp = false;
                     y = 0;
                     x = 0;
                 }
         }
 Debug.Log(transform.eulerAngles);
 }

I'm getting a different angle

avatar image Vipertex13 alexdevAo · Apr 09, 2020 at 12:19 AM 0
Share

Sorry I am not that good at mobile games and haven't learned swipe yet

Sorry

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

125 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

Related Questions

SoftBodys with Cloth :: Locking to transform 0 Answers

How to make arrow stick to environment ? 3 Answers

my prefab is null woe 2 Answers

How to store direction so that player faces last direction when joystick is idle 2 Answers

How to align & rotate objects to each other at run time? 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