Skip to content

Instantly share code, notes, and snippets.

@DomDomHaas
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DomDomHaas/e93b2a35a0bfebb1e794 to your computer and use it in GitHub Desktop.
Save DomDomHaas/e93b2a35a0bfebb1e794 to your computer and use it in GitHub Desktop.
Use a deadzone for very used, old controllers which aren't percise anymore
// http://www.third-helix.com/2013/04/12/doing-thumbstick-dead-zones-right.html
float deadzone = 0.25f;
Vector2 stickInput = new Vector2(Input.GetAxis(“Horizontal”), Input.GetAxis(“Vertical”));
if(stickInput.magnitude < deadzone)
stickInput = Vector2.zero;
else
stickInput = stickInput.normalized * ((stickInput.magnitude - deadzone) / (1 - deadzone));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment