How 'bout the entire code + explanation?
The complicated part is the turn to left and right + the camera as turning the camera left and right in an arc with an entity is pretty complicated.
What I do is use a "tcam" Entity without a model graphic that is always equal to the player co-ordinates. When ever this turns, the tcam entity moves back and i store its x,y,z co-ords and move the entity cam (which holds the camera) onto those co-ords. The diagrams below explain it:
the code is this:
______________________________________________________________
///////////////////////////////////////////////////////
// INCLUDES
///////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////////////////////////////
// VARIABLES
///////////////////////////////////////////////////////
VECTOR offset;
ENTITY* cam;
ENTITY* actor;
ENTITY* tcam;
var attach;
//////////////////////////////////////////////////////
// ACTIONS
//////////////////////////////////////////////////////
action camera_action(){
cam = me;
while (me!=NULL){
wait(5);
camera.x = cam.x;
camera.y = cam.y;
camera.z = cam.z;
camera.pan = cam.pan;
wait(1);
}
}
action actor_action(){
actor = me;
}
action tcam_action(){
tcam = me;
while (me!=NULL){
wait(5);
my.x = actor.x;
my.y = actor.y;
my.z = actor.z;
my.pan = actor.pan;
wait(1);
}
}
/////////////////////////////////////////////////////
// FUNCTIONS
/////////////////////////////////////////////////////
function initCamOffset(ox,oy,oz){
offset.x = ox;
offset.y = oy;
offset.z = oz;
cam.x += offset.x;
cam.y += offset.y;
cam.z += offset.z;
return vector(cam.x,cam.y,cam.z);
}
function attachCam(){
attach = true;
}
function removeCam(){
attach = false;
}
function actorForward(){
c_move(actor,vector(4 * time_step,0,0),nullvector,GLIDE);
c_move(cam,vector(4 * time_step,0,0),nullvector,GLIDE);
}
function actorBackwards(){
c_move(actor,vector(-4 * time_step,0,0),nullvector,GLIDE);
c_move(cam,vector(-4 * time_step,0,0),nullvector,GLIDE);
}
////////////////////////////////////////////////////
// MAIN
////////////////////////////////////////////////////
function main(){
// load level
level_load("game.wmb");
wait(5);
// initialise the offset
initCamOffset(30,0,15);
// tcam set up
attachCam();
ent_create(NULL,nullvector,tcam_action);
while (1){
while (key_cuu){
actorForward();
wait(1);
}
while (key_cud){
actorBackwards();
wait(1);
}
if (key_cur){
attachCam();
while (key_cur){
actor.pan -= 6 * time_step;
c_move(tcam,vector(offset.x,0,0),nullvector,IGNORE_MODELS);
cam.x = tcam.x;
cam.y = tcam.y;
cam.z = tcam.z;
wait(2);
}
removeCam();
}
wait(1);
}
}
the actor and cam entity are placed in WED.
that just about all of it.