From 8a1fdc6f9e0a43821abe29877a39407f1f324fae Mon Sep 17 00:00:00 2001 From: Syntriax Date: Sun, 13 Nov 2022 17:43:47 +0300 Subject: [PATCH] Collider Check to Non Alloc --- ColliderCheck/TwoDimensionalBoxChildColliderCheck.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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()