So I have some animations which animate to what my player is doing.
Etc if he stands still, the sword stands still / if the player walks the sword animates “walking”.
And when i press Mouse button 1 it animates the sword “attacking”.
So when i walk and then press Mouse button 1 it attacks while i walk and when i stand still it also attacks when i press the key.
But now to the problem, when i use the “Sprint” animation which i toggled by “LeftShift” and then Press Mouse button 1, it just looks stuck, like its trying to execute the "Attack command but it can´t because the "Sprint animation is blocking it…
Here is my code, help please
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
//Attack animation
TheSword.animation.Play("Attack");
//Attack function
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
if (TheSword.animation.isPlaying == false)
{
TheSword.animation.CrossFade("Walk");
}
if (Input.GetKey(KeyCode.LeftShift))
{
TheSword.animation.CrossFade("Sprint");
}
if (Input.GetKeyUp(KeyCode.W))
{
TheSword.animation.CrossFade("Stand");
}
if (Input.GetKey(KeyCode.W)(Input.GetKey(KeyCode.LeftShift)))
{
TheSword.animation.CrossFade("Sprint");
}
}