Created
November 14, 2016 03:56
-
-
Save Problematic/aff719ed77a4416e49097faa3fd088d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
[CreateAssetMenu] | |
public class CastService : ScriptableObject | |
{ | |
public float maxDistance = Mathf.Infinity; | |
public LayerMask mask; | |
public QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal; | |
public bool Raycast (Vector3 origin, Vector3 direction, out RaycastHit hitInfo) | |
{ | |
return Physics.Raycast (origin, direction, out hitInfo, maxDistance, mask.value, queryTriggerInteraction); | |
} | |
public bool BoxCast (Vector3 center, Vector3 halfExtents, Vector3 direction, out RaycastHit hitInfo, Quaternion orientation) | |
{ | |
return Physics.BoxCast (center, halfExtents, direction, out hitInfo, orientation, maxDistance, mask.value, queryTriggerInteraction); | |
} | |
public bool BoxCast (Bounds bounds, Vector3 direction, out RaycastHit hitInfo, Quaternion orientation) | |
{ | |
return BoxCast (bounds.center, bounds.extents / 2f, direction, out hitInfo, orientation); | |
} | |
public int OverlapSphereNonAlloc (Vector3 position, Collider[] results) | |
{ | |
return Physics.OverlapSphereNonAlloc (position, maxDistance, results, mask.value, queryTriggerInteraction); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment