A
Ajay Warden
Guest
I don't want an enemy to shoot at me when an object is between it and me.
So far I have this,
var CanSee = !collision_line(x, y, obj_player.x, obj_player.y, obj_barn, false, true);
var IsInsideRadius = distance_to_object(obj_player) <= 500;
if(CanSee and IsInsideRadius){
var inst;
inst = instance_create(x+lengthdir_x(65, image_angle), y+lengthdir_y(65,image_angle), obj_enemybullet);
with (inst)
{
speed = 4;
direction = other.image_angle;
}
enemycanfire = false;
}
That works but only for obj_barn, how would I add obj_house to this also so the enemy doesn't shoot me when obj_barn or obj_house is in the way?
So far I have this,
var CanSee = !collision_line(x, y, obj_player.x, obj_player.y, obj_barn, false, true);
var IsInsideRadius = distance_to_object(obj_player) <= 500;
if(CanSee and IsInsideRadius){
var inst;
inst = instance_create(x+lengthdir_x(65, image_angle), y+lengthdir_y(65,image_angle), obj_enemybullet);
with (inst)
{
speed = 4;
direction = other.image_angle;
}
enemycanfire = false;
}
That works but only for obj_barn, how would I add obj_house to this also so the enemy doesn't shoot me when obj_barn or obj_house is in the way?