Last active
August 29, 2015 14:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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