Finding distance between analog stick center and current position

I can get my xbox controller to work with the analog stick by using Input.GetAxisRaw(“Horizontal”) or Input.GetAxisRaw(“Vertical”), however, I want to be able to determine the distance from the resting position of the analog stick and the current position of the analog stick - no matter which direction it is swayed in.

I want my player character to move in varying speeds depending on how far the analog stick is swayed, so the only way I know to determine that is by figuring out how far the analog stick is pushed from its center (or resting position).

Are their any techniques, mathematical algorithms, or alternative approaches someone could suggest? Thanks so much!

The stick at rest is Vector2.zero, so you don’t need to bother with Distance. Just get the magnitude of the XY input vector.

new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).magnitude

Thank you, I’ll try this out today!

Just tried it out. It works as you said, so I very much appreciate the assistance. I do, however, have one question. The analog stick produces a magnitude of 1 or slightly more when I push my analog stick in the downward/right direction, but only a magnitude of approximately 0.92 if I push it in the upward/left direction. Any ideas on what might contribute to this? Thanks!

You might try re-calibrating the controller and see if that has any effect.