I have a few questions about raycasting I'm using a raycast script for my gun heres the code.
I have a few questions though. 1. How would I use a texture as a crosshair in the center of the screen? 2. How would I make the enemys react to the raycast hitting them would it be something like "OnRaycastEnter()"? 3. How would I make the raycast go in the direction of the crosshair texture instead of the mouse?
1) A texture as a crosshair is just a GUITexture in the middle of your screen. simple as that. Here's how you use it:
2) The answer is in the code you posted. if your raycast hits something, it will drop into the conditional statement that says print("Hit something"). from there you can access the object that it hit using hit.collider (what you do with it after that is up to you). Here's how you use raycasting:
3) use Camera.ViewportPointToRay to create your ray:
You'll notice that I linked the Unity docs in every answer. All of your questions were solved by one source of information. Please read the unity docs, you will learn a ton from it.