Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 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 /
avatar image
0
Question by unity_lF98_nVJe9di1A · Apr 05, 2019 at 01:48 PM · gameobjecttransformquaternionlocalrotation

Write a C# script to record GameObject rotation?

I know how to write most of the script and record to csv file. But when i play back the GameObject from the data it comes very deformed and crooked and essentially inaccurate. I am using Quaternion.Euler(gameObject.transform.localEulerAngles()) to obtain the rotation values. Is this correct?

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

4 Replies

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

Answer by unity_lF98_nVJe9di1A · Apr 05, 2019 at 04:13 PM

Actually all has been solved. I removed stupid Quaternion that I for some reason still kept in my code, and changed it to Vector3. The whole animation is now working. Thank you for all your help! Solution is here https://pastebin.com/jmy7LwXv

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
avatar image
0

Answer by xxmariofer · Apr 05, 2019 at 01:56 PM

you want to obtain the rotation of the object? why not just use transform.rotation? if you want to store the euler angles just use transform.rotation.eulerAngles what you are trying to do in that line feels redundant but not innacurate, but you are getting the local rotation so that may be whats making it inaccurate

Comment
Add comment · Show 3 · 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 unity_lF98_nVJe9di1A · Apr 05, 2019 at 03:14 PM 0
Share

i tried transform.rotation and transform.localRotation and it still comes very crooked. Also is there a way to get the rotation angles EXACTLY how they appear in the inspector?, because transform.rotation values are actually different to the inspector values.

avatar image xxmariofer unity_lF98_nVJe9di1A · Apr 05, 2019 at 03:18 PM 0
Share

as i said transform.rotation.eulerAngles tells you exactly what is in inspector, try logging them and compare if they are logging right

avatar image unity_lF98_nVJe9di1A xxmariofer · Apr 05, 2019 at 03:57 PM 0
Share

Hi, just compared them and they are not logging right.alt text

See image attached

The euler angle logged and the value in the inspector are about 360 degrees different.

Please find my code here https://pastebin.com/EPBJUPYx

hand-problem-unity.png (173.9 kB)
avatar image
0

Answer by Tsaras · Apr 05, 2019 at 02:20 PM

It is pretty straightforward if you record transform.rotation and then replay by setting the transform.rotation values. Unless you absolutely want euler angles for some reason.

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 unity_lF98_nVJe9di1A · Apr 05, 2019 at 03:14 PM 0
Share

i tried transform.rotation and transform.localRotation and it still comes very crooked. Also is there a way to get the rotation angles EXACTLY how they appear in the inspector?, because transform.rotation values are actually different to the inspector values.

avatar image
0

Answer by metalted · Apr 05, 2019 at 03:36 PM

The inspector rotation values are in transform.localEulerAngles.


Only use this variable to read and set the angles to absolute values. Don't increment them, as it will fail when the angle exceeds 360 degrees. Use Transform.Rotate instead ~ Unity Reference


https://docs.unity3d.com/ScriptReference/Transform-localEulerAngles.html

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

171 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

Related Questions

transform.localRotation resets after rotation 1 Answer

Instantiate GameObject towards player 0 Answers

Adding Rotation to a Gameobject 1 Answer

How rotate only z axis of Gameobject (2D) 1 Answer

Auto leveling help 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