Hi everyone,
I want to make transition from Idle to other animation through single click, also count clicks. However while transition works more or less, the count registers 2 clicks after one mouse button press. Any advices? Code I’m working with:
public class KnightController : MonoBehaviour {
//Rigidbody2D rigidBody2D;
Animator anim;
int count = 0;
// Use this for initialization
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
OnMouseOver();
}
private void OnMouseOver()
{
if (Input.GetMouseButtonDown(0))
{
anim.SetBool("IsBeingClicked", true);
count++;
print(count);
StartCoroutine(Wait());
}
else
{
anim.SetBool("IsBeingClicked", false);
}
}
IEnumerator Wait()
{
yield return new WaitForSeconds(.6f);
}
}