Problem With Physics.Raycast

Hi, I am trying to create a Ray from my MainCamera to my Player

Here is the code I used…

var target : Transform;

function Update () 
	Debug.DrawRay(transform.position, target.position);
    if (Physics.Raycast(transform.position, target.position))
        Debug.Log("Something in the way");

Now I got it to work and all, but it doesnt seem to want to point towards the target! It points off at an angle, I need it to point directly down towards the Target.

Here are a few pics to show what I mean…

Any help or suggestions would be greatly appreciated!!!

The second input(*) of a raycast isn’t the place to look, it’s the direction to look. In your case, should be target.position-transform.position

Is is a little confusing, since LookAt(player.position) does work – the input is an actual map spot. In general, you always have to think “does it want an actual spot on the map, or a direction going to that spot?”

(*)Raycasts can either take two “start here” + “look this way” inputs, or a single Ray. But the two parts of the ray are “start here / look this way,” so it’s the same either way.