FIx enemy AI

This commit is contained in:
2023-08-03 12:09:24 +03:00
parent 754068bf58
commit e5f415f9d4
4 changed files with 17 additions and 8 deletions
+12 -3
View File
@@ -145,9 +145,18 @@ public abstract class Character : MonoBehaviour
private bool CanGoDown()
{
var rayCastHit = Physics2D.RaycastAll(_capsuleCollider.bounds.center, Vector2.down, _capsuleCollider.size.y+0.5f, _mapLayer);
if (rayCastHit.Any(x=>x.collider.transform.GetComponent<MapElement>().ElementSO.ElementType != MapElementType.Ladder))
return false;
var rayCastHit = Physics2D.RaycastAll(_capsuleCollider.bounds.center, Vector2.down, 0.5f, _mapLayer);
var isNoladder = rayCastHit.Any(x => x.collider.transform.GetComponent<MapElement>().ElementSO.ElementType != MapElementType.Ladder);
foreach (var hit in rayCastHit)
{
Debug.DrawLine(hit.point, hit.point + hit.normal.normalized * 0.2f, isNoladder? Color.blue: Color.red);
}
if (isNoladder)
{
return false;
}
return true;
}