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
0
Question by Zarlang · Jun 04, 2012 at 06:15 PM · runtimeanimationcurve

AnimationCurve created in runtime, unexpected behaviour

Hi, I need some help with this:

 Keyframe[] k_x = new Keyframe[len];
 Keyframe[] k_y = new Keyframe[len];
 Keyframe[] k_z = new Keyframe[len];

 Keyframe[] k_qx = new Keyframe[len];
 Keyframe[] k_qy = new Keyframe[len];
 Keyframe[] k_qz = new Keyframe[len];
 Keyframe[] k_qw = new Keyframe[len];
 for (int i = 0; i < boneChannel.rotation_key_list.Length; i++)
 {
     //define "mat" here which is the character bone data.
     Vector3 new_vec = mat.GetColumn(3);
     Quaternion new_quat = QuaternionFromMatrix(mat);
 
     k_x[i] = new Keyframe(t, new_vec.x, 0f,0f); //defining in and out tangents as 0
     k_y[i] = new Keyframe(t, new_vec.y, 0f,0f);
     k_z[i] = new Keyframe(t, new_vec.z, 0f,0f);

     k_qx[i] = new Keyframe(t, new_quat.x, 0f,0f);
     k_qy[i] = new Keyframe(t, new_quat.y, 0f,0f);
     k_qz[i] = new Keyframe(t, new_quat.z, 0f,0f);
     k_qw[i] = new Keyframe(t, new_quat.w, 0f,0f);
 }
 curve_pos_x = new AnimationCurve(k_x);
 curve_pos_y = new AnimationCurve(k_y);
 curve_pos_z = new AnimationCurve(k_z);

 curve_quat_x = new AnimationCurve(k_qx);
 curve_quat_y = new AnimationCurve(k_qy);
 curve_quat_z = new AnimationCurve(k_qz);
 curve_quat_w = new AnimationCurve(k_qw);

 clip.SetCurve(relative_path, typeof(Transform), "localPosition.x", curve_pos_x);
 clip.SetCurve(relative_path, typeof(Transform), "localPosition.y", curve_pos_y);
 clip.SetCurve(relative_path, typeof(Transform), "localPosition.z", curve_pos_z);

 clip.SetCurve(relative_path, typeof(Transform), "localRotation.x", curve_quat_x);
 clip.SetCurve(relative_path, typeof(Transform), "localRotation.y", curve_quat_y);
 clip.SetCurve(relative_path, typeof(Transform), "localRotation.z", curve_quat_z);
 clip.SetCurve(relative_path, typeof(Transform), "localRotation.w", curve_quat_w);

Now, for just a certain bone, I get this artifacted rotation curves:

alt text

I've tried other ways of defining the curve and it's always the same bug...Really don't know what to do. Any thoughts? Thanks in advance.

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 Berenger · Jun 04, 2012 at 06:21 PM 0
Share

Does it affect the Evalute's return value ? $$anonymous$$aybe it's just graphic ?

avatar image Zarlang · Jun 04, 2012 at 06:25 PM 0
Share

Haven´t tested Evaluate but artifacts are present in the animation, I mean, you see it ingame.

2 Replies

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

Answer by Zarlang · Jun 05, 2012 at 06:26 PM

Well, an answer to this can be found here. http://forum.unity3d.com/threads/63463-Weird-tangents-at-Keyframe-creation

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 Bunny83 · Jun 04, 2012 at 06:31 PM

I think you shouldn't animate the quaternion components the way you did. Usually you animate eulerangles.

It's also not really clear where you get your data from. I see you animate in local space which is correct, but where is your matrix comming from? Is it in local space?

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 Berenger · Jun 04, 2012 at 07:42 PM 1
Share

zarlanga : Well, I tried converting quaternion to angles, it's the same problem. Let me try to explain it a bit:

I get, from a file, the rotation and position offset of a bone in a certain keyframe. $$anonymous$$y matrix is then composed with the original bone pos and rot plus this offset, like this:

  $$anonymous$$atrix4x4 mat;
  mat = $$anonymous$$atrix4x4.TRS(initial_bone_mat.vec, initial_bone_mat.quat, Vector3.one);
  $$anonymous$$atrix4x4 mat2;
  mat2 = $$anonymous$$atrix4x4.TRS(boneChannel.position_key_list[i], boneChannel.rotation_key_list[i], Vector3.one);
  mat = mat * mat2;

$$anonymous$$aybe the original position and rotation of bones are somehow doing something. I'm sorry but I'm very new to this thing, can't quite understand it all.

I've also slowed down animation and this bone rotates to the opposite direction it's supposed to. Need to turn from 359.90 to 360.1 but turns 359.90 to 0.1

...

($$anonymous$$e : Why does the ability to move an answer to comments requiere so much karma ...)

avatar image Zarlang · Jun 05, 2012 at 05:54 PM 0
Share

sorry, in my defense, "add new comment" should say, "answer to answer" :)

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

How to modify animation curve in run time? 2 Answers

Scripted animation not working on windows 8 1 Answer

Export objects to a .3DS file at runtime 1 Answer

How to access AnimationCurve at runtime 4 Answers

Scripted animation not working 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