Quote:
You may place the camera in a certain distance
away from your entity, when you move the entity,
move the camera also and keep it always look at
your entity.
Code:
action yourEntity
{
while(1)
{
// entity move code
//.....
// Place the camera in a certain distance
// away from the entity
camera.x = my.x + 15; // play with 15
camera.y = my.y + 15; // play with 15
camera.z = my.z + 2; // play with 2
// Always look at the entity
vec_diff(temp,my.x,camera.x);
vec_to_angle(camera.pan,temp);
wait(1);
}
}
This one almost works correctly. I put this code into a function because I have more camera views. But when I want to change the camera mode, it didn't change.
This is the function of the camera views with the keys.
Code:
function cam1()
{
camera.x = -112;
camera.y = 0;
camera.z = 16;
camera.pan = 0;
camera.tilt = 0;
camera.roll = 0;
}
function cam2()
{
camera.x = -160;
camera.y = 0;
camera.z = 16;
camera.pan = 0;
camera.tilt = 20;
camera.roll = 0;
}
function cam3()
{
camera.x = -250;
camera.y = 0;
camera.z = 16;
camera.pan = 0;
camera.tilt = 45;
camera.roll = 0;
}
function cam4() {
camera.x = -22;
camera.y = -42;
camera.z = 9;
camera.pan = 60;
camera.tilt = 0;
camera.roll = 0;
}
function cam5() {
while(1) {
// Place the camera in a certain distance
// away from the entity
camera.x = machine.x + 40; // play with 15
camera.y = machine.y + 40; // play with 15
camera.z = machine.z + 10; // play with 2
// Always look at the entity
vec_diff(temp,machine.x,camera.x);
vec_to_angle(camera.pan,temp);
wait(1);
}
}
on_1 = cam1;
on_2 = cam2;
on_3 = cam3;
on_4 = cam4;
on_5 = cam5;
When I press the 5-button the cam is good. But when I press the 1-button for example, the view did not change.
So how can I fix this problem?