Collission Checker has been Added and Basic Patrolling Enemy Updated to use the Checkers

This commit is contained in:
2022-02-21 16:27:23 +03:00
parent 4cfbf23960
commit cd2f667f56
6 changed files with 406 additions and 166 deletions

View File

@@ -0,0 +1,18 @@
using UnityEngine;
namespace Movement
{
public class CollissionChecker : MonoBehaviour
{
private Collider2D[] nonAllocColliderArray = new Collider2D[5];
public LayerMask LayerMask = ~((1 << 6) | (1 << 7)); // Everything except the "Player" and "Enemy" layer
public bool IsCollided => Physics2D.OverlapBoxNonAlloc(transform.position, transform.localScale, 0, nonAllocColliderArray, LayerMask) != 0;
public void OnDrawGizmosSelected()
{
Gizmos.color = IsCollided ? Color.green : Color.red;
Gizmos.DrawWireCube(transform.position, transform.localScale);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 02e036b6321fff34cbd154fd665a8b23
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: