Quantcast
Channel: Latest Questions by jjmontes
Viewing all articles
Browse latest Browse all 6

Clamp camera quaternion so you can't look up or down more than 90 degrees?

$
0
0
I'm trying to limit my camera movements in order to avoid it "flipping" when you look up or down further than 90 degrees, while keeping the Up vector always pointing up. I'm currently using the following: // Process controls var cdir : Vector3 = transform.rotation * Vector3.forward; cdir = (Quaternion.AngleAxis(rotX, axisX)) * cdir; cdir = (Quaternion.AngleAxis(rotY, Vector3.Cross(cdir, Vector3.up).normalized)) * cdir; transform.rotation = Quaternion.LookRotation(cdir); I would like to clamp the vertical (axisY) angle to something between -89 and 89 degrees, but I fail to find a proper way to do this. I believe it shall be easier to do this in the quaternion domain, but I don't know how to test for this.

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images