void Start() { HandStateSource[] sources = sourceGameObject.GetComponents <HandStateSource>(); Debug.Assert(sources.Length == 1); source = sources[0]; reprs = new GameObject[2, HandState.NUM_CAPSULEPARTS * 3]; system = FindObjectOfType <TrueHandlingPhysics>(); }
public PhysicsBoneManager(TrueHandlingPhysics main_, HandState state, int bone_) { main = main_; h = state.right ? 1 : 0; b = bone_; Debug.Assert(state.active); contactProposals = new Dictionary <GameObject, HandContact[]>(); contactPersistence = new Dictionary <Collider, HandContact> [HandState.BONE_CAPSULEPART_COUNT[b]]; noCollided = new HashSet <Collider> [HandState.BONE_CAPSULEPART_COUNT[b]]; for (int p = 0; p < HandState.BONE_CAPSULEPART_COUNT[b]; p++) { contactPersistence[p] = new Dictionary <Collider, HandContact>(); noCollided[p] = new HashSet <Collider>(); } thisPos = state.GetBonePosition(b); thisRot = state.GetBoneAngle(b); objects = new GameObject[1]; capsules = new GameObject[HandState.BONE_CAPSULEPART_COUNT[b]]; kinematicRoot = objects[0] = new GameObject("tr"); kinematicRoot.transform.parent = main.transform; kinematicRoot.layer = TrueHandlingPhysics.handCollisionLayer; Rigidbody rigid = kinematicRoot.AddComponent <Rigidbody>(); rigid.isKinematic = true; //rigid.collisionDetectionMode = CollisionDetectionMode.Continuous; Transform capsuleOwner = kinematicRoot.transform; for (int i = 0; i < capsules.Length; i++) { // THESE DON'T IGNORE COLLISION IN THE JOINT GameObject cap = capsules[i] = new GameObject(i.ToString()); cap.layer = TrueHandlingPhysics.handCollisionLayer; cap.AddComponent <CapsuleCollider>().direction = 2; cap.transform.parent = capsuleOwner; } }