diff --git a/ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs b/ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs index 255a42a..691bad1 100644 --- a/ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs +++ b/ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs @@ -7,6 +7,7 @@ namespace Syntriax.Modules.Movement.ColliderTrigger { [SerializeField] private LayerMask colliderMask = 0; private bool _isTrigerred = false; + private Collider2D[] results = new Collider2D[8]; public LayerMask ColliderMask { get => colliderMask; set => colliderMask = value; } @@ -29,7 +30,7 @@ namespace Syntriax.Modules.Movement.ColliderTrigger => OnTriggered = new UnityEvent(); protected void FixedUpdate() - => IsTrigerred = Physics2D.OverlapBox(transform.position, transform.localScale, 0, ColliderMask) != null; + => IsTrigerred = Physics2D.OverlapBoxNonAlloc(transform.position, transform.localScale, 0, results, ColliderMask) > 0; #if UNITY_EDITOR private void OnDrawGizmosSelected()