Ejemplo n.º 1
0
 //-------------------------------------------------
 // Called every Update() while a Hand is hovering over this object
 //-------------------------------------------------
 private void HandHoverUpdate(VRTRIXGloveGrab hand)
 {
     //Debug.Log(VRTRIXGloveVRInteraction.GetGesture(hand.GetHandType()));
     if (hand.GetStandardInteractionButtonDown())
     {
         if (hand.currentAttachedObject != gameObject)
         {
             isHoveredbyHand = true;
             //Call this to continue receiving HandHoverUpdate messages,
             // and prevent the hand from hovering over anything else
             hand.HoverLock(GetComponent <VRTRIXInteractable>());
             if (hand.GetHandType() == HANDTYPE.LEFT_HAND)
             {
                 // Attach this object to the left hand
                 //hand.AttachObject(gameObject, attachmentFlags);
                 hand.AttachLongBow(gameObject, attachmentFlags, "L_Middle_1");
                 gameObject.transform.localPosition = new Vector3(-0.311f, 0.072f, 0.04f);
                 gameObject.transform.localRotation = Quaternion.Euler(0, 200f, 90f);
             }
             else if (hand.GetHandType() == HANDTYPE.RIGHT_HAND)
             {
                 hand.AttachLongBow(gameObject, attachmentFlags, "R_Middle_1");
                 gameObject.transform.localPosition = new Vector3(-0.311f, 0.072f, 0.04f);
                 gameObject.transform.localRotation = Quaternion.Euler(0, -20f, -90f);
             }
         }
     }
 }
Ejemplo n.º 2
0
        //-------------------------------------------------
        private void SpawnAndAttachObject(VRTRIXGloveGrab hand)
        {
            if (hand.otherHand != null)
            {
                //If the other hand has this item package, take it back from the other hand
                VRTRIXGloveItemPackage otherHandItemPackage = GetAttachedItemPackage(hand.otherHand);
                if (otherHandItemPackage == itemPackage)
                {
                    TakeBackItem(hand.otherHand);
                }
            }

            //if (showTriggerHint)
            //{
            //    ControllerButtonHints.HideTextHint(hand, Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
            //}

            if (itemPackage.otherHandItemPrefab != null)
            {
                if (hand.otherHand.hoverLocked)
                {
                    //Debug.Log( "Not attaching objects because other hand is hoverlocked and we can't deliver both items." );
                    return;
                }
            }

            // if we're trying to spawn a one-handed item, remove one and two-handed items from this hand and two-handed items from both hands
            if (itemPackage.packageType == VRTRIXGloveItemPackage.ItemPackageType.OneHanded)
            {
                RemoveMatchingItemTypesFromHand(VRTRIXGloveItemPackage.ItemPackageType.OneHanded, hand);
                RemoveMatchingItemTypesFromHand(VRTRIXGloveItemPackage.ItemPackageType.TwoHanded, hand);
                RemoveMatchingItemTypesFromHand(VRTRIXGloveItemPackage.ItemPackageType.TwoHanded, hand.otherHand);
            }

            // if we're trying to spawn a two-handed item, remove one and two-handed items from both hands
            if (itemPackage.packageType == VRTRIXGloveItemPackage.ItemPackageType.TwoHanded)
            {
                RemoveMatchingItemTypesFromHand(VRTRIXGloveItemPackage.ItemPackageType.OneHanded, hand);
                RemoveMatchingItemTypesFromHand(VRTRIXGloveItemPackage.ItemPackageType.OneHanded, hand.otherHand);
                RemoveMatchingItemTypesFromHand(VRTRIXGloveItemPackage.ItemPackageType.TwoHanded, hand);
                RemoveMatchingItemTypesFromHand(VRTRIXGloveItemPackage.ItemPackageType.TwoHanded, hand.otherHand);
            }

            spawnedItem = GameObject.Instantiate(itemPackage.itemPrefab);
            spawnedItem.SetActive(true);
            Debug.Log("attachmentPoint: " + attachmentPoint);
            hand.AttachLongBow(spawnedItem, attachmentFlags, attachmentPoint);

            //if ((itemPackage.otherHandItemPrefab != null) && (hand.otherHand.controller != null))
            if ((itemPackage.otherHandItemPrefab != null))
            {
                Debug.Log("Other Hand Prefab not NULL");
                GameObject otherHandObjectToAttach = GameObject.Instantiate(itemPackage.otherHandItemPrefab);
                otherHandObjectToAttach.SetActive(true);
                hand.otherHand.AttachLongBow(otherHandObjectToAttach, attachmentFlags, attachmentPoint);
            }

            itemIsSpawned = true;

            justPickedUpItem = true;

            if (takeBackItem)
            {
                useFadedPreview = true;
                pickupEvent.Invoke();
                CreatePreviewObject();
            }
        }