Tag Archives: Unity

Input.GetAxis vs Input.GetAxisRaw

I recently started getting into some Unity programming with C# and was working on a character controller script to make a simple box move on a 2D plane. I was using the Input.GetAxis method to read the input from the keyboard. After a little bit of playing around, I wasn’t satisfied at all with the way the character was moving, it seemed like there was a little bit of delay when the key was pressed and also when I let go of a direction key, the character still moved a little bit as if it had some momentum. None of the physics settings seemed to fix this issue. After a bit of digging around, I found out that it was not the physics that was causing the sluggishness and over shooting, it was the input method. The Input.GetAxis method contains an inbuilt smoothing filter which automatically smooths out the key press. This means that the function won’t give an immediate full response to the key press, the return value will gradually increase from 0 to 1 as the key is pressed and decrease from 1 to 0 as the key is let go. I personally find this smoothing quite annoying and it feels sluggish for the kind of movement I want. The alternative is to use the Input.GetAxisRaw which gives a 1 when the key is pressed and a 0 when it is not. Simple and straight up.

Dissolve shader

This Shader uses the alpha value of the applied texture to clip parts of the mesh that fall below a specified ‘dissolve amount’ property. The outline of the mesh can be given a custom color and thickness. An artist can manually paint the alpha channel of the texture to achieve a desired dissolve pattern as darker pixels dissolve earlier than lighter pixels.

Object Sway Shader

This Shader uses the R, G and B components of the vertex color on a mesh to sway corresponding vertices via three sets of user defined direction, amplitude and frequency values – one for each component. The RGB values also linearly affects the frequency of sway. Using RGB values allows the artist to paint complex patterns for the mesh to sway. This can be used to create dynamic objects like foliage, flags, curtains etc.