Collider Check to Non Alloc

This commit is contained in:
Syntriax 2022-11-13 17:43:47 +03:00
parent b93c966218
commit 8a1fdc6f9e
1 changed files with 2 additions and 1 deletions

View File

@ -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<bool>();
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()