I've tried raycasting to the position of the mouse then setting the width of an object to the HitDistance expression, however if the mouse isn't over a solid the raycast stops at the mouse.
Basically, I want cast a ray from a gun to the mouse without stopping until it hits a solid (instead of stopping when it reaches the mouse position), then set the width of the laser object to the raycast distance.
Is it possible to raycast at an angle until it hits a solid? If not, how can I do this?
I've tried following a tutorial and have seen others set the width to a number larger than the layout if the ray doesn't intersect but the laser acts inconsistently and I'm having difficultly making it work.
Can anyone please help?