I’ve been creating games using Unity for quite some time, and for the first time i’m trying to switch my focus to the mobile theme.
Made a very simple platformer, and after a lot of investigations, i just can’t get my head around how to achieve the same results as i’m seeing with Unity’s input system, the old input system.
When i’m using Input.GetAxis("Horizontal");
and i’m pressing on a button i get a small ramp-up of a -1 to 1 float, when i’m using the new input system with touch on mobile i’m always getting 1 or -1 without any ramp up which cases the player to just shoot out running instead of slightly ramping up.
How do i get the same effect in mobile? pressing on a button and slowly getting 0-1 or 0 -(1) ?
My actual movement code isn’t complicated its just this (in fixedUpdate of course)
rigidBody2d.velocity = new Vector2(_horizontal * _movementSpeed, rigidBody2d.velocity.y);
Hope my question in clear, if more info is needed please let me know.
@Kurt-Dekker thanks so much for you answer i’ll try to implement it.
So that’s basically the difference between the old input system’s “GetAxis” and “GetAxisRaw”? that raw that’s have that smoothing and the regular one has?
I personally ALWAYS use Input.GetAxisRaw() because I find it more centralized to control the “smoothness” in code (always using the above thingy I posted) than to control the smoothness in the InputManager, which of course is totally global to the entire project.
I might use Input.GetAxis() in simple demos and one-offs though.
And sometimes you want even more-custom behaviour, like smoothing as long as are gathering speed, but if you are REVERSING yourself you might want much higher rate of change of the direction to make the game feel snappier.
This type of custom input filtering and tuning it well is pretty much what sets apart incredibly polished platformers (such as pretty much EVERYTHING from Nintendo!) from less-polished games.