Example #1
0
 public GameObject NotSee()
 {
     if (usePhysics2D)
     {
         // If the target object is null then determine if there are any objects within sight based on the layer mask
         if (targetObject == null)
         {
             returnedObject = MovementUtility.WithinSight2D(transform, offset, fieldOfViewAngle, viewDistance, -1, targetOffset, angleOffset2D, ignoreLayerMask);
         }
         else
         { // If the target is not null then determine if that object is within sight
             returnedObject = MovementUtility.WithinSight2D(transform, offset, fieldOfViewAngle, viewDistance, targetObject, targetOffset, angleOffset2D, ignoreLayerMask);
         }
     }
     else
     {
         // If the target object is null then determine if there are any objects within sight based on the layer mask
         if (targetObject == null)
         {
             returnedObject = MovementUtility.WithinSight(transform, offset, fieldOfViewAngle, viewDistance, -1, targetOffset, ignoreLayerMask);
         }
         else
         { // If the target is not null then determine if that object is within sight
             returnedObject = MovementUtility.WithinSight(transform, offset, fieldOfViewAngle, viewDistance, targetObject, targetOffset, ignoreLayerMask);
         }
     }
     if (returnedObject == null)
     {
         return(returnedObject);
     }
     else
     {
         return(null);
     }
 }
Example #2
0
 public GameObject CanSee()
 {
     if (usePhysics2D)
     {
         // If the target object is null then determine if there are any objects within sight based on the layer mask
         if (targetObject == null)
         {
             returnedObject = MovementUtility.WithinSight2D(transform, offset, fieldOfViewAngle, viewDistance, objectLayerMask, targetOffset, angleOffset2D, ignoreLayerMask);
         }
         else // If the target is not null then determine if that object is within sight
         {
             returnedObject = MovementUtility.WithinSight2D(transform, offset, fieldOfViewAngle, viewDistance, targetObject, targetOffset, angleOffset2D, ignoreLayerMask);
         }
     }
     else
     {
         // If the target object is null then determine if there are any objects within sight based on the layer mask
         if (targetObject == null)
         {
             returnedObject = MovementUtility.WithinSight(transform, offset, fieldOfViewAngle, viewDistance, objectLayerMask, targetOffset, ignoreLayerMask);
         }
         else // If the target is not null then determine if that object is within sight
         {
             returnedObject = MovementUtility.WithinSight(transform, offset, fieldOfViewAngle, viewDistance, targetObject, targetOffset, ignoreLayerMask);
         }
     }
     if (returnedObject != null)
     {
         // Return success if an object was found
         return(returnedObject);
     }
     // An object is not within sight so return failure
     return(null);
 }