Without an actual screenshot showing the problem, I can only make suggestions that may or may not apply to your situation.
First, make sure that the camera is not pointed directly in the same direction as the ray being drawn. Otherwise it might only show up as infinitely in line.
Second, by default, Debug.DrawRay
draws lines with depth testing enabled, so if the camera is behind the object, and the ray is being drawn mostly away from the camera, the object itself would obscure the line. Or there could be something else in the way. If this is the only problem, then you could simply disable depth testing:
Debug.DrawRay(this.transform.position, this.transform.forward * 100f, Color.red, duration: 2f, depthTest: false);
As a sidenote, is there a reason duration is set to 2? Since this is being called in Update
, no duration is required unless you want it to continue to be drawn after the object is disabled, or if the object is moving or rotating and you want a visual record of where it was in previous frames.