Hello,
I have a problem understanding the rotation functions.
I try to do a simple free camera controller (first person flying type), so I created a script and attached it to my main camera. The aim is to move forward/backwar/left/right with W/S/A/D and turn up and down with vertical mouse mouve and turn left and right with horizontal mouse mouve.
No problem with the translate part, but the rotation only works when I do only vertical rotation (around right axis) or horizontal rotation (around up axis). When I do both, I allways have a rotation on the forward axis, that I can’t explain.
I’m using the transform up and right vectors from my camera object, they’re supposed to be actualized, but I have the same result than when I use Vector3.up and Vector3.right wich are constants.
transform.Rotate(transform.up * Input.GetAxis(“Mouse X”) * horizontalMouseSensibility * Time.fixedDeltaTime)
transform.Rotate(transform.right * Input.GetAxis(“Mouse Y”) * verticalMouseSensibility * Time.fixedDeltaTime)
I tried lots of other things but always the same result :
transform.RotateAround(transform.position, transform.up, Input.GetAxis(“Mouse X”) * horizontalMouseSensibility * Time.fixedDeltaTime);
transform.RotateAround(transform.position, -transform.right, Input.GetAxis(“Mouse Y”) * verticalMouseSensibility * Time.fixedDeltaTime);
Even when forcing 0 to the rotation around Z axis, same result.
transform.rotation = new Quaternion(transform.rotation.x - Input.GetAxis(“Mouse Y”) * verticalMouseSensibility * Time.fixedDeltaTime, transform.rotation.y + Input.GetAxis(“Mouse X”) * horizontalMouseSensibility * Time.fixedDeltaTime, 0, transform.rotation.w);
Did I miss something ? Thanks for tour help.