- Home /
How do I author animation clips for additive blending when the desired motion is returning to zero?
I'm trying to get a non-humanoid (hence no Mecanim IK) character to look at, and track a target.
My first attempt was to programatically animate the bones in LateUpdate(), which worked but looked a bit mechanical, especially since the character has quite a complicated neck structure and I was only animating a small portion of it.
My second attempt was to use a set of head turn animations, one each for look up, down, left and right (as well as a matched set that return back to the idle position) and then use a 2D blend tree to blend between the four animations based on the desired yaw and pitch. This worked pretty well, but is limited by Unity's insistence on normalising animation blend weights. If I look straight up or down then I don't get the full range of motion, likewise left and right, but if I look up and left at the same time then the weights are normalised to 0.5 and 0.5. (If anyone knows a way to optionally bypass that feature I'd be grateful)
My third attempt was to use additive animation. I created two separate additive Mecanim layers, one for pitch, and one for yaw. Now I get the full range of motion, but the animation only plays correctly when it is playing the animation that transitions from the idle pose into the look pose. If I try to play an animation that just holds the look pose then it gets ignored, and if I play the return to idle animation the head snaps back to the idle pose and then looks in the opposite direction.
I realise that this is being caused by Unity applying additive animations as a delta from the first frame in each clip. Any static animation (like my one that holds the look left pose) has deltas of zero, and so get ignored, whilst ones that return to idle ends up with negative deltas.
I couldn't find anyway to specify which frame to use as the basis for the deltas, Unity just seems to always use the first one. (Alternatively it'd be nice to have an absolute additive animation mode that just used the values directly from the animation without calculating deltas, and then we could pre-process our turn animations in an external tool)
I'm was wondering if I could create an animation where the first frame consists of the idle pose and then the subsequent frames contain the rest of the animation so that the deltas would be correct, but I suspect that this will result in the animation glitching at the start as it snaps to the dummy idle frame before playing the rest of the animation.
Has anyone successfully used additive animation like this?
Your answer
Follow this Question
Related Questions
Blended Animation offsetting 0 Answers
Additive Animation 0 Answers
Issue with animation 1 Answer
Reference clip for Additive blending animation in Mecanim 0 Answers
additive animation wont stop playing 0 Answers