I'm trying to rotate my OrthographicCamera in the render loop to a fixed angle, but I can only make the camera spin. This is the code that I have:

in create():

OrthographicCamera camera = new OrthographicCamera();
camera.setToOrtho(true, 100, 100);
camera.position.set(50, 50, 0);

in the render loop:


The camera keeps spinning each frame. But I'd like the camera to stay at 30 degrees.

I have already seen this answer:


But I don't like it because this code is too drastic. I wonder if there is a more "common" way to do this.


1 Answer 1


The method camera.rotate() (and all other transformation methods on camera) act on the current state of the camera. So if it's rotated 30 degrees, it will add more 30 degrees to the rotation.

If you want to keep at 30 degrees (but still applying the transform every step), you have to make it look back at whatever it was looking before. Assuming you're using an orthogonal camera for 2D rendering with y pointing down, then this should work:

camera.up.set(0, -1, 0);
camera.direction.set(0, 0, 1);

If you prefer y pointing up, try:

camera.up.set(0, 1, 0);
camera.direction.set(0, 0, -1);

Hope this helps you :)

  • \$\begingroup\$ Thanks for this. I was actually able to use this without the camera.directin.set(0, 0, -1); lines. \$\endgroup\$ Commented Jan 16, 2018 at 7:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .