Pausing a gameObject that has movement in and Update()?


Good day.

If ypu are moving the object inside the update, and you have a bool variable to know if user pressed pause, ypu just need to allow enter inside the movement functions when pause is not actice. If you also need to stop the time, do the same.

Inside the update create a

Timer functions...
Moving functions....

You are moving using the variable speed, which I assume is not updated when Time.timeScale is set to 0. Instead use Time.deltaTime (which is premultiplied by Time.timeScale), and multiply it by speed to have control over how fast it moves. Something like this:

private void Update () {
    timer += Time.deltaTime * speed;
    // this is the same you have, I just condensed it into one line
    transform.Translate(Mathf.Cos(timer) * width, Mathf.Sin(timer) * height, 0);