Remote PlayerAPI GetTrackingData and GetBonePosition/Rotation/Transform return wrong position on LateUpdate
frou01
[Steps to reproduce]
1)make some visual object
2)attach U# & paste code
private void LateUpdate()
{
TrackingData trackingData = Networking.GetOwner(this.gameObject).GetTrackingData(VRCPlayerApi.TrackingDataType.RightHand);
transform.SetPositionAndRotation(trackingData.position, trackingData.rotation);
}
3)build & test with VR client and Last build test with desktop client.
[expected result]
Object move to RightHand of VR Player on desktop client.
[Actual Result]
Object move to side of VR Player's waist on desktop client.
Log In
Reimajo
FYI, this bug report here is missing some crucial details (the issue is the bone data, not tracking data, and this affects more than just LateUpdate). It is also not a bug, as far as I understand it.
First of all, remote players don't have tracking data, they will always return the hand bone data instead. The reason for this is that tracking data isn't sent over network.
But most importantly, the issue is that Udon doesn't cache bone positions, instead they give you direct access to the armature at any given time, which is a problem because this armature is probably moving around due to IK calculations before settling at the final position. You can only access the correct data in PostLateUpdate() as far as my testing has gone.
The solution for this would be to not give Udon direct access to bone data, but to cache the correct data after each finished IK calculation. Here is my canny for that: https://feedback.vrchat.com/vrchat-udon-closed-alpha-feedback/p/always-provide-correct-bone-data
Spiritmarsrover
Recent project of mine where i ran into this same thing.
Shiro K
Ran into the same issue with GetBonePosition(HumanBodyBones.LeftHand) or GetBonePosition(HumanBodyBones.RightHand). Works, after code runs in Update method instead of LateUpdate method.
Reimajo
Shiro K: If you need the correct bone data, you need to use PostLateUpdate() instead. Update() will only give you outdated information. It probably doesn't matter for your use case, because it will be close enough, but there is a visible lag behind the real position when using Update() instead of PostLateUpdate().
Shiro K
Reimajo: Thank you. In meantime it is also documented somewhere in the VRC docs (maybe also before, but I didn't check). Using PostLateUpdate solved my problem.
Reimajo
Shiro K: Unfortunately there are a few cases where this isn't helping. In particular because you cannot control during which timing certain events are being called, e.g. networking events or player interactions. And PostLateUpdate isn't available for delayed events (who knows why). But you can help upvoting the following canny if you want it to be fixed for all use cases, because the fix would be rather trivial: https://feedback.vrchat.com/vrchat-udon-closed-alpha-feedback/p/always-provide-correct-bone-data