I have 4 animations made inside unity.
Shoot
IDLE
ADS
ADS OUT
The problem is that when I have my shoot animation on a layer above all the others, it plays the whole animation with all the curves set but it overrides all the other animations when playing.
Also, if I set it below the other animations or inbetween and even not a layer at all, the animation does not play the position change, If I can get the position animation to show with the shoot animation instead of just the rotation, that would be great!
Hope it wasn’t confusing!
Here’s the code.
var firerate = 2;
var adsspeed = 1;
function Update () {
//LAYERS
animation["IDLE MP5"].layer = 1;
animation["MP5 SHOOT"].layer = 2;
animation["ADS MP5"].layer = 3;
animation["ADS OUT MP5"].layer = 3;
//WRAPMODES
animation["MP5 SHOOT"].wrapMode = WrapMode.Loop;
animation["IDLE MP5"].wrapMode = WrapMode.Loop;
animation["ADS MP5"].wrapMode = WrapMode.ClampForever;
animation["ADS OUT MP5"].wrapMode = WrapMode.ClampForever;
//SPEEDS
animation["MP5 SHOOT"].speed = firerate;
animation["IDLE MP5"].speed = 1;
animation["ADS MP5"].speed = adsspeed;
animation["ADS OUT MP5"].speed = 1;
//BLEND MODES
animation["IDLE MP5"].blendMode = AnimationBlendMode.Blend;
animation["ADS MP5"].blendMode = AnimationBlendMode.Blend;
animation["ADS OUT MP5"].blendMode = AnimationBlendMode.Blend;
//SHOOTING
if (Input.GetButton("Fire1"))
{
animation.CrossFade("MP5 SHOOT", 0.5);
}
else
{
//IDLING
animation.Stop("MP5 SHOOT");
animation.CrossFade("IDLE MP5", 0.5);
}
//ADS
if (Input.GetButton("ADS"))
{
animation.CrossFade("ADS MP5", 0.05);
}
else
{
//ADS OUT
animation.CrossFade("ADS OUT MP5", 0.2);
}
}
No, that didn't work for me. The thing about the PlayOnce and layer part of the shoot animations is the aim down the sight animation. That would snap it back to the shoot animation if you hold aim and shoot down.
– VicciGames