Hi All,
I am messing around with NavMeshes and they are awesome. I have 1 problem however. I am using a Linecast to see if a unit is in sight of the AI. This works great for walls and such, but for some reason the Linecast ignores the collider on other AI units that have a NavMeshAgent. This causes the units to shoot through eachother. I cannot figure out why it does not work. I have a collider and a rigidbody set up on the units.
I have read there was a bug with Raycasting and NavMeshAgent. Is still still true?
bool CheckLineOfSight()
{
bool inSight = false;
RaycastHit hit;
Vector3 origin = new Vector3(transform.position.x, transform.position.y + 1, transform.position.z);
Vector3 end = new Vector3(targetUnit.position.x, targetUnit.position.y + 1, targetUnit.position.z);
if(Physics.Linecast(origin, end, out hit))
{
if(hit.transform == targetUnit.transform)
{
inSight = true;
attacking = true;
}
}
return inSight;
}