Question by
Brent11232 · Feb 28, 2016 at 09:37 AM ·
animation script
How to play an Animation when you left click
I have tried to get this sword on my 2d character to swing every time i click. I'm new to coding so i don't really know much. I have tried looking everywhere but none of the scripts or tutorials i find work please help. I already have the animation.
Comment
if you have done your animation in the Animator window make a bool variable "clicked" & make animation play if it true but don't set it true in Animator now from your script accesses the animator to set the clicked variable true any time you want
Animator anim;
void Start()
{
anim = GetComponent<Animator> ();
}
// i don't know what do you mean " left click " this code when finger release the A button
void Update()
{
if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.A))
{
anim.SetBool ("cliked",true);
}
}
Sorry how do i add a bool variable?and thankyou so much for helping. maybe could i get screen shots? thankyou in advance. and somewhere there is an error