private void MappingExamples() { // Maps 10 from [-250..250] to [0..10] Debug.Log(MathHelper.MapClamped(10f, -250f, 250f, 0f, 10f)); // => 5.2 // Applies a deadzone to a joystick input (positive and negative) to make sure that // little imperfections in the stick resting position don't make the character move Debug.Log(MathHelper.ApplyJoystickDeadzone(0.1f, 0.2f)); // => 0 Debug.Log(MathHelper.ApplyJoystickDeadzone(0.2f, 0.2f)); // => 0 Debug.Log(MathHelper.ApplyJoystickDeadzone(0.21f, 0.2f)); // => 0.21 Debug.Log(MathHelper.ApplyJoystickDeadzone(0.3f, 0.2f)); // => 0.3 Debug.Log(MathHelper.ApplyJoystickDeadzone(1f, 0.2f)); // => 1 Debug.Log(MathHelper.ApplyJoystickDeadzone(-0.1f, 0.2f)); // => 0 Debug.Log(MathHelper.ApplyJoystickDeadzone(-0.2f, 0.2f)); // => 0 Debug.Log(MathHelper.ApplyJoystickDeadzone(-0.21f, 0.2f)); // => -0.21 Debug.Log(MathHelper.ApplyJoystickDeadzone(-0.3f, 0.2f)); // => -0.3 Debug.Log(MathHelper.ApplyJoystickDeadzone(-1f, 0.2f)); // => -1 }