how to move the camera behind a model with the same angle? in XNA

Posted by Mehdi Bugnard on Game Development See other posts from Game Development or by Mehdi Bugnard
Published on 2012-12-07T20:45:42Z Indexed on 2012/12/07 23:44 UTC
Read the original article Hit count: 337

Filed under:
|
|
|
|

I meet are having difficulty in moving my camera behind an object in a 3D world. I would create two view mode. 1: for fps (first person). 2nd: external view behind the character (second person).

I searched the net some example but it does not work in my project.

Here is my code used to change view if F2 is pressed

 //Camera
        double X1 = this.camera.PositionX;
        double X2 = this.player.Position.X;
        double Z1 = this.camera.PositionZ;
        double Z2 = this.player.Position.Z;


        //Verify that the user must not let the press F2
        if (!this.camera.IsF2TurnedInBoucle)
        {
            // If the view mode is the second person
            if (this.camera.ViewCamera_type == CameraSimples.ChangeView.SecondPerson)
            {
                this.camera.ViewCamera_type = CameraSimples.ChangeView.firstPerson;

                //Calcul position - ?? Here my problem
                double direction = Math.Atan2(X2 - X1, Z2 - Z1) * 180.0 / 3.14159265;
                //Calcul angle - ?? Here my problem

                this.camera.position = ..
                this.camera.rotation = ..

                this.camera.MouseRadian_LeftrightRot = (float)direction;
            }
            //IF mode view is first person
            else
            {
                    //....

© Game Development or respective owner

Related posts about XNA

Related posts about c#