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 /
  • Help Room /
avatar image
0
Question by Gabestronaut · Jan 24, 2016 at 09:13 PM · rotationquaternionrotateeuleranglestracking

Any simple ways of keeping track of simple rotation?

I want to track my objects rotation. I will give an example so you can understand. I want to rotate an object by an amount in any direction. Once it hits that amount, it stops. The way I have it set up is basically:

if(rotatingObject.transform.rotation.eulerAngles.y < 90) { rotatingObject.transform.Rotate(Vector3.left speed Time.deltaTime); }

The issue at hand is that rotation is from 0 to 360 so sometimes if I rotate left or right it goes from 360 to 0 and I have to duct tape the code so that it works the way I want to.

What I want to know is if this is possible. I will pseudocode it a bit Have an integer of float that is the rotation being track by a positive value. So lets say the object rotates by 1 this will += 1 to that integer or something like that. Here is an example below.


 public GameObject rotatingObject;
 public float rotationTracking;
 public float rotationGoal;
 
 void Update()
 {
      rotateObject();
 }
 
 void rotateObject()
 {
             if(rotationTracking != rotationGoal)
            {
             /*I know this next line wont make much sense but it will convey the idea I am trying to                                get across and what i'd like to do
             rotationTracking = rotatingObject.transform.Rotate(Vector3.left * speed* time.deltaTime);*/
             rotatingObject.transform.Rotate(Vector3.left * speed* time.deltaTime);
            }
 }


Comment
Add comment · Show 2
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 KdRWaylander · Jan 25, 2016 at 07:49 AM 0
Share

Please format your code properly.

avatar image Gabestronaut KdRWaylander · Jan 25, 2016 at 06:59 PM 0
Share

Excuse the formatting, I wrote it here on the fly but have reformatted it to be more understandable. $$anonymous$$y apologies.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Gabestronaut · Jan 26, 2016 at 08:13 PM

public float curRot;

curRot += rotatingObject.transform.localRotation.x;

Comment
Add comment · Show 1 · 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 Gabestronaut · Jan 26, 2016 at 08:13 PM 0
Share

Hope this helps some of you!

avatar image
0

Answer by ShadyProductions · Jan 25, 2016 at 07:41 PM

 public Vector3 curRot;
 
 curRot = new Vector3(rotatingObject.transform.eulerAngles.x,rotatingObject.transform.eulerAngles.y,rotatingObject.transform.eulerAngles.z);

Something like this maybe? (untested).

Comment
Add comment · Show 1 · 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 Gabestronaut · Jan 26, 2016 at 08:13 PM 0
Share

That was not quite what I was looking for but thank you because you steered me in the right direction! I managed to figure it out testing variations of methods and found one that worked.

 public float curRot;
 
 curRot += rotatingObject.transform.localRotation.x;

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

45 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

Related Questions

How to convert Quaternions to Euler angles with different order? 0 Answers

Does anyone know how to convert this rotation to lerp 1 Answer

If rotation was over 20° smoothly rotate towards the next 90° 2 Answers

Quaternions cancels transform.Rotate 0 Answers

Help with suns rotation 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