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.
[12256-screen+shot+2013-06-21+at+1.22.24+pm.png|12256]
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?