public static void SwitchDimensions(GameObject obj, Dimension fromDimension, Dimension toDimension) { obj.layer = toDimension.layer; ControllerRenderer controller = obj.GetComponent <ControllerRenderer>(); if (controller != null) { controller.SwitchDimensions(toDimension); return; } HandCollider handCollider = obj.GetComponentInChildren <HandCollider>(); if (handCollider != null) { handCollider.collisionMask = toDimension.layer; } // Move over all visible children as well foreach (MeshRenderer childRenderer in obj.GetComponentsInChildren <MeshRenderer>()) { childRenderer.gameObject.layer = toDimension.layer; } // If this is an FPS controller then make sure it goes through too. Transform parent = obj.transform.parent; if (parent != null && parent.GetComponent <CharacterController>()) { parent.gameObject.layer = toDimension.layer; } }
//Constructors: public ManagedHandCollider(ManagedHand managedHand) { //sets: _managedHand = managedHand; //creates: GameObject collider = new GameObject($"({managedHand.Hand.Type}Collider)", typeof(SphereCollider), typeof(BoxCollider), typeof(Rigidbody)); collider.GetComponent <Rigidbody>().isKinematic = true; _handCollider = collider.AddComponent <HandCollider>(); _boxCollider = _handCollider.GetComponent <BoxCollider>(); _boxCollider.enabled = false; _sphereCollider = _handCollider.GetComponent <SphereCollider>(); _sphereCollider.enabled = false; //hooks (relay the events coming from the relay to simplify access): _handCollider.OnTriggerEntered.AddListener(HandleTriggerEnter); _handCollider.OnTriggerStayed.AddListener(HandleTriggerStay); _handCollider.OnTriggerExited.AddListener(HandleTriggerExit); _handCollider.OnCollisionEntered.AddListener(HandleCollisionEnter); _handCollider.OnCollisionStayed.AddListener(HandleCollisionStay); _handCollider.OnCollisionExited.AddListener(HandleCollisionExit); _managedHand.Gesture.OnVerifiedGestureChanged += HandleGestureChanged; _managedHand.OnVisibilityChanged += HandleVisibility; _managedHand.Gesture.Pinch.Touch.OnEnd += HandleTouchEnd; _managedHand.Gesture.Grasp.Touch.OnEnd += HandleTouchEnd; _managedHand.OnVisibilityChanged += HandleVisibilityChanged; }
private void Start() { //Find hand Colliders GameObject o = GameObject.Find("[Thry]HandCollider_L"); if (o == null) { Debug.LogError("[ThryError] Can't Find Left Thry Hand Collider"); return; } _left = o.GetComponent <HandCollider>(); o = GameObject.Find("[Thry]HandCollider_R"); if (o == null) { Debug.LogError("[ThryError] Can't Find Right Thry Hand Collider"); return; } _right = o.GetComponent <HandCollider>(); //Find clapper actions in children int actionsCount = 0; for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (child.GetComponent <ClapperEffect>() != null) { _localEffect = transform.GetChild(i).GetComponent <ClapperEffect>(); if (!hasNetworkedEffect) { hasLocalEffect = true; } } if (child.GetComponent <ObjectPool.OneObjectPerPlayerPool>() != null) { _effectPool = transform.GetChild(i).GetComponent <ObjectPool.OneObjectPerPlayerPool>(); hasNetworkedEffect = true; hasLocalEffect = false; } if (child.GetComponent <ThryAction>() != null && child.GetComponent <ThryAction>().isClapperAction) { actionsCount++; } } _clapperActions = new ThryAction[actionsCount]; actionsCount = 0; for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).GetComponent <ThryAction>() != null && transform.GetChild(i).GetComponent <ThryAction>().isClapperAction) { _clapperActions[actionsCount++] = transform.GetChild(i).GetComponent <ThryAction>(); } } //Register clap callback on hands _right.RegisterClapCallback(this.gameObject); _left.RegisterClapCallback(this.gameObject); }
private void OnTriggerEnter(Collider collider) { if (collider == null || collider.gameObject == null) { return; } if (localState == STATE_RIMING && collider.gameObject.GetComponent <HandCollider>() != null) { HandCollider hand = collider.gameObject.GetComponent <HandCollider>(); Networking.SetOwner(Networking.LocalPlayer, gameObject); SetState(STATE_FYING); _rigidbody.velocity = hand._velocity; start_velocity = _rigidbody.velocity; start_position = transform.position; start_rotation = transform.rotation; RequestSerialization(); } }