So, my basic problem is this: I can’t seem to make Unity detect small deviations in joystick movement around the north, south, east and west corners.
To elaborate:
I have a simple bit of code in place to rotate my top-down 2D character using the right analog stick of a gamepad:
float angle = Mathf.Atan2(Input.GetAxis("Joy1 Horizontal"), Input.GetAxis("Joy1 Vertical")) * Mathf.Rad2Deg;
myObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
However, I noticed that when I move the joystick’s angle anywhere close to the north, south, east or west directions, the character would “snap” to that direction. For example, if I point directly north so that my horizontal and vertical output is 0,1, and then move the joystick slightly to the east or west, my output remains at 0,1 for a few degrees. I would like for ANY small amount of joystick movement to be detected, to create a smoother feel for the player.
Currently, I have the sensitivity for my two axes set to 1, and my dead zone set to 0.001 (which is probably way too low), though I’ve played around with these values extensively to no avail. There is no problem with the physical joystick itself-- the snapping I’ve mentioned does not occur in certain similar games that I’ve tested.
Any ideas? It seems like this must be a common issue for anyone doing a game that relies on joystick aiming.