- Home /
Mouse Click Animation
I have a character, you can say it's an inspector.. My Question is how do I animate the guy when I click with the mouse button. I did try in javascript
function OnMouseOver () { if (Input.GetMouseButtonDown(0)) { animation.Play("CHECK"); } }
but my problem is that it only plays when i have the mouse button down, when I release it, its stops. I want my whole animation to play and not just a part of it.
Please help me out..
Comment
Answer by Frix · Nov 30, 2012 at 11:57 AM
I'm not too experienced with coding, but it might be because you've only put it on 'GetMouseButtonDown'.
Answer by darker9999 · Nov 30, 2012 at 12:41 PM
I have not used animation much and this is a bit of work around, but you could use something like:
function OnMouseOver ()
{
if (Input.GetMouseButtonDown(0))
{
play=true;
}
}
function Update ()
{
if (play == true)
{
animation.Play("CHECK");
}
}