public override bool checkProceduralPrecondition(GameObject agent) { MommyHouse[] GenerousPeople = (MommyHouse[]) UnityEngine.GameObject.FindObjectsOfType ( typeof(MommyHouse)); MommyHouse closest = null; float closestDist = 0; foreach (MommyHouse giver in GenerousPeople) { if (closest == null) { // first one, so choose it for now closest = giver; closestDist = (giver.gameObject.transform.position - agent.transform.position).magnitude; } else { // is this one closer than the last? float dist = (giver.gameObject.transform.position - agent.transform.position).magnitude; if (dist < closestDist) { // we found a closer one, use it closest = giver; closestDist = dist; } } } if (closest == null) return false; myMom = closest; target = myMom.gameObject; return closest != null; }
public override void reset() { cried = false; myMom = null; startTime = 0; }