first commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public class CoverChecker : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Если объект находится между врагом и игроком, он должен блокировать линию видимости.")]
|
||||
public bool blocksVision = true;
|
||||
|
||||
[Tooltip("Небольшая метка для будущих расширений механики укрытий.")]
|
||||
public float concealmentStrength = 1f;
|
||||
|
||||
public static bool IsVisionBlocked(Vector3 origin, Vector3 target, LayerMask obstacleMask)
|
||||
{
|
||||
Vector3 direction = target - origin;
|
||||
float distance = direction.magnitude;
|
||||
|
||||
if (distance <= Mathf.Epsilon)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Physics.Raycast(origin, direction.normalized, distance, obstacleMask, QueryTriggerInteraction.Ignore);
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = blocksVision ? new Color(0.2f, 0.7f, 1f, 0.5f) : new Color(1f, 0.4f, 0.2f, 0.3f);
|
||||
Collider objectCollider = GetComponent<Collider>();
|
||||
|
||||
if (objectCollider != null)
|
||||
{
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
Gizmos.DrawWireCube(objectCollider.bounds.center - transform.position, objectCollider.bounds.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user