/// <summary> /// Returns if the given position is within a collider of any unit in the scene. /// </summary> /// <param name="position"></param> /// <returns>True if the given position is within any unit's collider, false if not.</returns> static bool PositionInsideAnyUnitCollider(Vector3 position) { List <GameObject> units = UnitTracker.GetActiveUnits(); foreach (GameObject go in units) { MeshCollider mc = go.GetComponent <MeshCollider>(); if (mc == null) { continue; } if (mc.bounds.Contains(position)) { return(true); } } return(false); }
float maxTargetLength = 10.0f; // Maximum amount of time to have a target before searching for a new one void Start() { myInfo = GetComponent <UnitInfo>(); weaponsController = GetComponent <WeaponsController>(); myRigidbody = GetComponent <Rigidbody>(); target = GetEasiestTarget(); myHealth = GetComponent <Health> (); phase = 1; shieldsOn = true; boosted = false; if (!UnitTracker.GetActiveUnits().Contains(this.gameObject)) { UnitTracker.AddUnit(this.gameObject); } // set target on spawn messageTxt = GameObject.Find("MessageText").GetComponent <MessageTextController>(); messageTxt.DisplayMessage("Their shields are too strong for our weapons. Try to find a weak point."); }