Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 rolandha · Mar 08, 2012 at 07:17 PM · animationtransformproperty

Which transform properties can be set in a scripted animation?

The documentation of AnimationClip.SetCurve describes that common property names that can be used for scripting animations are: localPosition, localRotation and localScale.

But the transform class also has properties for transformations in world space like position, rotation and eulerAngles or in local space like localEulerAngles.

Is it possible to modify these as well? I tried, but animations on this properties get ignored. When I try to check them in the animation window I get the message, that I should clean up left over properties cause they can not be found in the object. So I guess it is not possible. Is there any documentation on 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

1 Reply

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

Answer by Blazor Ramone · Mar 09, 2012 at 02:24 AM

I'm not 100% sure, but I think the way things work in Unity as well as some other 3d engines is that objects (transforms) are only really responsible for the local components of their transforms and that the other values, such as world space position and rotation and things like Euler angles, are calculated from or translated to local coordinates when needed. One clue to this is the fact that in the inspector, particularly in Debug mode, you will only see the localPosition, localRotation, and localScale are shown. So it would seem that animation curves will only directly let you manipulate these local values, but there maybe some things you can do to achieve similar effects to manipulating the other values. For instance if you add animation curves to a transform that has no parent( the root game object not necessarily the root node in a skelton) its local position rotation etc will be equivalent to a worldspace coordinate. Concievably if you happen to know the position of all the parent transforms you can figure out the local position to set in order to get a desired world coordinate I think it would be something like

 //psuedo code
 desiredlocalPos = desiredWorldPos - Sum(all parents localPositions * rotation)

I'm not sure that the normal TransformPoint / InverseTransformPoint or WorldToLocal/LocalToWorld matrixes will work in these contexts as the transforms may not be set when creating an animCurve. Also the only way you could really know all the parent positions is if you also set the keys on all of them for the same frame. This seems like it would get dangerous...

Euler angles are another property Unity has to calculate as it really uses Quaternions to represent orientation. Luckily there is a static function Quaternion.Euler that you can use convert Euler to Quaternion so if you wanted to set local eulers to the animation curve you could do something like:

 Quaternion desiredRot = Quaterion.Euler(x,y,z);
 clip.SetCurve("", Transform, "localRotation.x", curvex);
 clip.SetCurve("", Transform, "localRotation.y", curvey);
 clip.SetCurve("", Transform, "localRotation.z", curvez);
 clip.SetCurve("", Transform, "localRotation.w", curvew);
 curvex.AddKey(time, desiredRot.x);
 curvey.AddKey(time, desiredRot.y);
 curvez.AddKey(time, desiredRot.z);
 curvew.AddKey(time, desiredRot.w);
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 rolandha · Mar 09, 2012 at 01:04 PM 0
Share

thank you!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Material doesn't have a color property '_Color' 4 Answers

Add Mixing Transform Doesn't Work!! 4 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Rotating An Object On Its Axis Once 3 Answers

Unity 3d(Space) Questions 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