I’m having problems with a raycast… i’m using a linecast for shooting projectiles with the following code-
Physics.Linecast (animatorScript.head.transform.position, crosshairTarget.transform.position)
Now I’m trying to use that same code, but I only want it to go a certain distance (for example 10) - I still want it to be going from the “head” towards the crosshairTarget.
So I figure I have to use a raycast, but I’ve tried writing it every way I could think of and it simply always goes a direction relative from the character? It does NOT face towards the camera.
I figured it would be something along the lines of
Physics.Raycast (animatorScript.head.position, crosshairTarget.transform.position, out rayHit, distance)
For the crosshairTarget, I’ve tried Normalizing it, I’ve tried that alone and combined with TransformPoint and TransformDirection. Nothing I do seems to work.
Any advice on how I could get the proper cast for a specified distance? I’m sure its a simple error I’m just having trouble with this.