3

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?

3 Answers 3

2

GetAxisRaw

Always return -1, 0, -1

If you use this value, I tough you must implement acceleration system to increase/decrease your character speed.


GetAxis

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

  • set sensitive value to 10, you input will reach to 1 in ~0.1 second (approximately)
  • set gravity value to 5, you input will reach to 0 in ~0.2 second(approximately)
1

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.

-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. :)

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.