camera zoom from 3rd person to 1st

Posted By: the4d

camera zoom from 3rd person to 1st - 05/08/08 10:27

i'm fairly sure this should be possible,
so can somebody tell me how i can code it so that the game starts with the camera in 3rd person, then zooms into first, kinda like an orientation or an intro.
Posted By: HeelX

Re: camera zoom from 3rd person to 1st - 05/08/08 16:45

Hi,

this is quiet easy if you write the camera management in a proper way (the following code is written in C-Script). I would differentiate different camera styles through a simple state variable, e.g.

var camState;

Whereas 0 means undefined and there camera doesnt move/rotate, 1 means first person and 2 means third person.

Now, I would write a camera function which has a loop. In this loop you check this state and if it is >0, you call a function camFirstPerson() if it is == 1 and function camThirdPerson(). These function calculate the target position of the camera with everything you need to take into account, e.g. collision. The important thing is, that these functions DON'T SET the camera to this target position and rotation. The target position and rotation could be saved in globals:

var camTargetPos[3];
var camTargetPan[3];

After you have called these functions in your camera loop, you have to process this information to move the camera to this location. This is the point in which you interpolate the current camera position and rotation to the target position. You could call for instance a function camInterpolate(); which does exactly this job. You just take the camera's .x location and .pan rotation and the target counterparts and interpolate. For the spacial interpolation you could take vec_lerp. For the angular rotation you could use the function ang_lerp which I introduce here as Lite-C script (it is easy to convert it to C-Script): http://www.coniserver.net/ubb7/ubbthreads.php?ubb=showflat&Main=22242&Number=184968#Post184968

As long as you want the camera to be in 3rd person mode, you set camState = 2; and when you change into 1st person mode, you set camState = 1; Because of the dynamic interpolation, the camera translates automatically from the 3rd person camera position to the 1st person camera position.

Thats it! - I hope, this helps.

Good luck,
- Christian
Posted By: the4d

Re: camera zoom from 3rd person to 1st - 05/12/08 08:08

confusing, but i think itll help me.
thanks a lot!
© 2024 lite-C Forums