void OnTriggerExit2D(Collider2D other) { if (other.gameObject.GetComponent <GameUnit>().unitIsTargetable() == true) { UnitData.enemyTarget = UnitUtils.FindObjectNearestToEndToEndOfSpline(gameObject, "Units"); } }
void OnTriggerEnter2d(Collider other) { //_OnTriggerStay2d_delegate(ObjectsContainer, other); if (other.gameObject.GetComponent <GameUnit>().unitIsTargetable() == true) { UnitData.enemyTarget = UnitUtils.FindObjectNearestToEndToEndOfSpline(gameObject, "Units"); } }
// Update is called once per frame void Update() { if (FireRateTimer <= 0) { Target = UnitUtils.FindObjectNearestToEndToEndOfSpline(gameObject, "Units"); } if (Target && FireRateTimer <= 0) { Points[1] = Target.transform.position; LineRend.SetPositions(Points); FireProjectileWeapon(Target); Target = null; } FireRateTimer -= Time.deltaTime; }