Casting rays is easy, all you need to do is call the ray_cast function and it will give you a ds_map full of useful information.
var ray =
ray_cast([x, y],
[mouse_x, mouse_y],
all,
true,
true);
This code will cast a ray from the position of the object to the mouse poisition. You can now get the information needed by using these lines of code:
var startPosition = ray[? "startPosition"];
var hitPosition = ray[? "hitPosition"];
var object = ray[? "object"];
var rayDirection = ray[? "direction"];
var reflectionAngle = ray[? "reflectionAngle"];
var normal = ray[? "normal"];
var distance = ray[? "distance"];
var hitPosition = ray[? "hitPosition"];
var object = ray[? "object"];
var rayDirection = ray[? "direction"];
var reflectionAngle = ray[? "reflectionAngle"];
var normal = ray[? "normal"];
var distance = ray[? "distance"];