public void Trigger(Missile missile) { //Debug.Log("MISSILE SENSOR TRIGGERED!!!!"); var missileOwner = missile.GetOwner(); if (missileOwner != null) { var missileOwnerActor = missileOwner.GetComponentInParent <ActorAgent>(); if (missileOwnerActor != null) { if (missileOwnerActor.Team == opposingTeam) { var target = Targeting.FindNearest(opposingTeam, owner.GetVehicle().transform.position, 500f); owner.SetTarget(target); } } } }
private IEnumerator CheckInside(float delay) { yield return(new WaitForSeconds(delay)); var recentColliders = Physics.OverlapSphere(transform.position, triggerCollider.radius, LayerMask.GetMask("Detectable")).ToList(); var enteredColliders = recentColliders.Except(lastColliders).ToList(); var exitedColliders = lastColliders.Except(recentColliders).ToList(); if (enteredColliders.Count > 0 || exitedColliders.Count > 0) { if (!owner.HasTarget()) { var target = Targeting.FindNearest(opposingTeam, owner.GetVehicle().transform.position, triggerCollider.radius); owner.SetTarget(target); } } lastColliders = recentColliders; StartCoroutine(CheckInside(CheckFrequency)); }