VRCPlayerApi.GetBonePosition sometimes throws exception if called early in scene
H
Hiina Kuukan
(speculative) reproduction:
- Create udon behaviour that on Update(), calls Networking.LocalPlayer.GetBonePosition(HumanBodyBones.LeftHand)
- Assign udon behaviour to gameObject that's active in scene by default
- In game, observe that the UdonBehaviour sometimes crashes with an exception in the console, and other times works.
I think there's an initialization race condition with the VRCPlayerAPI, where the GetBonePosition call can throw an exception if executed too early in the scene.
A real example that helped a user was adding this line (in UdonSharp) to a script: https://github.com/hiinaspace/utheremin/blob/3022801f9c3b844ebc69a57879d9b495fd0f0036/Assets/UTheremin/HandFollower.cs#L46 , i.e. waiting 3 seconds after Start() was called before attempting to call GetBonePosition.
Unfortunately I couldn't reproduce locally, but the workaround does seem to work for the user that reported the issue.
Log In