Beispiel #1
0
        public static void UpdateHeldItemTransform()
        {
            if (!VRConfig.configUseControllers.Value)
            {
                return;
            }

            ItemEquippable heldItem = PlayerAgent.FPItemHolder.WieldedItem;

            if (heldItem != null)
            {
                heldItem.transform.position = Controllers.GetControllerPosition() + WeaponArchetypeVRData.CalculateGripOffset();
                Vector3 recoilRot = heldItem.GetRecoilRotOffset();

                if (!Controllers.IsFiringFromADS())
                {
                    recoilRot.x *= 2f;
                }
                heldItem.transform.rotation       = Controllers.GetControllerAimRotation();
                heldItem.transform.localRotation *= Quaternion.Euler(recoilRot) * WeaponArchetypeVRData.GetVRWeaponData(heldItem).rotationOffset;
                heldItem.transform.position      += Controllers.GetControllerAimRotation() * heldItem.GetRecoilPosOffset();
            }
        }
Beispiel #2
0
        void Update()
        {
            bool isInDoubleHandPos = false;

            if (PlayerVR.LoadedAndInGame)
            {
                VRWeaponData itemData = WeaponArchetypeVRData.GetVRWeaponData(ItemEquippableEvents.currentItem);
                if (itemData.allowsDoubleHanded)
                {
                    bool wasAimingTwoHanded = aimingTwoHanded;
                    isInDoubleHandPos = AreControllersInDoubleHandedPosition();

                    if (!aimingTwoHanded && !wasInDoubleHandPosLastFrame && isInDoubleHandPos)
                    {
                        VRInput.TriggerHapticPulse(0.025f, 1 / .025f, 0.3f, GetDeviceFromType(offHandControllerType));
                    }

                    if (aimingTwoHanded)
                    {
                        aimingTwoHanded = !AreControllersOutsideOfDoubleHandedAimingRange();
                        if (wasAimingTwoHanded && !aimingTwoHanded)
                        {
                            VRInput.TriggerHapticPulse(0.025f, 1 / .025f, 0.3f, GetDeviceFromType(offHandControllerType));
                        }
                    }
                    else
                    {
                        aimingTwoHanded = AreControllersInDoubleHandedPosition();
                    }
                }
                else
                {
                    aimingTwoHanded = false;
                }
                wasInDoubleHandPosLastFrame = isInDoubleHandPos;
            }
        }
Beispiel #3
0
        static void Postfix(FirstPersonItemHolder __instance, ItemEquippable ___WieldedItem)
        {
            if (PlayerVR.VRSetup && VRSettings.UseVRControllers)
            {
                if (___WieldedItem == null)
                {
                    return;
                }
                Vector3 gripOffset = ___WieldedItem.transform.position - ___WieldedItem.transform.TransformPoint(WeaponArchetypeVRData.GetVRWeaponData(___WieldedItem.ArchetypeName).transformToVRGrip);

                ___WieldedItem.transform.position = Controllers.GetControllerPosition() + gripOffset;

                if (VRSettings.twoHandedAimingEnabled && Controllers.aimingTwoHanded && WeaponArchetypeVRData.GetVRWeaponData(___WieldedItem.ArchetypeName).allowsDoubleHanded)
                {
                    ___WieldedItem.transform.rotation = Controllers.GetTwoHandedRotation();
                }
                else
                {
                    ___WieldedItem.transform.rotation = Controllers.GetControllerAimRotation();
                }
            }
        }