Check IsTargetable in FindTarget
This commit is contained in:
parent
4b96196b69
commit
417bcd9485
@ -171,11 +171,16 @@ public class AIEntity : Entity {
|
||||
float lastDist = float.MaxValue;
|
||||
Transform chosenEntity = null!;
|
||||
foreach (Transform other in entityParent) {// Find the closest entity
|
||||
if (other.GetComponent<Entity>() is {} otherEntity) {
|
||||
if (entity.IsTargetable(otherEntity)) {
|
||||
float distance = Vector2.Distance(other.position, entity.transform.position);
|
||||
if (distance < lastDist) {
|
||||
lastDist = distance;
|
||||
chosenEntity = other;
|
||||
if (lastDist <= entity.AIStats.closeEnough) break;
|
||||
if (lastDist <= entity.AIStats.closeEnough)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user