Rotating the lookAt

Hi all,

I’ve had a read of the math bit of the wiki and the excellent math for dummies slideshow, I get most of it…I think, but there’s something I’m still not getting as I am stuck.

I’m using the default cam and I want to look to the left of a spatial, not directly at it.

View from above:

v1 is the .location of the spatial, v2 doesn’t exist, I need to create and calculate where it is, eg. 90 degrees to the left of v1.

(It’ll probably be 45 deg in the game)

cam.getLeft() should help there, the flyCam uses that to strafe left/right, check the source code of it

1 Like

(90degreeRightQuat * (v2Pos - camPos)) + camPos

1 Like

Thanks guys! went with normen’s solution as I may need other angles as well as hard left, here’s the code I used:


Quaternion left = new Quaternion();

left.fromAngleAxis(FastMath.HALF_PI,new Vector3f(0,0,1));

Vector3f v2=left.mult((v1.subtract(cam.getLocation()))).add(cam.getLocation());

cam.lookAt(v2, Vector3f.UNIT_Z);


Have a happy new year!