FIx enemy AI
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user