I was getting a "possible endless loop" error in my function, so i added a wait to it.. It fixed the problem but now the animations don't work... whats wrong with the code?
Code:
// FPSP1.wdl
// Define Variables
var video_depth 16;
var video_mode 7;
var video_screen 1;
var move_vec[3] = 0,0,0;
var stand_percent = 0;
var walk_percent = 0;
var stoptilt = 0;
// Define STRINGs, BMAPs, SOUNDS,
STRING FPSP1_str = <FPSP1.wmb>;
BMAP crosshair_pcx = <"crosshair.pcx">;
///////////////
// Mouse Function
function mouse_mapping()
{
mouse_map = crosshair_pcx;
mouse_mode = 1;
mouse_sync = ON;
}
// Action player_move
action player_move
{
player = me;
wait(1);
while(player !=NULL)
{
//Movement
move_vec[0] = (key_w - key_s) * 4*TIME;
move_vec[1] = (key_a - key_d) *4 *time;
ent_move(move_vec,NULLVECTOR);
// Camera Positions
mouse_pos.x = mouse_pointer.x;
mouse_pos.y = mouse_pointer.y;
camera.tilt += mouse_force.y;
camera.pan -= mouse_force.x;
my.pan -= 5 * mouse_force.x * time;
stoptilt += 5 * mouse_force.y *time;
camera.pan = my.pan;
vec_set(camera.x,player.x);
camera.z = player.z + 27;
camera.arc = 80;
wait(1);
}
// Animations set
if(move_vec[0] == 0 && move_vec[1] == 0)
{
stand_percent = (stand_percent +5*TIME)%100;
ent_animate(me,"stand",stand_percent,ANM_CYCLE);
}
else
{
walk_percent = (walk_percent + sign(move_vec[0])*5*time)%100;
ent_animate(me,"walk",walk_percent,ANM_CYCLE);
}
}
//Main Function
function main()
{
mouse_mapping();
level_load (FPSP1_str); // Load level
wait(1);
}