Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
UPDESIGNSTUDIO's avatar
4 years ago

bug in OVRSkeleton update: capsules only update on first frame/initialization

in Oculus Integration 29.0, there is a bug that the hand capsules only update on the first frame, when the hand is initialized.

maybe it is due to some settings, but the capsule.CapsuleRigidbody.MovePosition and capsule.CapsuleRigidbody.position do not seem to work in unity 2020.3.12f1.

 

here is a quick hotfix with 2 lines of code, which sets the transform of the capsule GO

	private void FixedUpdate()
	{
		if (!IsInitialized || _dataProvider == null)
		{
			IsDataValid = false;
			IsDataHighConfidence = false;

			return;
		}

		Update();

		if (_enablePhysicsCapsules)
		{
			var data = _dataProvider.GetSkeletonPoseData();

			IsDataValid = data.IsDataValid;
			IsDataHighConfidence = data.IsDataHighConfidence;

			for (int i = 0; i < _capsules.Count; ++i)
			{
				OVRBoneCapsule capsule = _capsules[i];
				var capsuleGO = capsule.CapsuleRigidbody.gameObject;
				if (data.IsDataValid && data.IsDataHighConfidence)
				{
					Transform bone = _bones[(int)capsule.BoneIndex].Transform;
					if (capsuleGO.activeSelf)
					{
						capsule.CapsuleRigidbody.MovePosition(bone.position);
						capsule.CapsuleRigidbody.MoveRotation(bone.rotation);
					}
					else
					{
						capsuleGO.SetActive(true);
						capsule.CapsuleRigidbody.position = bone.position;
						capsule.CapsuleRigidbody.rotation = bone.rotation;
					}
					//this is a temporary hotfix. should be avoided, because accessing GO each frame for each capsule is slow!
					capsule.CapsuleRigidbody.gameObject.transform.position = bone.position;
					capsule.CapsuleRigidbody.gameObject.transform.rotation = bone.rotation;
					
				}
				else
				{
					if (capsuleGO.activeSelf)
					{
						capsuleGO.SetActive(false);
					}
				}


			}
		}
	}

not sure where to post this, i couldnt find a git, or bug report location.