character collision

Posted By: oldschoolj

character collision - 08/07/07 22:51

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);
}
}


Posted By: Uhrwerk

Re: character collision - 08/07/07 23:54

A player going up a wall is usually a sign for an entity being inside a wall and therefore tracing even as inside an object and therefore trying to escape upwards...
Posted By: Ottawa

Re: character collision - 08/08/07 00:00

Hi oldschoolj!

Looking at your code I was wondering about this line

movement_speed.z = - (distance_to_ground - 17); // 17 = experimental value

are you sure you wanted = - and not -=

Ottawa
Posted By: Nems

Re: character collision - 08/31/07 20:02

I found that by using c_rotate for panning stopped most instances of this happening then using z_glide = 1 (depending on the size of the character) sorted a few more out and experimenting with c_move .z forces for gravity cleared up the rest but then I had probs with ease of game play.
© 2023 lite-C Forums