コード例 #1
0
        public Vector3 GetBonePosition(int boneIndex, bool local = false)
        {
            if (handSkeleton != null)
            {
                return(handSkeleton.GetBonePosition(boneIndex, local));
            }

            return(Vector3.zero);
        }
コード例 #2
0
        // Use this for initialization
        void Start()
        {
            poses    = GetComponent <KnucklePoses>();
            skeleton = GetComponent <SteamVR_Behaviour_Skeleton>();
            hand     = skeleton.inputSource;
            GameObject _claws = Instantiate(clawPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.wrist), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.wrist));

            _claws.transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.wrist);
            if (hand == SteamVR_Input_Sources.LeftHand)
            {
                _claws.transform.localScale = new Vector3(1, 1, 1);
            }
            claws = _claws.GetComponent <KnuckleClawScaler>();
        }
コード例 #3
0
        // Use this for initialization
        void Start()
        {
            actionSet.ActivateSecondary();
            poses    = GetComponent <KnucklePoses>();
            skeleton = GetComponent <SteamVR_Behaviour_Skeleton>();
            hand     = skeleton.inputSource;
            if (spiritGunPrefab != null)
            {
                GameObject spiritGun = Instantiate(spiritGunPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.indexTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.indexTip));
                spiritGunEffect = spiritGun.GetComponent <SpiritGunGlow>();
                spiritGunEffect.transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.indexTip);
            }
            if (shockPrefab != null)
            {
                shockObjects[0] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.indexTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.indexTip));
                shockObjects[0].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.indexTip);
                shockObjects[0].SetActive(false);

                shockObjects[1] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.middleTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.middleTip));
                shockObjects[1].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.middleTip);
                shockObjects[1].SetActive(false);

                shockObjects[2] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.ringTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.ringTip));
                shockObjects[2].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.ringTip);
                shockObjects[2].SetActive(false);

                shockObjects[3] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.pinkyTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.pinkyTip));
                shockObjects[3].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.pinkyTip);
                shockObjects[3].SetActive(false);

                shockObjects[4] = Instantiate(shockPrefab, skeleton.GetBonePosition(SteamVR_Skeleton_JointIndexes.thumbTip), skeleton.GetBoneRotation(SteamVR_Skeleton_JointIndexes.thumbTip));
                shockObjects[4].transform.parent = skeleton.GetBone(SteamVR_Skeleton_JointIndexes.thumbTip);
                shockObjects[4].SetActive(false);

                if (hand == SteamVR_Input_Sources.LeftHand)
                {
                    foreach (GameObject shockObject in shockObjects)
                    {
                        shockObject.transform.localScale = new Vector3(1, 1, 1);
                    }
                }
            }
        }