- Home /
code animation on multiple properties using one AnimationClip
I'm trying to make an animation at runtime. I'm using two keyframes for each individual propery. So 6 in total for the x,y and z. But it seems that if i call SetCurve
for the x it will write the y and z with zerovalues. So it keeps overwriting when i call it for the y and z.
Is there any other way to set the curve with multiple properties ?
I'm using the following code to set it for each property.
string animationName = "test";
AnimationCurve curve = new AnimationCurve(); // already made from keyframes
string attribute = "m_LocalPosition.x"
AnimationClip clip = new AnimationClip { legacy = true };
clip.SetCurve("", typeof(Transform), attribute, curve);
anim.AddClip(clip, animationName);
anim.Play(animationName);
Answer by wouter_v · Apr 30, 2018 at 03:40 PM
I found a answer to my problem.
Just call SetCurve
for all properties before calling the AddClip
after that it added it as a single curve and now works great!.
Your answer
Follow this Question
Related Questions
How to make the animation run longer or shorter? 1 Answer
How can I set my Animation Curve's Tangents to Flat in script? 0 Answers
How to make an Animation movement happen only after certain keyframes? 0 Answers
My animation is not playing 2 Answers
How to add new curves or animation events to an imported animation? 6 Answers