Question by
Bryanhag · Dec 05, 2018 at 01:46 PM ·
animationscripting problemupdateupdate functionanimation controller
Slow down animation with constantly pressing mouse,I have to keep pressing the mouse to slow the animation BlendSpeed.
How do I slow down the animation without pressing the mouse constantly. Please help before I go mad. Thanks
public Animator animator;
float speedUp = 1f;
float speedTime = 100f;
float speedGo = 1f;
float min = 100f;
// Use this for initialization
void Start()
{
animator = this.gameObject.GetComponent<Animator>(); //get the animation
}
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetMouseButtonDown(0))
{
animator.SetBool("ClockStart", true); //set anim path open
animator.SetFloat("BlendSpeed", speedUp); //add speed to blendspeed
}
if (Input.GetMouseButtonUp(0))
{
StartCoroutine(SlowWheel());
animator.SetFloat("BlendSpeed", speedGo); //sub speed to blendspeed
Debug.Log("SpeedGo is: " + speedGo);
}
}
IEnumerator SlowWheel()
{
while (min > 0.1)
{
speedGo = min / speedTime;
min -= Time.deltaTime;
yield return speedGo;
}
}
,Is there anyway to play the slow down animation without constantly pressing the mouse? Script attached, any help please.
public Animator animator;
float speedUp = 1f;
float speedTime = 100f;
float speedGo = 1f;
float min = 100f;
// Use this for initialization
void Start()
{
animator = this.gameObject.GetComponent<Animator>(); //get the animation
}
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetMouseButtonDown(0))
{
animator.SetBool("ClockStart", true); //set anim path open
animator.SetFloat("BlendSpeed", speedUp); //add speed to blendspeed
}
if (Input.GetMouseButtonUp(0))
{
StartCoroutine(SlowWheel());
animator.SetFloat("BlendSpeed", speedGo); //sub speed to blendspeed
Debug.Log("SpeedGo is: " + speedGo);
}
}
IEnumerator SlowWheel()
{
while (min > 0.1)
{
speedGo = min / speedTime;
min -= Time.deltaTime;
yield return speedGo;
}
}
Comment