How do I make an animation activate by clicking the mouse button in unity5?
How do I make an animation activate when I click the left mouse button? I have already created the animation, its a sword swing, but I have no idea what to do from there. I just have the animation created. I just need a script or something that will make it activate only when I press the left mouse button. Thanks!
void Update()
{
if (Input.Get$$anonymous$$ouseButtonDown(0)) //left mouse button
{
//play animation
}
}
http://docs.unity3d.com/ScriptReference/Input.Get$$anonymous$$ouseButtonDown.html http://docs.unity3d.com/ScriptReference/Input.Get$$anonymous$$ouseButtonUp.html
I keep getting the error "Assets/Scripts/AniamtionClick.cs(1,6): error CS0116: A namespace can only contain types and namespace declarations "
you have to add a bool variable in Animator window & animation work only if it true then in script enter the Animator to set the bool to true each time you click .