I’m trying to move an object about the x-axis of the mouse, the code I have for now is this:
transform.position = new Vector3(Mathf.Clamp(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, MinMovement, MaxMovement), transform.position.y, transform.position.z);
The problem is that when converting from pixels to Unity world units, it always gives me the position of the camera and I want the position of the mouse already converted to Unity world units.
Does anyone know how to fix it?