Пример #1
0
        protected virtual void OnEquippedUpdate(Inventory inventory, Item item, int slotIndex, bool quickEquipped)
        {
            if (slotIndex != myEquipIndex)
            {
                return;
            }


            if (mainRenderModel != null)
            {
                VRItemAddon vr_item = item.GetComponent <VRItemAddon>();
                if (vr_item != null)
                {
                    if (vr_item.handFollowTransform)
                    {
                        Quaternion targetHandRotation;
                        Vector3    targetHandPosition;

                        // Transform equipPoint = inventory.equippedItem.item.transform;
                        // Quaternion offset = Quaternion.Inverse(this.transform.rotation) * equipPoint.rotation;
                        targetHandRotation = item.transform.rotation;

                        // Vector3 worldOffset = (this.transform.position - equipPoint.position);
                        // Quaternion rotationDiff = mainRenderModel.GetHandRotation() * Quaternion.Inverse(this.transform.rotation);
                        // Vector3 localOffset = rotationDiff * worldOffset;
                        targetHandPosition = item.transform.position;// + localOffset;

                        mainRenderModel.SetHandRotation(targetHandRotation);
                        mainRenderModel.SetHandPosition(targetHandPosition);
                    }
                }
            }
        }
Пример #2
0
        void OnItemEquipped(Inventory inventory, Item item, int equipSlot, bool quickEquipped)
        {
            if (equipSlot != myEquipIndex)
            {
                return;
            }

            if (quickEquipped)
            {
                if (item.itemBehavior.equipType != Inventory.EquipType.Static && item.rigidbody != null)
                {
                    GetComponent <VelocityEstimator>().BeginEstimatingVelocity();
                }
            }

            VRItemAddon vr_item = item.GetComponent <VRItemAddon>();

            if (!vr_item)
            {
                Debug.LogError(item.name + " :: does not have a vr item component");
                return;
            }

            if (vr_item.hideHandOnAttach)
            {
                Hide();
            }



            // if (vr_item.handAnimationOnPickup != 0) {
            //         // Debug.LogError("animation state");

            //     SetAnimationState(vr_item.handAnimationOnPickup);
            // }

            if (vr_item.setRangeOfMotionOnPickup != SkeletalMotionRangeChange.None)
            {
                // Debug.LogError("range of mot ion");
                SetTemporarySkeletonRangeOfMotion(vr_item.setRangeOfMotionOnPickup);
            }

            if (vr_item.usePose)
            {
                // if (!string.IsNullOrEmpty(vr_item.poseName)) {//.skeletonPoser != null)
                // if (vr_item.skeletonPoser != null && skeleton != null) {

                // Debug.LogError("blendign to poser");
                skeleton.BlendToPoser(vr_item.poseName, vr_item.poseInfluence, blendToPoseTime);
                // }
            }

            if (vr_item.activateActionSetOnAttach != null)
            {
                vr_item.activateActionSetOnAttach.Activate(handType);
            }
        }
Пример #3
0
        void OnItemUnequipped(Inventory inventory, Item item, int slotIndex, bool quickEquipped)
        {
            if (slotIndex != myEquipIndex)
            {
                return;
            }

            if (quickEquipped)
            {
                if (item.itemBehavior.equipType != Inventory.EquipType.Static)
                {
                    Rigidbody rigidbody = item.rigidbody;
                    if (rigidbody != null)
                    {
                        Vector3 velocity;
                        Vector3 angularVelocity;

                        GetReleaseVelocities(rigidbody, out velocity, out angularVelocity);

                        rigidbody.velocity        = velocity;
                        rigidbody.angularVelocity = angularVelocity;
                    }
                }
            }

            VRItemAddon vr_item = item.GetComponent <VRItemAddon>();

            if (!vr_item)
            {
                Debug.LogError(item.name + " :: does not have a vr item component");
                return;
            }

            if (vr_item.hideHandOnAttach)
            {
                Show();
            }

            // if (vr_item.handAnimationOnPickup != 0)
            //     {

            //     StopAnimation();
            //     }

            if (vr_item.setRangeOfMotionOnPickup != SkeletalMotionRangeChange.None)
            {
                // Debug.LogError("range of motion unewiup");
                ResetTemporarySkeletonRangeOfMotion();
            }

            if (mainRenderModel != null)
            {
                // Debug.LogError("render mdel");
                mainRenderModel.ReturnHandToOrigin();
                // mainRenderModel.MatchHandToTransform(mainRenderModel.transform);
            }
            //move to vr interacable
            if (vr_item.usePose)
            // if (!string.IsNullOrEmpty(vr_item.poseToUse))//.skeletonPoser != null)
            {
                if (skeleton != null)
                {
                    // Debug.LogError("blend to skeleton");
                    skeleton.BlendToSkeleton(releasePoseBlendTime);
                }
            }

            if (vr_item.activateActionSetOnAttach != null)
            {
                // int otherHandEquipIndex = VRManager.Hand2Int(VRManager.OtherHand(handType));
                // int otherHandEquipIndex = 1-GetComponent<EquipPoint>().equipSlotOnBase;
                // if (inventory.otherInventory.equippedItem == null || inventory.otherInventory.equippedItem.item.GetComponent<VRItemAddon>().activateActionSetOnAttach != vr_item.activateActionSetOnAttach)
                if (inventory.equippedSlots[otherHandEquipIndex] == null || inventory.equippedSlots[otherHandEquipIndex].sceneItem.GetComponent <VRItemAddon>().activateActionSetOnAttach != vr_item.activateActionSetOnAttach)

                {
                    vr_item.activateActionSetOnAttach.Deactivate(handType);
                }
            }
        }