Rather than have it remain active, you will be setting a condition on the raycast. For this project, you will have it active only when the virtual button, “ML Enable,” is being pressed. You could easily assign a different key to the preset “Fire1” virtual input, if you wish, but in this case, the player has one less input to deal with, if it is hooked up with the mouse-look.
1. Add the following lines above the Physics.Raycast line: