Animation in World Space

Hi folks, I’ve got a common issue with what appears to be a hidden solution. I’ve got a game with tons of finished mo-cap animations for our characters and enemies. Many of these animations (transitional animations mostly…aka, the animations that play from one loop to another like idle to aggressive) shift the actual character off of the origin.

So when I play, for instance, the character’s idle animation and then play the transition from idle to aggressive, he shifts off of the origin a bit (rotations, of course, end at arbitrary values also). If I then followed with an aggressive idle animation (gun up), he’ll pop back to the local origin of the blank object above the rig in the hierarchy and animate from there. I obviously need to avoid that.

The only way I really see this being feasible is to have a root game object that the rest of the hierarchy is a child of. That game object sits between the characters feet and moves with him within the animation but is always on that floor plane between his feet (or, depending on the animation, an equivalent location). When one of these transitional animations is done, I take that root and zero him out so his position/orientation is 0,0,0.

The next time an animation plays (for instance the aggressive idle), the rest of the rig would still be correct relative to the parent, and the parent (being this floor plane root) will now start (first frame of that animation has the root at the origin of the scene) at the correct position, avoiding any popping.

I can only do this once that transitional animation has finished so I know the this floor plane root won’t get animated off the center, thus causing a pop in the animation.

Does all of this make sense? My characters’ animations move/rotate them in world space and when I play the next animation, I need them “back at the origin” so it plays correctly relative to their new location/orientation.

Any help would be immensely appreciated, I don’t have a ton of time on this one. :slight_smile:

People usually make “in-place” animation to solve this problem.

Thanks Paulius, I thought I mentioned that we’ve been given hundreds of mo-capped animations. We don’t really have the option to remake the animations, heh.

I do think we’ve got a potential solution on the horizon. It looks as though we were able to add a node that moves with our characters hips but sits on the floor between his feet. When an animation ends, I’ll zero that node out (the rest of the rig is a child of this node) after moving the base node to that location. Then I’ll play the next animation which should start with that node zero’d out, so there shouldn’t be any hiccups in animation or anything.

We’ll see…

So we were able to implement world transforms/rotations with all of the mocap data we were given using a root node that tracked the global movement. I do, however, have a slightly unrelated problem…

Right now I determine if the enemy needs to go to a certain state (and therefore a certain animation) and so I call his transitional animation to get there. For instance, the enemy needs to go to an Alert State from his Idle state so I call the IdleToAlertIdle animation. I then have the following code inside an update (hardcoded the animation for ease of testing):

if( !m_Animator.IsPlaying( m_TransitionalAnimation ) )
	m_TransitionalAnimation = null;
	m_Animator.CrossFade( "ENY_M_Stand_CBR_AlertIdle" );

So the above code works fine. The RecalibrateBase() function handles moving my nodes around so if the transitional animation moved the mesh off of the origin, it’s fixed. The problem is the cross-fading. Since technically there’s no animation playing since the transitional animation finished, the enemy pops to the new alert idle. There’s nothing to actually blend from.

Do I need to add a transitional animation for each of these scenarios? Is there a way to tell the enemy to blend to the new animation without needing an active animation? The enemy still remains in the final frame’s bone positions since no animations are playing, he doesn’t pop to a T-Pose. I literally just want him to blend from that final pose (from the just finished and no longer active transitional animation) to the new animation.

If anyone can help, that’d be fantastic. I tried CrossFade(), Blend(), and I tried setting the transitional animation’s wrapmode to ‘ClampForever’ but the crossfade of the enemy blends between the new idle and the old animation (which still has the offset root so he blends from the wrong position/orientation).

Thanks for the help!