Hello there! I’m fairly new to Unity and I’m having some trouble with animation and mouse clicks.
So, what I want, is for the animation not to be running unless I click on it, and I got that much working. The thing is, with the script I made, even if the animation is still half thru, if you click on the object again it restarts.
I wanted the animation to start when you click the object, then it would run the full animation and mouse click being disbaled meanwhile, and when the animation is over then you could click again to start it again.
Here’s what I got:
using UnityEngine;
using System.Collections;
public class teste1 : MonoBehaviour
{
public string rodavidro;
// Use this for initialization
void Start()
{
this.GetComponent<Animator>().enabled = false;
}
// Update is called once per frame
void Update()
{
}
void OnMouseUp()
{
this.GetComponent<Animator>().enabled = true;
this.GetComponent<Animator>().Play(rodavidro);
}
}
Thanks a lot in advance!