Wednesday, July 22, 2020

LibGDX 3D Camera lookAt() Problem

If you've ever used the method camera lookAt() method, you may have noticed that afterwards, your view of the (virtual) world is slightly off-kilter. 

For some reason, the methods alters the camera.up value, which should ideally be (0, 1, 0).

What is the solution?  Just manually set the direction yourself like so:-

tmpVector.set(targetPosition).sub(camera.position).nor();
player.camera.direction.set(tmpVector);
player.camera.update();
I've no idea why the lookAt() method does what it does.

No comments: