Posted By: Luzifer
Problem with c_trace and wait - 01/20/08 21:05
Hello everyone,
I got a really weird problem that I want to share with you. For my game I use a sprite that serves as a laser sight to the player's gun (well, I call it crosshair...). Here's the code:
Code:
Unfortunately, as soon as I create the entity running this function, my player cannot move anymore. I narrowed the problem down to the c_trace in this function and its timing. If I add a "wait(1);" before the trace the problem does not occur but the game runs in slow-mo (because of the frame skip?). I tried to work something out with proc_late() but nothing happened.
Anyone know how I go about this?
Edit: Also notable is that I used the exact same function in another game where it worked fine. Must have to do with a more complicated move function for this which also uses more c_traces.
I got a really weird problem that I want to share with you. For my game I use a sprite that serves as a laser sight to the player's gun (well, I call it crosshair...). Here's the code:
Code:
function crosshair() {
my.overlay = on;
my.passable = on;
my.facing = off;
my.transparent = on;
my.ambient = 255;
my.scale_x = 0.5;
my.scale_y = 0.5;
my.scale_z = 0.5;
while (player.skill3 > 0) {
if (player.skill50 == 100)
{my.invisible = off;}
else
{my.invisible = on; }
vec_set(gun_target, gun_muzzle);
gun_target.x += 10000; // the weapon has a firing range of up to 10,000 quants
vec_rotate(gun_target, pistol.pan);
vec_add(gun_target, pistol.x);
c_trace(gun_muzzle,gun_target,ignore_passable|ignore_me|use_aabb);
my.x = target.x;
my.y = target.y;
my.z = target.z;
vec_to_angle(my.pan, normal); // put on surface
wait(1);
}
}
Unfortunately, as soon as I create the entity running this function, my player cannot move anymore. I narrowed the problem down to the c_trace in this function and its timing. If I add a "wait(1);" before the trace the problem does not occur but the game runs in slow-mo (because of the frame skip?). I tried to work something out with proc_late() but nothing happened.
Anyone know how I go about this?
Edit: Also notable is that I used the exact same function in another game where it worked fine. Must have to do with a more complicated move function for this which also uses more c_traces.