Object don't rotate correctly
So i have a camera attached to a gameobj. And i made a code like this to controll camera rotation in X axis but it seems not correct *I have created ref. Of my camera named thisCamera
Void FixedUpdate()
{ Float inputX = Input.GetAxis("Mouse Y") Float currentXRotation = thisCamera.localEulerAngles.x + inputX
Vector3 cameraRotation = new Vector3(Mathf.Clamp(currentXRotation, -85f, 85f), 0f, 0f)
thisCamera.transform.localEulerAngles = cameraRotation }
The code works, it detects input and assign it to the variable and my camera rotated but not as i want to be, i've set the limits to -85f to 85f, but the camera only allows me to rotate between 0f - 85f and when i passed 0f, the camera instantly returned its position 85.00000001, did i missing something?
Answer by Hsni · Jun 28, 2018 at 12:13 PM
What you want can be efficiently achieved using LookAtTarget script in standard assets, under Camera assets.