I have a problem with Line of Sight,
my code :
func Player_is_in_LOS():
var space = get_world_2d().direct_space_state
var LOS_obstacle = space.intersect_ray(global_position, Player.global_position, [self], collision_mask)
var distance_to_player = Player.global_position.distance_to(global_position)
var Player_in_range = distance_to_player < MAX_DETECTION_RANGE
if LOS_obstacle.collider == Player and Player_in_range:
return true
else:
print(LOS_obstacle.collider.get_path())
return false
I added additional line to see what is obstacle
print(LOS_obstacle.collider.get_path())
and when light hit the player I see output:
/root/Level1/Walls
/root/Level1/Walls
Player is on Player Layer and Player Mask ,
SecurityCam is on SecurityCam Layer and Player and Wall Mask,
I check it hounded of times
What can I check more? Any ideas ?