How can I draw a line from point A to point B and check if it overlaps a player?

So I'm trying to make a detection system on my own and I want my guards to draw lines in front of them and if any line collides with the player then the player is seen. The thing is I want the lines to hit unpassable objects (so it doesn't go through walls) but go through stuff like chairs and tables, so I'll probably use region IDs for that. Can anyone give me a hand/direction on how to do such a function?

I'm thinking of something like:

stealthSystem_s2.png

stealthSystem_s1.png

 

//On GameEventcan_see_player?(disX, disY)    for i to n        line = drawLine()        if(line.overlaps($game_player))            return true;        end    end    return false;endJust tossing ideas really. If anyone can give me a hand/direction I'd be very happy 🙂

Thanks in advance

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-draw-a-line-from-point-a-to-point-b-and-check-if-it-overlaps-a-player.17287/