Convert mouse X position into a horizontal float

Good morning! Im stuck on a small issue. Im trying to convert the mouse x into a horizontal float clamped at -1/0/1. Basically, if the mouse is on the left side of the screen the value would be -1, if the mouse is in the center the value would be 0 , and if on the right the value would be 1. Any help as always is greatly appreciated! Thanks!

Mathf.Clamp((Input.mousePosition.x / Screen.width) * 2 - 1, -1.0F, 1.0F)

The mouse position is in screen space, of you convert from screen point to viewport you’ll have a Vector2 with values from 0 to 1. Subtract 0.5 from the x and multiply by 2 to convert from a range of 0 to 1 to -1 to 1.