I am making a space shooter game and am having problems with collision detection. The ship "shoots" out a simple model (using c_move) which has my.enable_entity = on assigned to it and an action to remove it if it comes in contact with an other model, but the action seems to never be triggered. The projectile destroys its target but countinues to fly away, never getting removed itself until it has reached a maximum distance. I want it removed right after it hits any model
Here is the code. This should be simple. Any help here would be awesome.
Code:
function move_projectile()
{
var maximum_distance = 15;
var projectile_speed = 50;
var effect_speed = 0;
wait(1);
c_setminmax(me);
my.invisible = on;
my.enable_entity = on;
my.pan = player.pan;
my.tilt = player.tilt;
my.event = remove_projectile;
while (maximum_distance > 0) && (my)
{
maximum_distance -= 1 * time;
c_move (me, projectile_speed, nullvector, ignore_passable);
vec_set (temp.x, my.x);
effect (photon_effect, 1, temp, effect_speed);
wait (1);
}
remove_projectile(); //remove me once distance is met
}
function remove_projectile()
{
wait(1); //wait one frame
my.event = null;
my.passable = on;
my.invisible = on;
sleep (2);
ent_remove(me);
}