- Home /
Problem with "function OnMouseDown"
Hi! I've problem with the function mouse. I Did this script, and I put it into GameObject that has Mesh Collider, and Animation. But if I click on the GameObject, the animation dont start. If I change the script whit button Input, It work... es: (ifInputGetKey(click a taste)) The problem is this script, or maybe some setting..
Image: http://oi41.tinypic.com/24etijs.jpg
Script:
#pragma strict
var AnimCancelloIngresso : String;
function OnMouseDown ()
{
if (Input.GetMouseButtonDown(0))
{
animation[AnimCancelloIngresso].speed = 1.0f;
animation.Play(AnimCancelloIngresso);
audio.Play();
}
}
thanks for the help ! ;)
I created a project Test, but not work! I set all correctly, maybe some settings are wrong? :(
I make a picture: http://oi41.tinypic.com/14o0v82.jpg
Answer by PAEvenson · Jul 16, 2013 at 07:27 PM
Remove the Input.GetMouseButtonDown(0) if statement. That is used for in Update or checking to see if the mouse is actually down. The OnMouseDown function gets triggered when the object is clicked.
function OnMouseDown ()
{
//if (Input.GetMouseButtonDown(0))
//{
animation[AnimCancelloIngresso].speed = 1.0f;
animation.Play(AnimCancelloIngresso);
audio.Play();
//}
}
Your answer

Follow this Question
Related Questions
Controlling animation with mouse 0 Answers
Third person animation 0 Answers
Making a character point his gun at the mouse 2 Answers
Prevent animation from restarting every time it is clicked 1 Answer