Comments and answers for "localRotation rotates by 180°"
http://answers.unity.com/questions/1564826/localrotation-rotates-by-180.html
The latest comments and answers for the question "localRotation rotates by 180°"Comment by xNIkurasu on xNIkurasu's comment
http://answers.unity.com/comments/1564930/view.html
oh and y is:
y -= Input.GetAxis("Mouse Y") * lookSpeed * Time.deltaTime;
y = Mathf.Clamp(y, -80, 80);Mon, 22 Oct 2018 21:34:02 GMTxNIkurasuComment by xNIkurasu on xNIkurasu's comment
http://answers.unity.com/comments/1564928/view.html
Oh yeah my bad:
else if(!isGrounded)
{
var xRot = Input.GetAxisRaw("Mouse X") * Time.deltaTime * lookSpeed;
fpsCam.transform.localRotation = Quaternion.Euler(y,xRot,0);
}Mon, 22 Oct 2018 21:33:18 GMTxNIkurasuComment by JVene on JVene's comment
http://answers.unity.com/comments/1564915/view.html
I'd need to see your updated code, because in the example you've posted you only request the X axis from the mouse.Mon, 22 Oct 2018 20:52:10 GMTJVeneComment by xNIkurasu on xNIkurasu's answer
http://answers.unity.com/comments/1564890/view.html
Hello! Thanks for the answer! Sadly, that only partly fixed my problem. My camera does not rotate by 180° anymore, which is a good thing, but now i cant really move my camera on the x-axis anymore. It looks like its being forced back to the rotation of the parent object. I understand that child objects inherit the position and rotation of the parent object, but i was hoping i could use localRotation, but, for some reason, it only works on the y-axis. Do you perhaps have any idea why that is the case? Thanks again for the help.Mon, 22 Oct 2018 19:31:15 GMTxNIkurasuAnswer by JVene
http://answers.unity.com/answers/1564841/view.html
There is a lot one could say about what is wrong here, but let's start with the last line because that leads to an understanding that fixes everything else.
It appears you're familiar with Euler angles (your first line in the code block), but when you fashion a Quaternion (in the last line), you're fashioning the Quaternion with 4 parameters, and they are not Euler angles. Nothing in the constructor of a Quaternion will make much sense if you're not really familiar with the mathematics of quaternions (the subject of math beyond that of Unity). A quaternion (and thus Unity's Quaternion class) represents a complex number, like the imaginary numbers taught in algebra whereby the square root of a negative number becomes possible. The complex numbers taught in algebra are generally related to a 2 dimensional representation (like the imaginary numbers which have two values, an imaginary part and a real part). Quaternions, however, are complex numbers in 3 dimensions. None of the 4 parameters (x,y,z,w) have any meaning relative to rotations in Euler angles. This is the problem you're having. You are providing a value you intend to interpret as an angle in degrees, but the y parameter to the Quaternion constructor has no relationship to such an angle in the y axis.
----------
To fix that, and therefore propagate that upwards to the rest of your code, look up the static function Quaternion.Euler, which forms a correct Quaternion object given Euler angles in 3 axis, as you're expecting. You could also consider using the eulerAngles property of localRotation as an alternative approach, or at the least in your translation between any quaternion and an orientation in 3 axis.Mon, 22 Oct 2018 17:30:36 GMTJVene