private void OnTriggerStay2D(Collider2D collision) { IFactionHolder holder = collision.transform.GetComponent <IFactionHolder>(); // destroy self on enemy/neutral or on obstacles if (holder == null || holder.Faction != this.faction) { Destroy(gameObject); } }
private void Awake() { self = GetComponent <IFactionHolder>(); agent = GetComponent <PolyNav.PolyNavAgent>(); Reporter.ComponentMissingCheck(self); Reporter.ComponentMissingCheck(agent); serachArea.radius = range; isAttacking = false; }
private void OnTriggerStay2D(Collider2D collision) { // in attack mode no following if (isAttacking) { return; } IFactionHolder other = collision.GetComponent <IFactionHolder>(); if (other != null) { if (other.Faction != self.Faction) { agent.SetDestination(collision.transform.position); target = collision.transform; } } }