Forum Discussion
gary.frewin
5 years agoExplorer
Bones list is empty
Hi Folks,
Two questions:
1. My list of bones is always empty.
I have an OVRhandprefab stored in a variable called skeleton. But when I call skeleton.Bones in my start method it always has a count of zero. So, I can't get a list of anything.
(this is from the valem gesture detection tutorial)
2. I want to get the position of the tip of the right hand at one point in my code. How do I reference this?
Thanks
- Anonymous5 years ago
You have to wait until the OVRSkeleton's Initialize method has finished before you can get the bones. The simplest way to do that is wait a frame before getting the bones. Since the Start method can be turned into a coroutine you can do that like this:
public class GetBones : MonoBehaviour { private OVRSkeleton skeleton; private Transform indexTipTransform; // Start is called before the first frame update IEnumerator Start() { skeleton = GetComponent<OVRSkeleton>(); while (skeleton.Bones.Count == 0) { yield return null; } foreach (var bone in skeleton.Bones) { if (bone.Id == OVRSkeleton.BoneId.Hand_IndexTip) { indexTipTransform = bone.Transform; } } } }Then if there's a particular part of the hand to you to get the position of you look for the bone.Id in the Bones list and store that part's transform (the foreach part above).
1 Reply
Replies have been turned off for this discussion
- Anonymous
You have to wait until the OVRSkeleton's Initialize method has finished before you can get the bones. The simplest way to do that is wait a frame before getting the bones. Since the Start method can be turned into a coroutine you can do that like this:
public class GetBones : MonoBehaviour { private OVRSkeleton skeleton; private Transform indexTipTransform; // Start is called before the first frame update IEnumerator Start() { skeleton = GetComponent<OVRSkeleton>(); while (skeleton.Bones.Count == 0) { yield return null; } foreach (var bone in skeleton.Bones) { if (bone.Id == OVRSkeleton.BoneId.Hand_IndexTip) { indexTipTransform = bone.Transform; } } } }Then if there's a particular part of the hand to you to get the position of you look for the bone.Id in the Bones list and store that part's transform (the foreach part above).
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 7 years ago
- 3 years ago