hello everyone,
i got some problems with my script.
MY PROBLEMS ARE:
1. The player should move his head, when SPACE is pressed
;
This is already working, but if i go away from SPACE, the camera should smoothly go back.
2. movement-problem: if i go around and turn, the camera should turn with the camera, but the camera has still the same position.
;
3. Zoom function: if i press mouse right, the camera should zoom into the head and the person should slowly gets transparent, that doesnt work perfectly....
;
I HOPE YOU MAY CAN HELP ME :-)
HERE IS THE SCRIPT
/////////////////////
var player_turn[3];
var player_speed[3];
var cam_bone_ang[3];
entity* spieler;
var camera_pan;
var camera_tilt;
var camera_move_to[3];
var camera_distance = 150;
var bone_ang[3];
var camera_mode = 1;
define zustand, skill51;
define ani_speed,skill90;
var steig = 0;
var camera_roll;
var tilt_bone;
action player_act
{
spieler = me;
my.polygon = on;
my.narrow = on;
my.fat = on;
my.shadow=off;
ent_bonereset(my,"bone");
my.zustand = 0;
camera.arc = 60;
while(1)
{
if(mouse_right == 1)
{
camera_mode = 2;
}
else
{
camera.arc=60;
camera_mode = 1;
}
///Animation
if((key_w || key_s) == 1)
{
ent_animate(my,"walk",my.ani_speed,ANM_CYCLE);
my.ani_speed += 4*time_step;
if(my.ani_speed > 100){my.ani_speed = 0;}
}
if(key_w == 0 && key_s == 0 && key_a == 0 && key_d == 0)
{
ent_animate(my,"idle",my.ani_speed,ANM_CYCLE);
my.ani_speed += 2*time_step;
if(my.ani_speed > 100){my.ani_speed = 0;}
}
///Camera
if(camera_mode == 1)
{
camera.pan = camera_pan;
camera_pan = bone_ang.pan;
my.transparent = off;
my.alpha = 100;
camera_tilt = bone_ang.tilt;
camera_tilt = clamp(camera_tilt,-40,30);
camera_pan = clamp(camera_pan,-30,30);
temp = fcos(camera_roll+camera_pan,-camera_distance);
vec_set(camera_move_to.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 40 + fsin(camera_tilt,-camera_distance)));
temp = min(1,0.3 * time_step); //changing 0.5 will change how fast the camera moves, at 1 places us at target, this value is what allows the smooth movement
camera.x += temp*(camera_move_to.x - camera.x);
camera.y += temp*(camera_move_to.y - camera.y);
camera.z += temp*(camera_move_to.z - camera.z);
vec_set(temp, my.x);
vec_sub(temp, camera.x);
vec_to_angle(camera.pan, temp);
vec_diff(temp.x,camera.x,my.x); //find the vector from the player to the camera
vec_normalize(temp.x,16); //get the magnitude of it's vector to 16 quants and store it in temp
vec_add(temp.x,camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.
}
hande_movmenent();
handle_camera_zoom();
handle_lookaround();
wait(1);
}
}
function handle_camera_zoom()
{
if(camera_mode == 2)
{
my.transparent=on;
my.alpha -= 8*time_step;
camera.tilt += mouse_force.y * 8 * time_step;
camera.pan -= mouse_force.x * 8* time_step;
if (camera.tilt >40){camera.tilt=40;}
if (camera.tilt <-40){camera.tilt=-40;}
}
}
function handle_umschauen()
{
// Kopfdrehung
if (key_space == 1){
ent_bonereset(my, "bone"); // Bestimmung des Bones
bone_ang.pan = -(pointer.x - 400) / 10;
bone_ang.tilt = -(300 - pointer.y) / 10;
bone_ang.roll = 0;
ent_bonerotate(my,"bone", bone_ang);
}
}
function hande_movmenent()
{
player_speed.x = 2.5*(key_w - key_s);
player_turn.pan = 2*(key_a - key_d);
c_move(my,player_speed,nullvector,ignore_me + ignore_passable + glide + use_box + ignore_flag2);
c_rotate(my,player_turn, nullvector);
}