playMaker

Author Topic: GetAxisRaw (Tighter, Snappier Input)  (Read 2891 times)

Thore

  • Sr. Member
  • ****
  • Posts: 480
GetAxisRaw (Tighter, Snappier Input)
« on: August 29, 2018, 05:32:19 AM »
Hello :)

UPDATED: made an exact mirror version of GetAxis for GetAxisRaw, and the functionality below is now dubbed GetAxisRawSwitch. That seems cleaner and better.

You feel that the movement of your character could be "snappier" or "tighter", especially for a platformer? Then you want to try out this action.

What it does.
The action is identical to GetAxis, but gets the GetAxisRaw value instead. This value is not smoothed out, and makes for "snappy" input. GetAxisRawSwitch has a checkbox to switch between GetAxis and GetAxisRaw, also at runtime. This also gives you the ability to try out the difference as you play, which is good for prototyping.

A little bit of explanation
The typical way, Input.GetAxis gets the input from the player in a smooth way: assuming a controller with an analog stick, the axis value is smoothly cranked up to to 1 when you push right (-1 when left). Now, there is a twin called Input.GetAxisRaw, which does not smooth out the input. It's either hard left (-1) or hard right (1), with gives a snappier and tighter control, which might be more suitable for your game. You can also use the raw to calculate your own smoothing (see Unity's documentation linked to above, or e.g. Ease Float action).
« Last Edit: September 28, 2018, 06:06:21 PM by Thore »

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: GetAxisRaw (Tighter, Snappier Input)
« Reply #1 on: September 28, 2018, 06:29:47 PM »
Updated. I thought it's cleaner to have an exact mirror version of GetAxis as GetAxisRaw, and the one I made originally that allows to switch between both styles at runtime as a special version.