- Home /
Get smooth input when Time.timescale == 0
I've run into issue that I cannot gradually pan the camera when the game is paused with Keyboard Input. For some reason, Joystick Input returns float values from "GetAxis" even when Timescale is set to 0, but using WASD wont change. Changing to AxisRaw will work, but there is no smoothing anymore to both Joystick and Keyboard. How can this be solved without using Raw Input?
.
Vector3 movementXZ = new Vector3 (
Input.GetAxis ("Horizontal") * Time.unscaledDeltaTime,
Input.GetAxis ("Vertical") * Time.unscaledDeltaTime, 0);
Answer by Koyemsi · May 05, 2018 at 01:29 PM
I think this can't be done because of the timescale set to zero, because your scene is like "frozen in time". Even if the inputs are correctly read, nothing will happen unless your timescale becomes positive again. If you want any animation to go on after the player pressed a pause button, you should implement your pause differently. Perhaps one solution would be to :
manually disable all the scripts that control player, enemies and so on (you might have to store some info about their position and movement)
wait for your cam to finish its movement,
and only then, set the timescale to zero if you need to.
This answer is wrong. He's using unscaled time! If you read the question you'll see he also mentioned that the the code already works for raw input. You can run many things while on pause, like animations and scripts, and yes, inputs too, but horizontal and vertical do seem to have a problem if they're not raw. Seems like a bug.
You're probably right, and I admit I made a mistake. I was convinced that everything was like "frozen" when timescale was zero, but it seems to be wrong. So I have absolutely no idea of what's going on, talking about that smoothing issue. Sorry I couldn't help.
@calpolican no they're not wrong, you're the one who's partially wrong and no its not a bug
Input.GetAxis() is frame rate independent, which is a fancy way of saying Unity multiplies it by Time.deltaTime internally. When Time.timeScale is 0, deltaTime is 0 so the entire result of GetAxis is also 0. Don't believe me? take a look at the docs https://docs.unity3d.com/ScriptReference/Input.GetAxis.html
GetAxisRaw on the other hand is not frame rate independent thus it works.
Your answer
![](https://koobas.hobune.stream/wayback/20220612162046im_/https://answers.unity.com/themes/thub/images/avi.jpg)