private void CreateCollider(Transform transform) { if (!transform.gameObject.GetComponent(typeof(CapsuleCollider)) && !transform.gameObject.GetComponent(typeof(SphereCollider)) && transform.name.Contains("hands")) { if (transform.name.Contains("thumb") || transform.name.Contains("index") || transform.name.Contains("middle") || transform.name.Contains("ring") || transform.name.Contains("pinky")) { if (!transform.name.EndsWith("0")) { CapsuleCollider collider = transform.gameObject.AddComponent <CapsuleCollider>(); if (!transform.name.EndsWith("1")) { collider.radius = Phalanges.Radius; collider.height = Phalanges.Height; collider.center = Phalanges.GetCenter(transform.name.Contains("_l_")); collider.direction = 0; } else { collider.radius = Metacarpals.Radius; collider.height = Metacarpals.Height; collider.center = Metacarpals.GetCenter(transform.name.Contains("_l_")); collider.direction = 0; } } } else if (transform.name.Contains("grip")) { SphereCollider collider = transform.gameObject.AddComponent <SphereCollider>(); collider.radius = 0.04f; collider.center = new Vector3(((transform.name.Contains("_l_")) ? -1 : 1) * 0.01f, 0.01f, 0.02f); } } }
private void CreateCollider(GameObject finger) { //System.Type mType = System.Type.GetType("PositionRotationTracker"); //finger.AddComponent(mType); CapsuleCollider collider = finger.AddComponent <CapsuleCollider>(); collider.radius = Phalanges.Radius; collider.height = Phalanges.Height; collider.center = Phalanges.GetCenter(transform.name.Contains("_l_")); collider.direction = 0; //collider.isTrigger = true; }
//CreateCollider: Create CapsuleCollider for each finger joint. //Parameter: the transform of the finger joint. private void CreateCollider(Transform transform) { //if the object has "ignore" in its name, just ignore it. if (transform.name.Contains("ignore") || transform.name.EndsWith("hand")) { return; } // if the object is the palm, it needs a box collider. if (transform.name.Contains("grip")) { // if did not have collider before: if (!transform.gameObject.GetComponent(typeof(SphereCollider))) { SphereCollider collider1 = transform.gameObject.AddComponent <SphereCollider>(); collider1.radius = 0.03f; collider1.center = new Vector3(0.01f, 0.015f, 0.035f); CapsuleCollider collider2 = transform.gameObject.AddComponent <CapsuleCollider>(); collider2.radius = 0.01f; collider2.height = 0.06f; collider2.center = new Vector3(0.01f, 0.05f, 0.035f); collider2.direction = 2; } } // if the object is not palm but a finger, it needs a capsulde collider else if (!transform.gameObject.GetComponent(typeof(CapsuleCollider))) { // if the finger bone is not a Metacarpals if (!transform.name.EndsWith("0")) { CapsuleCollider collider = transform.gameObject.AddComponent <CapsuleCollider>(); if (!transform.name.EndsWith("1")) { collider.radius = Phalanges.Radius; collider.height = Phalanges.Height; collider.center = Phalanges.GetCenter(); collider.direction = 0; } // if the finger bone is a Metacarpals else { collider.radius = Metacarpals.Radius; collider.height = Metacarpals.Height; collider.center = Metacarpals.GetCenter(); collider.direction = 0; } } } }
//collider private void CreateCollider(Transform transform) { if (!transform.gameObject.GetComponent(typeof(CapsuleCollider)) && !transform.gameObject.GetComponent(typeof(SphereCollider)) && transform.name.Contains("hands")) { if (transform.name.Contains("index")) { if (!transform.name.EndsWith("0")) { if (!transform.name.EndsWith("1")) { CapsuleCollider collider = transform.gameObject.AddComponent <CapsuleCollider>(); Rigidbody rigidbody = transform.gameObject.AddComponent <Rigidbody>(); rigidbody.useGravity = false; rigidbody.isKinematic = true; this.tag = "rightHand"; collider.radius = Phalanges.Radius; collider.height = Phalanges.Height; collider.center = Phalanges.GetCenter(transform.name.Contains("_l_")); collider.direction = 0; } } } else if (transform.name.Contains("grip")) { /* * SphereCollider collider = transform.gameObject.AddComponent<SphereCollider>(); * Rigidbody rigidbody = transform.gameObject.AddComponent<Rigidbody>(); * transform.gameObject.AddComponent(Type.GetType("OpenHandUI")); * rigidbody.useGravity = false; * rigidbody.isKinematic = true; * collider.isTrigger = true; * collider.radius = 0.035f; * collider.center = new Vector3( * ((transform.name.Contains("_l_")) ? -1 : 1) * 0.01f, * 0.01f, 0.02f); */ } } }
private void CreateCollider(Transform transform) { if (!transform.gameObject.GetComponent(typeof(CapsuleCollider)) && !transform.gameObject.GetComponent(typeof(SphereCollider)) && transform.name.Contains("hands")) { if (transform.name.Contains("thumb") || transform.name.Contains("index") || transform.name.Contains("middle") || transform.name.Contains("ring") || transform.name.Contains("pinky")) { if (!transform.name.EndsWith("0")) { CapsuleCollider collider = transform.gameObject.AddComponent <CapsuleCollider>(); if (!transform.name.EndsWith("1")) { collider.radius = Phalanges.Radius * 1.5f; collider.height = Phalanges.Height; collider.center = Phalanges.GetCenter(transform.name.Contains("_l_")); collider.direction = 0; Rigidbody rb = transform.gameObject.AddComponent <Rigidbody>(); rb.isKinematic = true; rb.interpolation = RigidbodyInterpolation.Extrapolate; rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative; rb.useGravity = false; } else { collider.radius = Metacarpals.Radius * 1.5f; collider.height = Metacarpals.Height; collider.center = Metacarpals.GetCenter(transform.name.Contains("_l_")); collider.direction = 0; } } } else if (transform.name.Contains("grip")) { SphereCollider collider = transform.gameObject.AddComponent <SphereCollider>(); collider.radius = 0.06f; collider.center = new Vector3(((transform.name.Contains("_l_")) ? -1 : 1) * 0.01f, 0.01f, 0.02f); } } }