See raycast in Game?

I want to be able to put a line along my raycast so that I can see where the enemy can see, I don’t mean debug ray as that is only in editor I want something that can be seen in game, I also need to have it follow the raycast exactly so it doesn’t go through walls.

To Clarify, I need it to be there during the game, in the final product

Put this piece of code on the same script which creates the RayCast. Then when the game is running inside the editor, click on the object that has this code and you will see the ray!

function OnDrawGizmosSelected () {
	Gizmos.color = Color.red;
	var direction : Vector3 = transform.TransformDirection (Vector3.forward) * 5;
	Gizmos.DrawRay (transform.position, direction);
}

Hope it helped :slight_smile: