Well, I played around with some flags on the c_move, tried to move the bullet in front of the gun, and tried slowing it down, but it does the same thing. I don't really understand what the framerate of the game might change about collision. I guess the bullet can't tell fast enough it's being spawned in a wall, so it continues moving, and once it checks to see if it's colliding with a block, it's too late.
Not sure how I could fix this. Here is the code I have.
action pbullet(){
c_setminmax(me);
set(my,BRIGHT);
my.emask = ENABLE_BLOCK|ENABLE_ENTITY;
my.event = pbulletdelete;
var panrandom = integer(random(11));
my.pan = you.pan - 5 + panrandom;
while(1){
c_move(me,vector(50 * time_step,0,0),nullvector,GLIDE|IGNORE_PASSABLE|IGNORE_YOU);
wait(1);
}
}
action pgun(){
weapon = me;
var cooldown = 5;
var pistolsnd;
set(my,PASSABLE);
while(1){
cooldown += 1 * time_step;
if(key_j){
if(cooldown >= 4){
you = ent_create("bullet1.mdl",vector(my.x,my.y,my.z),pbullet);
if(snd_playing(pistolsnd)){
snd_stop(pistolsnd);
}
pistolsnd = snd_play(pistol,100,0);
cooldown = 0;
}
}
wait(1);
}
}
I
guess I could just scrap this code and not make the bullet a moving entity, but I think this problem could appear with many other things, so I want to learn how to fix it.
Thanks for the suggestions, by the way.