ablaszkiewicz1
ablaszkiewicz1

Reputation: 984

GetAxis smoothing and Time.timeScale in Unity

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

Answers (3)

akkaraul420
akkaraul420

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

David K
David K

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

さんですVaya
さんですVaya

Reputation: 176

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)

Upvotes: 2

Related Questions