protected override void CreateControllers() { base.CreateControllers(); foreach (var controller in new Controller[] { Left, Right }) { var boneCollider = CreateCollider(controller.transform, 0.01f); boneCollider.m_Center.y = -0.03f; boneCollider.m_Center.z = 0.01f; DynamicColliderRegistry.RegisterCollider(boneCollider); } }
protected override HandAttachments BuildAttachmentHand(Chirality handedness) { var hand = base.BuildAttachmentHand(handedness); foreach (var sphere in new Transform[] { hand.Thumb, hand.Index, hand.Middle, hand.Ring, hand.Pinky, hand.Palm }) { Logger.Info("Registering {0}", sphere); var boneCollider = CreateCollider(sphere, -0.05f); boneCollider.enabled = false; DynamicColliderRegistry.RegisterCollider(boneCollider); boneCollider = CreateCollider(sphere, 0.01f); boneCollider.enabled = false; DynamicColliderRegistry.RegisterCollider(boneCollider); } hand.OnBegin += delegate { foreach (var collider in hand.GetComponentsInChildren <DynamicBoneCollider>()) { collider.enabled = true; } }; hand.OnFinish += delegate { foreach (var collider in hand.GetComponentsInChildren <DynamicBoneCollider>()) { collider.enabled = false; } }; hand.gameObject.AddComponent <GrabHandler>(); Logger.Info("Added GrabHandler"); if (handedness == Chirality.Left) { // ClapDetector only on one hand. It tracks the other as well. hand.gameObject.AddComponent <ClapDetector>(); hand.gameObject.GetComponent <ClapDetector>().OnClap.AddListener(onHandsClapped); } return(hand); }