Mecanim - Precise animation control.

I’ve been having issues with mecanim, and precision control of a character in my game world.
I have setup animations in maya, utilizing root motion so I can control the characters position in maya (instead of code).

I have been very careful in animating to ensure that a walk / run / jump / roll… etc… cycle has a very exact distance traveled. So for example when my character runs I know that at the end of a step, he will be exactly 2 units away from the last step. I also have a leaping animation for use when grabbing an edge that is 4 units away from the last step.

My thinking here is so that when I setup my world every obstacle will be setup via grid snapping so hands grab bars / ledges, feet land on ramps / walls / ground etc. Other than these types of actions the user will not control the steering or speed of the character, so precision is very important since the user will not be able to correct.

My problem is that using root motion (and I have played with all the baking options within unity for orientation, y, xz) gives you inherently unpredictable results. For example if my leap animation starts when the run cycle is at 99% instead of 100% the slight rotation of the pelvis causes the character to jump slightly to the side instead of forward. I have setup my transitions so that a bool must be true (set by user via input or by trigger at the start of a gap) and the animation exit time is 1 with 0 blending between clips (Note to unity tech: we need input fields here instead of just sliders… Interestingly if you remove an animation from a state then view the transition you get fields because unity is unable to show a “preview” of the transition)…
In my mind this should result in something similar to a video editing timeline where one clip swaps for another, at the exact world position that the previous clip ended (yes animations line up from one to the other)

Maybe the problem is since deltaTime is variable you can’t guarantee a clip will ever be at exactly 100% so root motion isn’t where I would expect it to be?

Maybe I’m going about this all wrong and should use the legacy anim system, and control my character position via code ( but unity claims the legacy system will be phased out, so this should be possible in mecanim… perhaps use mechanim, but remove root motion)?

Maybe I need a bone in my hierarchy that supersedes the pelvis that has 0 rotation and 0 weight to the verts and use that as my root motion ( I don’t see this working for complex animations that involve lots of turning / twisting ) ?

In a related matter:
I am trying to make my actions a little more dynamic by changing the jump length / height Thinking that I should just be able to modify rootPosition in LateUpdate() over the span of the animation, I have so far been unable to get it to respond at all. Yet updating rootRotation works. Example.

anim.rootRotation += additiveRotation; // THIS WORKS.... New rotation value (I'm currently getting this from mobile device tilt amount )
anim.rootPostion += new Vector3(0, 2 * Time.deltaTime, 0); // DOESN'T WORK... This should raise the character up 2 unit per second, but has no effect.

Any Ideas / insights?
I so far have not seen any tutorials / manual that goes beyond the very basics of mecanim. Anybody have links?

Thanks for reading, I know it wasn’t short.

Unity 4.0.1f2 Free
Windows 7 x64

Yes its possible to use mecanim without root motion and do the root motion using code rather then using an animation. You lose the sense of realism procured by root motion but gain control which is what you are looking for it seems.

And about leaping and grabbing there is a demo for mecanim where the character jumps to grab on to a container and you can set the container as high as you want and he will reach it with correct height and position using IK. This would allow you to perform the jump from any distance instead of having to calculate the distance and try to match it exactly like you are doing now. So that might be a better option but IK is a pro only feature.

Yeah at the moment I don’t feel justified in purchasing unity pro, although ik, navmesh and shadows would be nice. I need to get further along in my project before I decide if i’ll pull that trigger.

I know I’m trying to be much more accurate with my animation than most would probably ever need to… but I can’t see how this unpredictability isn’t a problem for others? I haven’t seen any questions like mine out there. Take for example my jumping scenario… The hips in my run animation pivot a good amount (~10 degrees) If the user hits the jump button at the point the hips are the most angled away from +z… the character ends up jumping 10 degrees off center, I don’t see that working for any game. Perhaps I have a bad setup of bones in my anim? which is why I wrote

I don’t want to loose root motion if possible. I’m still early on in this concept but I think having root motion and some of the other benefits of mecanim will be very helpful down the road.

Suppose I can bake all root animation in unity but export the pelvis animation as a separate curve out of maya, Then reapply that curve plus any other motions I need in code… but that feels like a dirty hack and should be unnecessary.