コード例 #1
0
    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();
    }
コード例 #2
0
    protected void OnTriggerEnter(Collider other)
    {
        if (!enabled || !isServer)
        {
            return;
        }

        if (TriggeringTags.Contains(other.tag))
        {
            TriggeredCount++;

            if (TriggeredCount == 1)
            {
                BaseActivateBehaviour();
            }
        }
    }
コード例 #3
0
    protected void OnTriggerExit(Collider other)
    {
        if (!enabled || !isServer)
        {
            return;
        }

        if (TriggeringTags.Contains(other.tag))
        {
            TriggeredCount--;

            if (TriggeredCount <= 0)
            {
                TriggeredCount = 0;
                BaseDeactivateBehaviour();
            }
        }
    }