Hi,
I was told I better show this camera system when I got it working ok.
So here it is.
I still have never found a good way to keep the camera out of the walls other than by keeping the player a certain distance from the wall, which is what is done in this example. How I did it with this example was to create and invisble cylinder around the player that actually does the player movement, keepng the player a certain distance from the wall. There are other possible ways to do this, but this is probably the simpliest so that's what I did here. This example uses c_move, c_trace, etc.
I put 2 camera modes in the example so you get an idea of how to use the system. Hit F7 to change modes.
CAM_MODE_CHASE
The game starts in this mode. In this mode, you use the mouse to rotate the player and to change the camera tilt. Pressing the 'Q' key will force the camera to the front.
CAM_MODE_THIRD
In this mode, you use the A, D, or cursor keys to rotate the player. The mouse changes tilt and if you are not moving forward the mouse can also be used to rotate the camera around the player in a free style.
You can add whatever modes you like or add things to the existing modes. I put alot of extra camera movement functions in the code too, that currently aren't being used, but can be easily added into the camera mode functions, i.e., MoveCamLeft(), MoveCamRight().
An example of adding these to a mode would be changing CameraChase() to this:
function CameraChase()
{
// get angle diffrence between player pan and camera pan
CamPlayerAngDiff = ang(player.pan-camAng.pan);
if(key_q)
{
cameraRotationMode = ROTATION_MODE_SLOW;
MoveCamFront();
}
else
{
if(key_z)
{
cameraRotationMode = ROTATION_MODE_MEDIUM;
MoveCamLeft();
}
else
{
if(key_c)
{
cameraRotationMode = ROTATION_MODE_MEDIUM;
MoveCamRight();
}
else
{
cameraRotationMode = ROTATION_MODE_MEDIUM;
MoveCamBehind();
}
}
I just added keys Z and C to move camera off to left or right of player in that code.
There is some stuff that effects the camera that is in the PlayerEnt action, make sure you notice those if you are trying to add the camera system to your existing player action code.
It's at my 3DGS site, which is listed in my signature below. It's in the Camera link at my site.