Hi guys I have the following script to activate a keyboard animation. How could I modify the script so that when I press the key the animation starts while if I leave the key the animation pauses? Thank you Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class Benna : MonoBehaviour { public Animator anim; // Use this for initialization void Start() { anim = GetComponent<Animator>(); } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.V)) { gameObject.GetComponent<Animator>().Rebind(); anim.Play("Benna"); } } }
https://answers.unity.com/questions/1211034/how-to-pause-an-animation.html Sorry, got my answer wrong, would something like this work? Let me know, it seems like you just set the speed to 0 when the button is pressed.
Hi Lethn not really. In practice I have to move a part of a hydraulic machine and I would like to keep the "V" key pressed to start the animation while leaving the "V" key the animation pauses then resume if I press the button again.
Animator have manual time mode. Start playing immediately and advance time by Time.deltaTime if key is down.
Hi palex-nx I'm not very familiar with scripts, could you put the Time.deltaTime in the script up? Thank you so much.