- Home /
Additive Animation
Hello,
I've got an enemy character that I'd like to idle with his gun up while aiming at the player. My approach is to play a full body animation (an alert idle), then manually and additively blend between an extreme left and extreme right so that I can have the enemy aim at the player depending on where they are infront of him.
If I don't attempt to do this additively, manually adjusting the animation weights works fine. The enemy will look extreme left with full weight on that animation and extreme right with full weight on the right animation. As soon as I try to use normalizedTime and an additive blend mode, nothing happens at all as far as turning goes (he does still play the alert idle).
Here's some sample code I'm using:
m_Transitioning = true;
m_TransitionalAnimation = "ENY_M_Stand_CBR_idletoAlertIdle";
m_Animator.CrossFade( m_TransitionalAnimation, 0.1f );
m_Animator.CrossFadeQueued( "ENY_M_Stand_CBR_AlertIdle", 0.0f, QueueMode.CompleteOthers );
m_Animator[ "ENY_M_Stand_CBR_AimLeft" ].enabled = true;
m_Animator[ "ENY_M_Stand_CBR_AimLeft" ].AddMixingTransform( m_Waist );
m_Animator[ "ENY_M_Stand_CBR_AimLeft" ].blendMode = AnimationBlendMode.Additive;
m_Animator[ "ENY_M_Stand_CBR_AimLeft" ].wrapMode = WrapMode.ClampForever;
m_Animator[ "ENY_M_Stand_CBR_AimLeft" ].weight = 1.0f;
m_Animator[ "ENY_M_Stand_CBR_AimLeft" ].layer = 1;
m_Animator[ "ENY_M_Stand_CBR_AimRight" ].enabled = true;
m_Animator[ "ENY_M_Stand_CBR_AimRight" ].AddMixingTransform( m_Waist );
m_Animator[ "ENY_M_Stand_CBR_AimRight" ].blendMode = AnimationBlendMode.Additive;
m_Animator[ "ENY_M_Stand_CBR_AimRight" ].wrapMode = WrapMode.ClampForever;
m_Animator[ "ENY_M_Stand_CBR_AimRight" ].weight = 1.0f;
m_Animator[ "ENY_M_Stand_CBR_AimRight" ].layer = 1;
Then after that, during an update, I set the normalizedTime to -1 and 1 just for testing.
if( Input.GetKey( KeyCode.H ) )
{
m_Animator[ "ENY_M_Stand_CBR_AimLeft" ].normalizedTime = -1.0f;//0.0f;
m_Animator[ "ENY_M_Stand_CBR_AimRight" ].normalizedTime = 1.0f;
}
else if( Input.GetKey( KeyCode.J ) )
{
m_Animator[ "ENY_M_Stand_CBR_AimLeft" ].normalizedTime = 1.0f;
m_Animator[ "ENY_M_Stand_CBR_AimRight" ].normalizedTime = -1.0f;//0.0f;
}
I've also tried using the .weights option which worked before I made the animations additive. I've done almost exactly what Unity suggested in the example for Additive Animations and I've gotten no results at all.
Any help is greatly appreciated! Thanks -Matt