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
0
Question by manderda · Jan 07, 2019 at 09:29 AM · rotationscript.rotate object3d model

Rotate a Object, but with rotation values

I have a kind of strange question, but I hope someone can give me a good hint...
To the topic:
I have a gyroscope sensor, which collects the rotation position of the attached object every 0,1 second and stores the rotation values as a Vector3. So I have some sort of json file like this:

 {"x":357.0,"y":180.0,"z":11.900009155273438},{"x":357.0,"y":180.0,"z":11.900009155273438},{"x":360.0,"y":180.0,"z":12.000009536743164},...

it contains the transform.rotation of the object in 0,1 second time steps.

If I just use transform.rotation to set the rotation from the sensor, the unity object is rotation the correct way, but it is not rotating around itself:

 void Update () {
         transform.rotation = Quaternion.Euler(rotation);
     }

I do change the rotation variable every 0,1 second to the next from the json file.

With that the rotation works fine, but the object is not rotating around it self, but around it local origin.

But I want the object to rotate around it self (with Transform.RotateAround and the center of mass of the object?).
how can I transform the stored Transform.Rotation values from the json file to fit Transform.RotateAround. Maybe there is another way to accomplish this?

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

2 Replies

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

Answer by Kudorado · Jan 07, 2019 at 10:42 AM

@manderda

I'm not really understand your question but i think this might help you:

      void Update () {
              transform.rotation = Quaternion.Slerp(transform.rotation, 
            Quaternion.Euler(rotation), Time.deltaTime);   
          }


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 manderda · Jan 07, 2019 at 11:28 AM 0
Share

Thanks for the answer, I was a bit to sleepy when I made the Question. I tried to make it more clear. Sadly Quaternation.Slerp does not work the way I want it to.

avatar image
0

Answer by manderda · Jan 08, 2019 at 08:41 AM

I was able to find a solution to my problem. I guess I didn't understood how rotation is handles in Unity. I could "fix" the local origin of my object with this trick: https://www.youtube.com/watch?v=6qwjyypHcj8

And with
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(rotation), Time.deltaTime);
the rotation is looking smooth now. Thank you @Kudorado!

Comment
Add comment · 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

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

98 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

Related Questions

Why is the rotation missing when I animate? 1 Answer

How to Rotate Object around point only 90 Degree. 1 Answer

Have an object continuously rotate towards another 1 Answer

How can I make a character look in a direction that's halfway between its direction of 2D movement and facing the camera? 1 Answer

Build rotation tool for level editor 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