[/code]
function act_player();
function main()
{
fps_max = 50;
// load your level
level_load (NULL);
wait(5);
// load the (player entity, assign position, assign default function)
ent_create ("myplayer.mdl", vector(0,0,0), act_player);
}
function act_player()
{
var speed = 5;
var rotation_speed = 3;
my.scale_x = .5; // change model size if necesary
my.scale_y = .5;
my.scale_z = .5;
player = my;
while(1)
{
//update camera position relative to the model position
camera.x = player.x;
camera.y = player.y;
camera.z = player.z + 5; // 5 units above the model origin
camera.pan = player.pan; // set camera same pan as model
camera.tilt = player.tilt;
move_mode = IGNORE_PASSABLE + USE_BOX;
if(key_w == 1)
{
// perform movement
c_move (my,vector(speed * time_step,0,0), nullvector, move_mode);
}
if(key_s == 1)
{
c_move (my,vector(-speed * time_step,0,0), nullvector,move_mode);
}
// perform rotation
if(key_a == 1) { my.pan += rotation_speed * time_step; };
if(key_d == 1) { my.pan -= rotation_speed * time_step; };
if(key_q == 1) { my.tilt += 1; }
if(key_z == 1) { my.tilt -= 1; }
wait(1);
}
}
[code]