Hi 😊
I'm trying to animate a pinball paddle depending on the user's input using Unity's Animator component.
Expected behavior:
Hold down the "A" key to cause the paddle to go up.
Release the "A" key to cause the paddle to go down.
Current result:
The paddle works as expected however, if you hold down the "A" key until the paddle is at the end of it's animation and release, the paddle will instantly return to its resting position.
Here is also a snippet of the code that is effecting the animator.
public class PaddleController : MonoBehaviour
{
Animator anim;
void Start() {
anim = GetComponent<Animator>();
}
void Update() {
if (Input.GetKey(KeyCode.A)) {
anim.Play("ActivatePaddle");
anim.SetFloat("direction", 1);
anim.SetBool("isResting", false);
} else {
anim.SetFloat("direction", -1);
anim.SetBool("isResting", true);
}
}
}