Does anyone know why, when my player hits a wall, they go straight up to the top?
Code:
action players_code ()
{
on_alt = toggle_movemode;
player = my; // I'm the player
while (1)
{
my.pan += 6 * (key_a - key_d) * time_step; // rotate the player using the "A" and "D" keys
vec_set (temp2.x, my.x); // copy player's position to temp
temp2.z -= 5000; // set temp.z 5000 quants below player's origin
distance_to_ground = c_trace (my.x, temp2.x, IGNORE_ME | IGNORE_PASSABLE | USE_AABB);
if ((key_w == 0) && (key_s == 0))// the player isn't moving?
{
movement_speed.x = 7 * (key_w - key_s) * time_step; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
movement_speed.z = maxv (-35 * time_step, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE);
ent_animate(my, "stand", anim_percentage_stand, ANM_CYCLE); // play the "stand" animation
}
if ((run_toggle == 1) && (key_s == 1))
{
movement_speed.x = 15 * (key_w - key_s) * time_step; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
movement_speed.z = maxv (-35 * time_step, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE);
ent_animate(my, "run", anim_percentage_run, ANM_CYCLE);
}
if ((run_toggle == 1) && (key_w == 1))
{
movement_speed.x = 15 * (key_w - key_s) * time_step; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
movement_speed.z = maxv (-35 * time_step, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE);
ent_animate(my, "run", anim_percentage_run, ANM_CYCLE); // play the "stand" animation
}
if ((run_toggle == 0) && (key_w == 1))// the player is moving?
{
movement_speed.x = 7 * (key_w - key_s) * time_step; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
movement_speed.z = maxv (-35 * time_step, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE);
ent_animate(my, "walk", anim_percentage_walk, ANM_CYCLE); // play the "walk" animation
}
if ((run_toggle == 0) && (key_s == 1))// the player is moving?
{
movement_speed.x = 7 * (key_w - key_s) * time_step; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value
movement_speed.z = maxv (-35 * time_step, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE);
ent_animate(my, "walk", anim_percentage_walk, ANM_CYCLE); // play the "walk" animation
}
anim_percentage_entwalk += 5 * time_step;
anim_percentage_stand += 4 * time_step; // 5 = animation speed
anim_percentage_walk += 5 * time_step;
anim_percentage_run += 6 * time_step;
// move the player
c_scan(player.x, player.pan, vector(100, 100, 1000), IGNORE_ME | SCAN_ENTS |SCAN_LIMIT);
wait (1);
}
}