Reputation: 984
I am currently making a game in which I am using GetAxis
in order to move. What happens in this game quite often is that time slows to about 20% and it's causing strange behaviour.
Difference between GetAxis
and GetAxisRaw
is that GetAxis
is nicely smoothed. It seems like Time.timeScale
affect this smoothing effect and player needs really much time to get speed while in slow-motion. In GetAxisRaw
everything works like a charm.
How can I make GetAxis time independent?
Upvotes: 3
Views: 1991
Reputation: 1
I have not understood you very well, but if you mean that the fps per second affects the movement, what you should do is, for example, multiply the speed * Time.deltaTime what (Time.deltaTime) does is that if you go to 4 fps instead of going to 4 blocks per second (if the speed is 1) you will go to 1 block per second, that will make the speed independent of the fps of your device. If one block per second seems slow to you, you increase the speed and that's it. :)
Upvotes: -1
Reputation: 31
I haven't looked into it far enough yet, but I think its impossible to change Input.GetAxis to be timescale independent. Its a unity internal method, meaning you can't access it, recompile it, and then use it in your project.
Best shot would be to create your own abstraction, that uses GetAxisRaw, and add your own smoothing to get the same behaviour as GetAxis normally does.
Upvotes: 1
Reputation: 176
Always return -1, 0, -1
If you use this value, I tough you must implement acceleration system to increase/decrease your character speed.
return value between -1 to 1
By this method, you can set speed of input as you like by go to Edit > Project Settings > Input and set gravity or sensitive value
Upvotes: 2