Ray from enemy to player is always a bit off (Image)

I’ve got a ray from the enemy to the player, and a line showing the ray in unity. The ray always seems to fire just to the side of the player, so it never actually hits.


Here is my code:

var rayDirection = other.gameObject.transform.position - transform.position;
		rayDirection.y += 1;
		var currentPosition = transform.position;
		currentPosition.y += 1;
		var hit : RaycastHit;
		Debug.DrawLine (currentPosition, rayDirection, Color.yellow, 3);
		if(Physics.Raycast(transform.position, direction, hit, viewDistance)) 
			print ("Sent Raycast");
			Debug.DrawLine (transform.position, hit.point, Color.cyan, 3);
			if(hit.collider.gameObject.tag == "Player")
				print("Player found");

So I’m wondering why this is happening?

What is that math you’re doing for the raycast direction(which is actually a vector3 location not a direction)? If you want the raycast to shoot toward and object, give it only the objects position. Why are you subtracting something else from it?