Raycast is an asset for Game Maker Studio 2, which allows you to do raycasts on rectangles.

Documentation
Example
Raycast allows you to do raycasts in Game Maker Studio 2, it will give you the information you need: