How to move the camera sideways in libgdx

Posted by Bubblewrap on Game Development See other posts from Game Development or by Bubblewrap
Published on 2012-04-02T08:37:43Z Indexed on 2012/04/02 11:44 UTC
Read the original article Hit count: 541

Filed under:
|

I want to move the camera sideways (strafe/truck), now i had the following in mind, but it doesn't look like there are standard methods to achieve this in libgdx.

If i want to move the camera sideways by x, i think i need to do the following:

  1. Create a Matrix4 mat
  2. Determine the orthogonal vector v between camera.direction and camera.up
  3. translate mat by v*x
  4. multiply camera.position by mat

Will this approach do what i think it does, and is it a good way to do it? And how can i do this in libgdx? I get "stuck" at step 2, as in, i have not found any standard method in libgdx to calculate an orthogonal vector.

EDIT: I think i can use camera.direction.crs(camera.up) to find v. Guess i can now try this approach tonight and see if it works.

© Game Development or respective owner

Related posts about camera

Related posts about libgdx