private void CalculateColliderAcitvationRange() { var colliderActivationRange = GetBoundingSphereRadius(); var sc = GetComponent <SphereCollider>(); sc.radius = colliderActivationRange + CubeInteractionRadius; InteractableCollider.Radius = colliderActivationRange; var colliders = Physics.OverlapSphere(transform.position, colliderActivationRange + CubeInteractionRadius).ToList(); //Remove colliders that don't trigger us. for (var i = 0; i < colliders.Count; i++) { if (TriggeringTags.Contains(colliders[i].tag)) { continue; } colliders.RemoveAt(i); i--; } TriggeredCount = colliders.Count; EvaluateTriggeredCount(); }
protected void OnTriggerEnter(Collider other) { if (!enabled || !isServer) { return; } if (TriggeringTags.Contains(other.tag)) { TriggeredCount++; if (TriggeredCount == 1) { BaseActivateBehaviour(); } } }
protected void OnTriggerExit(Collider other) { if (!enabled || !isServer) { return; } if (TriggeringTags.Contains(other.tag)) { TriggeredCount--; if (TriggeredCount <= 0) { TriggeredCount = 0; BaseDeactivateBehaviour(); } } }