lookAt causing camera to invert

I’m not doing anything exotic. I’m just calling ‘lookAt’ so the camera points to a location in space. Whenever the camera would need to pan up, it will occasionally invert the camera as well.

Are there any code samples for how to keep a camera upright while setting ‘lookAt’? I presume it would involve supplying a custom ‘up’ vector to ‘lookAt’, but how would I know when to use it vs. the default?

If you don’t supply an Up vector, it will use world up. If you try to to use lookAt straight up where it’s exactly the same as world up, then it’s in a scenario where it no longer calculate the correct rotation.

I normally restrict the camera so it can’t look exactly straight up or use the camera’s up vector (if it’s current up vector is not the same as the new lookAt vector)

1 Like

It’s only tilting back about 45 degrees, though. I would expect something like this if I were going to 90 degrees.

It shouldn’t invert then :thinking: Do you have a project that you can share that shows this issue?