I really don’t know why I can’t get the curves of a clip, but it’s giving me troubles.
Another crazy question is: Why can’t I copy the curve(s) of an AnimationClip in the editor and paste them to an AnimationCurve property in a script?
I ask these questions because I want to be able to take an animation clip, get the transform, rotation, and scale curves/animations, and make the properties additive in such a way that my Animator’s gameobject does not need to change its initial rotation and still perform the animation in a given direction. I believe that if I am able to get the curves of an AnimationClip, I will be able to take those and add it and orient it through script to the desired gameobject.
I know this is complicated, because I’m having a hard time explaining it, but if you suggest that I use root motion, it will not work because then the gameobject will just perform the animation in its “forward” direction and not the direction I am inputting.
Although it may be possible, I do not want to animate everything through code because I don’t think it would be very intuitive or easy to use, especially with what I am trying to accomplish.
You do not have to solve my problem directly, but if there is a way to get these properties, I (and probably many others) would be glad to know.
Did you not read the API reference? You can very clearly add, remove, edit keys - so yeah really not sure what the issue is
Maybe I am misunderstanding you. But if what you want is to evaluate stuff over a curve, this is what you use.
If you are talking about curves specifically visible in the Animation window, then you need to be clearer on that as its not entirely clear and AnimationCurve is a real thing as I have pointed out, hence maybe the confusion
Of course I looked at the documentation, and you could have stated that in a nicer manner.
Yes, you are right, you can edit, add, and remove keys of an AnimationCurve variable, but it doesn’t matter at this point because you can never retrieve an AnimationCurve from an AnimationClip to edit the keys. The only Get functions of an AnimationClip are the GetType, which I don’t know how you could use to get the curves honestly if at all, GetHashCode, and GetInstanceID. Which I’m sure you already knew at this point since I’m deciding to respond to a year old post, and you of course look at the documentation
You can call AnimationCurve.Evaluate and pass in a percentage complete to get the key at a specific point. So, if you were to pass 0 then it’d give you the starting key. A 1 would be the final key, etc.
@Unity_Nitro - So, to do what you’re looking to do I think you could evaluate the percentage complete of your existing animation and get the corresponding percentage complete through your custom curves.
I haven’t tried this, so I’m not 100% sure - but that seems logical to me.