Assume I have two animation cycles:
Both assume that the model's pivot is on the same level as the model's feet.
Now I also have two animated transitions:
- Get on all fours while walking
- Climb onto a (table)
The first is not too complex. The model walks upright, then gets down on all fours (animation 1) and crouches. Pivot remains on the same level, all fine.
What I want:
However, I can't get my head around the second transition. I want the model to
- walk up to the table (pivot on ground level)
- climb onto the table (animation 2) (pivot..?)
- crouch on the table (pivot on table level, 1 m above ground)
What I have:
The climbing animation (2) assumes pivot to remain on ground level and simply animates the model's climbing up. I built a StateMachineBehaviour which raises the model to the table level as soon as the climbing animation is complete. From then on the pivot is on table level and the crouching can continue.
This seems to work fine in a standalone application, however, in multiplayer, where the models' transform and animator state are not necessarily synchronized in the same frame, this prooves problematic. One can clearly see the model jump when the change in the model's position arrives one frame earlier than the switch from climbing to crouching animation.
What I tried:
I thought it might be a better idea to have the pivot move gradually from ground level to table level over the duration of the climbing animation (2), instead of having one instant jump at the end. This way network synchronization would be much more robust because of the relatively small change per frame. Also this approach would much closer resemble the actual thing that's happening in the real world, which is generally a good thing. I tried offsetting the root transformation of the animation clip, and accomodate the modification by adding the negative offset to the root bones. This however did not work, as there seems to be no animatable translations in Mecanim animation clips. So im stuck at this approach.
Is there a better way? A simpler way? How are you guys tackling this?