Im trying to make a simple crouch script using animator. But it seems like my character ended up in an never ending teabag loop. I have tried to rearrange the animation boxes and ticked and unticked the looping function in them. But whenever i press the crouch key and release it it works. For some seconds, the the teabagging begins.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class crouchingScript : MonoBehaviour {
private Animator animator;
// Use this for initialization
void Start () {
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Crouch"))
{
animator.CrossFadeInFixedTime("theBeastCrouch", 0.01f);
}
if (Input.GetButtonUp("Crouch"))
{
animator.CrossFadeInFixedTime("theBeastStandUp", 0.01f);
}
}
}