hello, so i wanted to clamp my x rotation between 9,-10 so i dont have a player that faceplants his self into the ground (see the photo down bellow).quarternions and transform is al a bit new for me so i dont know how to do this i tryed to google it but that didnt work out but its really about the peace at the tranform.rotation i want there the clamping Code (CSharp): moveDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); if (im.rightClick) { allowPlayerRotation = 0.008f; } if (!im.rightClick) { allowPlayerRotation = 0.1f; } transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(cam.transform.forward),allowPlayerRotation); moveDir = transform.TransformDirection(moveDir); anny one ideas?
Don't bother looking at the rotation in Inspector, it'll only cause more confusion when dealing with rotation from my experience. Use Debug.Log(transform.rotation) if you want to understand why your code doesn't work. If I recall transform.rotation returns 0 to 1 not in degrees. From Unity Doc - "If you want to match values you see in the Inspector, use the Quaternion.eulerAngles".