K
koffe
Guest
I'm trying to create a simple LOS check inside of my enemy objects. With the code below, I create a list of all collisions along a line each frame and search through looking for matches with the variable 'tallObject =1 '.
I'm printing 'viewIsBlocked' in the console and I can see the LOS line updating with '1' or '0' on collisions, however the code isn't discrimating between tallObjects 1 or 0. Even if I break LOS with an object which has 'tallObject = 0', viewIsBlocked will return = 1
I'm sure it's a small error but I'm really struggling to conceptualize what's going wrong. Is this a junk system entirely or can someone see a simple fix?
I'm printing 'viewIsBlocked' in the console and I can see the LOS line updating with '1' or '0' on collisions, however the code isn't discrimating between tallObjects 1 or 0. Even if I break LOS with an object which has 'tallObject = 0', viewIsBlocked will return = 1
I'm sure it's a small error but I'm really struggling to conceptualize what's going wrong. Is this a junk system entirely or can someone see a simple fix?
var _num = collision_line_list(x, y, obj_player.x, obj_player.y, all, false, true, global.LOS_list, false);
if _num > 0 {
for (var i = 0; i < _num; ++i;){
if global.LOS_list[| i].tallObject == 1 {
var losBlocker = 1;
}}}
switch (losBlocker){
case 0:
viewIsBlocked = 0;
break;
case 1:
viewIsBlocked = 1;
break;
}
Last edited by a moderator: