PDA

View Full Version : Making camera follow character (2D)



Random89
05-05-2009, 09:41 AM
I was just wondering what the easiest way to make the camera follow the user controlled character in a top down 2d game? I have found all these tutorials for 3D games but they all seem to be more complicated than I need them. All I want is a command to move the camera along the X and Y axis. Does it exist?

ZbuffeR
05-05-2009, 01:14 PM
glTranslatef(x,y,0);

Random89
05-05-2009, 04:25 PM
Isn't that just for an object? I wanted to transform the camera viewpoint. Like in GTA how the camera follows the main character.

ZbuffeR
05-06-2009, 03:12 AM
In fact modelview transformations are for both objects and viewpoint (model+view).

Imagine your point of view is always fixed, and that all the objects translates with the same movement : this will look exactly the same as fixing the geometry, and only moving the point of view.

There is a bunch of information in the faq :
http://www.opengl.org/resources/faq/technical/transformations.htm