Skip to content

Instantly share code, notes, and snippets.

@DomDomHaas DomDomHaas/stick-deadzone
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.