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