Пример #1
0
    private void OnTriggerEnter(Collider other)
    {
        // Item
        NeuronVR_Item item = other.gameObject.GetComponent <NeuronVR_Item>();

        if (item != null && this.collidingItem == null)
        {
            collidingItem = item;
        }

        // Equipment
        NeuronVR_Equipment equip = other.gameObject.GetComponentInParent <NeuronVR_Equipment>();

        if (equip != null && collidingEquipment == null)
        {
            if (equip.GetEquipmentType() == NeuronVR_Equipment.Type.Shield && id == HandID.Left)
            {
                collidingEquipment = equip;
            }
            else if (equip.GetEquipmentType() == NeuronVR_Equipment.Type.Sword && id == HandID.Right)
            {
                collidingEquipment = equip;
            }
        }
    }
Пример #2
0
    public void SetGrabbing(bool grabbing)
    {
        // If the state of grabbing didn't change, do nothing
        if (grabbing == isGrabbing)
        {
            return;
        }

        // Performed grab gesture
        if (grabbing)
        {
            // If item grabbing is allowed (e.g. it's forbidden for the right hand in teleport mode since
            // the grab gesture is used then to activate the teleport)
            if (allowItemGrab)
            {
                // If colliding with an item & that item is not already grabbed by the other hand
                if (collidingItem != null && !collidingItem.IsGrabbed())
                {
                    holdingItem = true;
                    collidingItem.Grab(transform);
                }

                // Equipment
                if (collidingEquipment != null)
                {
                    holdingEquipment = true;
                    collidingEquipment.Grab(weaponHoldingTransform);
                }
            }
        }
        // Not grabbing
        else // Released grab
        {
            // Release item if holding one
            if (holdingItem && collidingItem != null)
            {
                bool itemDroppedInInventoryOrDoorZone = collidingItem.Release();
                if (itemDroppedInInventoryOrDoorZone)
                {
                    collidingItem = null;
                }
                holdingItem = false;
            }

            // Equipment
            if (holdingEquipment && collidingEquipment != null)
            {
                collidingEquipment.Release();
                collidingEquipment = null;
            }
        }

        isGrabbing = grabbing;
    }
Пример #3
0
    private void OnTriggerExit(Collider other)
    {
        // Item
        NeuronVR_Item item = other.gameObject.GetComponent <NeuronVR_Item>();

        if (item != null && this.collidingItem == item)
        {
            collidingItem = null;
        }

        // Equipment
        NeuronVR_Equipment equip = other.gameObject.GetComponent <NeuronVR_Equipment>();

        if (equip != null && equip == collidingEquipment)
        {
            collidingEquipment = null;
        }
    }
Пример #4
0
 public void DropItem()
 {
     collidingItem = null;
     allowItemGrab = true;
 }