Rotate target of camera

Oct 22, 2009 at 2:44 PM

Hi.

How it possible to rotate camera's target around position? (just like look around). For example, camera located at (0, 0, -5) and Target = Vector.Zero. How move target around point (0, 0, -5) ?

Coordinator
Oct 22, 2009 at 6:27 PM

Hi,

in the update method of your Game class, you can do something like this:

Camera.Position.X = (float)Math.Sin(radians)*10;
Camera.Position.Z = (float)Math.Cos(radians)*10;

radians += 0.05;

 

Radians would then be a double variable you'd define outside the Update method in the Game class and the number 10 that is multiplied would be something you'd have to tweak in order to get the right distance. The += 0.05 ofcourse would represent the rotation speed.

Hope that helps.