Heres animation trigger script
function Update () {
if(Input.GetKeyDown("f")) {
animation.Play("Gun and run");
}
}
I want to set it so if i hold down f the animation loops and when i let go of f the animation stops
Heres animation trigger script
function Update () {
if(Input.GetKeyDown("f")) {
animation.Play("Gun and run");
}
}
I want to set it so if i hold down f the animation loops and when i let go of f the animation stops
function Update () {
if(Input.GetKeyDown(“f”)) {
animation.Play(“Gun and run”);
}
if(Input.GetKeyUp(“f”)) {
animation.Stop(“Gun and run”);
}
}
note that the answer provided in the comments is incorrect since GetKeyDown will only return true for the frame the key is pressed, not for the frames afterwards when it’s kept down. It would work if he’d had used GetKey