I am making a GameMaker game that involves the enemies having line of sight so that they don't target the player through a wall. I have this code that uses collision line to detect whether there is a wall between the enemy and the player, then sets CanSee to 1 if true.
if collision_line(x, y, obj_parent.x, obj_parent.y, obj_wall_parent, false, true)
global.CanSee = 1;
However, this code does not ever affect the value of CanSee. Am I using this code wrong?
Edit:
Here is my room setup. The walls all have obj_wall_parentas their parent.
Here are some of the objects:


CanSee= 1 if the enemy isn't seeing the player. Making an if collision_line will return the id, and anything that is > 1 returns true. So, try adding makingif !collision_line(x, y, obj_parent.x, obj_parent.y, obj_wall_parent, false, true)and see if the statement works for you. \$\endgroup\$