How to get maximum value of a direction working with Joysticks?
Hey mates, I'm working on a simple joystick game. For this I need the maximum value of vector that returns the joystick, in 8 ways. (Top, down, left, right, diagonal top-right, diagonal top-left, diagonal down-right, diagonal down-left). But every time I move the joystick it gets all values that are in its way. So, how can I do to only get the maximum value of each axis when I'm moving the joystick?
Thanks!
Answer by Kardall · Mar 24, 2017 at 08:24 PM
There is a gentleman that had exactly this, http://answers.unity3d.com/questions/804075/how-to-get-overall-intensity-for-each-joystick-axi.html
although, he has a type-o in the code example:
float mag = Mathf.Clamp01(new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")).magnitude);
Your answer
Follow this Question
Related Questions
Twin stick control 2D 1 Answer
nested two joysticks 0 Answers
Joystick Axis Not Being Read in Unity 0 Answers