I need to rotating game object called gun.but I need to clamp it to two floats. I am using get axis vertical
I don’t really understand what ur trying to achieve but I think this could help you @deepikaratnayaka62
float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY; xRotation -= mouseY; xRotation = Mathf.Clamp(xRotation, -90f, 90f); gun.transform.rotation = Quaternion.Euler(xRotation, 0, 0)
This code clamps the rotation of the mouse’s vertical axis to a max of 90 degrees and a minimum of -90 degrees. I hope this helps.