Синтаксис:
Используется csharp
bool canSee(Transform from, Transform to)
{
Vector3 direction = to.position - from.position;
Quaternion look = Quaternion.LookRotation(direction);
float angle = Quaternion.Angle(from.rotation, look);
// Debug.Log("ANGLE = "+angle);
Ray ray = new Ray(from.position, direction);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, maxSearchDistance, layerMask))
{
if (hit.transform.gameObject == to.gameObject & angle < eye_fov_range)
return true;
else
return false;
}
return false;
}
{
Vector3 direction = to.position - from.position;
Quaternion look = Quaternion.LookRotation(direction);
float angle = Quaternion.Angle(from.rotation, look);
// Debug.Log("ANGLE = "+angle);
Ray ray = new Ray(from.position, direction);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, maxSearchDistance, layerMask))
{
if (hit.transform.gameObject == to.gameObject & angle < eye_fov_range)
return true;
else
return false;
}
return false;
}