private void DetectObjectHitLabel() { InteractableItem currentHitObject = hitInteractable.GetComponent <InteractableItem>(); //Detect what is hit with the ray, Can be a menu, arrows or an item. if (currentHitObject != null) { if (currentHitObject.isMenuItem) { prefab = (GameObject)Instantiate(currentHitObject.worldPrefab, transform.position, Quaternion.Euler(0, 0, 0)); //Spawn it at the controllers pos and with 0 rotation (facing upwards) interactingItem = prefab.GetComponent <InteractableItem>(); //Is only used for letting an object go again in this case interactingItem.BeginInteraction(this); Debug.Log(interactingItem); } else if (currentHitObject.isArrow) { currentHitObject.GetComponent <Arrows>().pressed = true; interactingItem = null; } else { interactingItem = currentHitObject; } if (interactingItem) //Starts interacting with the chosen item { if (interactingItem.IsInteracting()) //this statement is used in order to grap an item in the other hand { interactingItem.EndInteraction(this, false); } interactingItem.BeginInteraction(this); } } }
void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } if (controller.GetPressDown(gripButton)) { interactingItem = GetClosestItem(); if (interactingItem) { //if object is allready interacting with something else then drop it if (interactingItem.IsInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } else if (controller.GetPressUp(gripButton) && interactingItem != null) { interactingItem.EndInteraction(this); } }
void Update() { if (controller.GetPressDown(triggerButton)) { float min = float.MaxValue; float distance; foreach (InteractableItem obj in objects) { distance = (obj.transform.position - transform.position).sqrMagnitude; if (distance < min) { min = distance; closestItem = obj; } inHandItem = closestItem; if (inHandItem) { if (inHandItem.IsInteracting()) { inHandItem.EndInteraction(this); } inHandItem.BeginInteraction(this); } } } if (controller.GetPressUp(triggerButton) && inHandItem != null) { inHandItem.EndInteraction(this); } }
private void grabBrick() { // Check if flystick is inside a brick GameObject[] bricks = GameObject.FindGameObjectsWithTag("Brick"); GameObject selectedItem = null; foreach (GameObject brick in bricks) { if (brick.GetComponent <Collider>().bounds.Contains(flyStickInteraction.transform.position)) { selectedItem = brick; break; } } // Check if flystick points on a brick if (selectedItem == null) { flyStickInteraction.sendRayForBlocks(); selectedItem = flyStickInteraction.SelectedPart; } if (selectedItem) { interactingItem = selectedItem.GetComponent <InteractableItem>(); if (interactingItem) { GameObject towerObject = GameObject.Find("DynamicTower"); if (towerObject) { TowerInteractivity tower = towerObject.GetComponent <TowerInteractivity>(); if (interactingItem.name.Contains(TowerInteractivity.MaxRow.ToString()) && interactingItem.GetComponent <Renderer>().material.color != Color.green) { //return; } if (interactingItem.GetComponent <Renderer>().material.color != Color.green) { if (tower.FirstSelected == null) { tower.select(interactingItem.transform.gameObject); Debug.Log("select: " + interactingItem.transform.gameObject.name); } else { return; } } } if (interactingItem.isInteracting()) { interactingItem.EndInteraction(flyStickInteraction); interactingItem = null; Debug.Log("endInteraction"); } interactingItem.BeginInteraction(flyStickInteraction); } } }
private void Update() { if (enable) { if (InputSynchronizer.GetKeyDown("space")) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; closestItem = null; GameObject towerObject = GameObject.Find("DynamicTower"); if (towerObject != null && interactingItem != null) { TowerInteractivity tower = towerObject.GetComponent <TowerInteractivity>(); if (interactingItem.name.Contains(TowerInteractivity.MaxRow.ToString()) && interactingItem.GetComponent <Renderer>().material.color != Color.green) { return; } if (interactingItem.GetComponent <Renderer>().material.color != Color.green) { if (tower.FirstSelected == null) { tower.select(interactingItem.transform.gameObject); } else { return; } } } if (interactingItem) { if (interactingItem.isInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (InputSynchronizer.GetKeyUp("space") && interactingItem != null) { interactingItem.EndInteraction(this); } } }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not yet initialized"); return; } if (controller.GetPressDown(gripButton)) { Debug.Log("gripButtonDown detected"); float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; closestItem = null; if (interactingItem) { if (interactingItem.IsInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (controller.GetPressUp(gripButton) && interactingItem != null) { Debug.Log("gripButtonUp detected"); interactingItem.EndInteraction(this); } if (controller.GetPressDown(triggerButton)) { Debug.Log("triggerButtonDown detected"); } if (controller.GetPressUp(triggerButton)) { Debug.Log("triggerButtonUp detected"); } }
// Update is called once per frame void Update() { if (m_Controller == null) { Debug.Log("Wheres yo controller my dude"); return; } if (m_Controller.GetPressDown(m_TriggerButton)) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in m_ObjectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; m_ClosestItem = item; } } m_InteractingItem = m_ClosestItem; if (m_InteractingItem) { if (m_InteractingItem.IsInteracting()) { m_InteractingItem.EndInteraction(this); } m_InteractingItem.BeginInteraction(this); } } if (m_Controller.GetPressUp(m_TriggerButton)) { m_InteractingItem.EndInteraction(this); } if (m_Controller.GetPressDown(m_GripButton)) { } if (m_Controller.GetPressUp(m_GripButton)) { } if (m_Controller.GetPressDown(m_TouchpadButton)) { FindObjectOfType <CrateBehaviour>().m_CheckWhatPassed(); } if (m_Controller.GetPressUp(m_TouchpadButton)) { } }
private void HandleGripClicked(object sender, ClickedEventArgs e) { Debug.Log(" Grip button down."); float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; if (interactingItem) { if (interactingItem.IsInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } /* RaycastHit hit; * Ray ray = camera.ScreenPointToRay(Input.mousePosition); * if (Physics.Raycast(ray, out hit)) * { * print("Hit: " + hit.transform.gameObject.tag); * Transform objectHit = hit.transform; * if (objectHit.gameObject.tag.Equals("TriggerBall")) * { * pickup = objectHit.gameObject; * pickup.GetComponent<Renderer>().material.shader = Shader.Find("Self-Illumin/Outlined Diffuse"); * pickup.GetComponent<Rigidbody> ().useGravity = false; * pickup.GetComponent<Rigidbody> ().isKinematic = true; * } * } * if (pickup != null) * { * Debug.Log ("Pickup not null"); * * pickup.transform.parent = this.transform; * //pickup.GetComponent<Rigidbody>().useGravity = true; * } */ }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not inizialised"); return; } gripButtonDown = controller.GetPressDown(gripButton); gripButtonUp = controller.GetPressUp(gripButton); gripButtonPressed = controller.GetPress(gripButton); triggerButtonDown = controller.GetPressDown(triggerButton); triggerButtonUp = controller.GetPressUp(triggerButton); triggerButtonPressed = controller.GetPress(triggerButton); if (gripButtonDown) // wenn durch den trigger bereits collided { float minDistance = float.MaxValue; float distance; foreach (InteractableItem i in objectsHoveringOver) { distance = (i.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = i; } } interactingItem = closestItem; if (interactingItem) { if (interactingItem.IsInteraction()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (gripButtonUp && interactingItem != null) { interactingItem.EndInteraction(this); } }
// Update is called once per frame //Fixed update is based on time, better for rigidbody manipulation void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } // If the trigger button is pressed and the controller is touching/colliding with an object, the object moves with the hand. if (controller.GetPressDown(triggerButton)) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; closestItem = null; if (interactingItem) { if (interactingItem.IsInteracting()) { //Ends interaction between the object and the first remote that was interacting interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } // If you let go of the object, it no longer moves with the handset if (controller.GetPressUp(triggerButton) && interactingItem != null) { interactingItem.EndInteraction(this); } }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } else { if (controller.GetPressDown(triggerButton)) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) //Goes through all the objects and detects which is closest to the controller { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; closestItem = null; if (interactingItem) //Starts interacting with the chosen item { if (interactingItem.IsInteracting()) //this statement is used in order to grap an item in the other hand { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (controller.GetPressUp(triggerButton) && interactingItem != null) { interactingItem.EndInteraction(this); //Stops interaction with the item held interactingItem = null; } } }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } if (controller.GetPressDown(gripButton)) { // Find the closest item to the hand in case there are multiple and interact with it Debug.Log("Pressed"); float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; closestItem = null; if (interactingItem) { if (interactingItem.IsInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (controller.GetPressUp(gripButton) && interactingItem != null) { Debug.Log("Released"); interactingItem.EndInteraction(this); } }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } if (controller.GetPressDown(triggerButton)) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in ObjectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } interactingItem = closestItem; if (interactingItem) { if (interactingItem.IsInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } } if (controller.GetPressUp(gripButton) && interactingItem != null) { interactingItem.EndInteraction(this); } if (controller.GetPressDown(touchPad)) { GameObject.Find("[CameraRig]").SendMessage("Moveforward"); } }
void Test() { // is there already an interactionItem? if (m_interactionItem) { // finish interaction m_interactionItem.EndInteraction(this); m_interactionItem = null; } else { // get new interaction item UpdateNearestInteractionItem(); // any item found we can interact with? if (m_interactionItem) { // start interaction m_interactionItem.BeginInteraction(this); } } }
//Update called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } /* * if (controller.GetPressDown(gripButton) && pickup != null) * { * pickup.transform.parent = this.transform; //setting the cube's parent to be the wand. cube will follow wand. * pickup.GetComponent<Rigidbody>().isKinematic = true; * } * if (controller.GetPressUp(gripButton) && pickup != null) * { * pickup.transform.parent = null; * pickup.GetComponent<Rigidbody>().isKinematic = false; * } */ if (controller.GetPressDown(gripButton) || controller.GetPressDown(triggerButton)) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { //protecting against a problem where destroyed items still existed in this array if (item != null) { distance = (item.transform.position - transform.position).sqrMagnitude; //using sqrMagnitude bc distance can be negative. we just want magnitude if (distance < minDistance) { minDistance = distance; closestItem = item; } } } interactingItem = closestItem; if (interactingItem) //check that there is an item to interact with //check that the item isn't already being iteracted with -- if the other controller is holding it { if (interactingItem.IsInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if ((controller.GetPressUp(gripButton) || controller.GetPressUp(triggerButton)) && interactingItem != null) { interactingItem.EndInteraction(this); } //restart scene with menu if (controller.GetPressDown(menuButton)) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } } //end update
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } gripButtonDown = controller.GetPressDown(gripButtonId); gripButtonUp = controller.GetPressUp(gripButtonId); gripButtonPressed = controller.GetPress(gripButtonId); triggerButtonDown = controller.GetPressDown(triggerButtonId); triggerButtonUp = controller.GetPressUp(triggerButtonId); triggerButtonPressed = controller.GetPress(triggerButtonId); trackpadButtonDown = controller.GetPressDown(trackpadButtonId); trackpadButtonUp = controller.GetPressUp(trackpadButtonId); trackpadButtonPressed = controller.GetPress(trackpadButtonId); if (gripButtonDown) { } if (trackpadButtonUp) { GameObject.Find("Button_StartRecord").GetComponent <Button>().onClick.Invoke(); pressedRecord = true; } if (triggerButtonDown) { // Debug.Log("triggerbutton was just pressed"); if (pointer) { pointer.PulledTrigger(); } } if (triggerButtonUp) { // Debug.Log("triggerbutton was just unpressed"); } if (triggerButtonDown) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; // sqr because it could also be negative if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; closestItem = null; if (interactingItem) { if (interactingItem.isInteracting()) // this shouldn't happen that often... { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (triggerButtonUp && interactingItem != null) { interactingItem.EndInteraction(this); } }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } else { if (controller.GetPressDown(triggerButton)) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) //Goes through all the objects and detects which is closest to the controller { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } if (closestItem != null && closestItem.isMenuItem) //If the item pressed is something on the menu, then instantiate an object corresponding to the one on the menu { prefab = (GameObject)Instantiate(closestItem.worldPrefab, transform.position, Quaternion.Euler(0, 0, 0)); //Spawn it at the controllers pos and with 0 rotation (facing upwards) interactingItem = prefab.GetComponent <InteractableItem>(); //Is only used for letting an object go again in this case closestItem = null; interactingItem.BeginInteraction(this); } else if (closestItem != null && closestItem.isArrow) //If an arrow is pressed. simply tell the arrow and make it change menu page { closestItem.GetComponent <Arrows>().pressed = true; interactingItem = null; closestItem = null; } else { interactingItem = closestItem; closestItem = null; } if (interactingItem) //Starts interacting with the chosen item { if (interactingItem.IsInteracting()) //this statement is used in order to grap an item in the other hand { interactingItem.EndInteraction(this, false); } interactingItem.BeginInteraction(this); } } if (controller.GetPressUp(triggerButton) && interactingItem != null) { interactingItem.EndInteraction(this, false); //Stops interaction with the item held interactingItem = null; } } if (interactingItem != null) { if (controller.GetPressDown(menuButton) && !interactingItem.isMenuItem && !interactingItem.isArrow) { objectsHoveringOver.Clear(); closestItem = null; interactingItem.EndInteraction(this, true); interactingItem = null; } } //if the controller has the menu attached then we can disable/enable the menu with that controller by pressing the Touch Pad if (controller.GetPressDown(padButton) && changeMenu == false && controller.index == 2) { isMenuActive = !isMenuActive; changeMenu = true; Menu(isMenuActive); } }
// Update is called once per frame private void Update() { if (Controller == null) { Debug.Log("Controller not initialized"); return; } if (Controller.GetPress(_padPutton)) { foreach (var obj in _objectsHoveringOver) { Object.Destroy(obj.gameObject); } _objectsHoveringOver.Clear(); _isDeleting = true; } else { _isDeleting = false; } if (Controller.GetPressDown(_triggerButton)) { var minDist = float.MaxValue; var dist = 0.0f; _closestItem = null; foreach (var item in _objectsHoveringOver) { dist = (item.transform.position - transform.position).sqrMagnitude; if (dist < minDist) { minDist = dist; _closestItem = item; } } _interactingItem = _closestItem; if (_interactingItem != null) { if (_interactingItem.IsInteracting()) { _interactingItem.EndInteraction(this); } _interactingItem.BeginInteraction(this); } } if (Controller.GetPressUp(_triggerButton)) { if (_interactingItem != null) { _interactingItem.EndInteraction(this); _interactingItem = null; } } if (Controller.GetPressUp(_gripButton)) { _isSolid = !_isSolid; Sphere.GetComponent <Collider>().enabled = _isSolid; } Sphere.GetComponent <Renderer>().material.color = GetCurrentColor(); }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initializad"); return; } //if controller.triggerPulled, then attach if (this.triggerPulled) { //if(objectsHoveringOver.Count > 0) //Debug.Log("#Interactable items = " + objectsHoveringOver.Count); float minDistance = float.MaxValue; float distance; //Determine which object to pickup foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } interactingItem = closestItem; } if (interactingItem) { if (!interactingItem.IsInteracting()) { interactingItem.BeginInteraction(this); isAttached = true; if (isOffhand) { handOff(); } } } //Prepare for single handed grab if (interactingItem && this == interactingItem.GetInteractingController() && !offsetLocked) { calculateOffset(); offsetLocked = true; interactingItem.gameObject.GetComponent <Rigidbody>().isKinematic = true; Debug.Log("preparation finished"); } //Grab object if (interactingItem && this == interactingItem.GetInteractingController() && offsetLocked && !interactingItem.activeBimanualInteraction) { if (collidedItem.fromBiManualScaling) { calculateOffset(); collidedItem.fromBiManualScaling = false; } Matrix4x4 controllerMatrix = transform.localToWorldMatrix; Matrix4x4 newObjectMatrix = controllerMatrix * objectOffsetMatrix; collidedItem.transform.position = extractPosition(newObjectMatrix); collidedItem.transform.rotation = extractRotation(newObjectMatrix); } } //Force exit when TriggerOnExit isn't called if (delayedExit) { if (isOffhand && !isScaling && !isRotating) { collisionTriggered = false; objectsHoveringOver.Remove(collidedItem); interactingItem = null; delayedExit = false; } if (isAttached) { delayedExit = false; collisionTriggered = false; } if (!isAttached && !isOffhand) { collisionTriggered = false; objectsHoveringOver.Remove(collidedItem); interactingItem = null; delayedExit = false; } } //All requirements met for scaling & rotating to begin, set initial scaling parameters if (triggerPulled && collisionTriggered && collidedItem != null && !originalParamatersSet && collidedItem.GetInteractingController() && (collidedItem.GetInteractingController() != this)) { setOriginalParameters(); isScaling = true; isRotating = true; originalParamatersSet = true; isOffhand = true; collidedItem.activeBimanualInteraction = true; } //Begin scaling & rotation if (triggerPulled && isScaling && isRotating && collisionTriggered && (collidedItem != null) && collidedItem.GetInteractingController()) { updatePosition(); startScaling(collidedItem.GetInteractingController(), collidedItem); startRotating(collidedItem.GetInteractingController(), collidedItem); } //cleanup gameobjects used for rotating if (centerPoint && !isRotating) { Destroy(centerPoint); } }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } if (controller.GetPressDown(triggerButton)) { triggerDown = true; } if (controller.GetPressUp(triggerButton)) { triggerDown = false; } if (controller.GetPressDown(menuButton)) { AR.toggleAR(); } if (controller.GetPressDown(triggerButton)) { float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { if (item == null) { objectsHoveringOver.Remove(item); } else { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } } interactingItem = closestItem; if (interactingItem) { if (interactingItem.IsInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } } if (controller.GetPress(triggerButton) && interactingItem != null) { if (controller.GetPressDown(gripButton) && interactingItem.GetComponent <ProductController>() != null) { interactingItem.EndInteraction(this); objectsHoveringOver.Remove(interactingItem); cart.fastAddToCart(interactingItem.GetComponent <ProductController>()); interactingItem = null; } } if (controller.GetPressUp(triggerButton) && interactingItem != null) { if (ARobjGrabbed) { interactingItem.GetComponent <BoxCollider>().isTrigger = true; ARobjGrabbed = false; } interactingItem.EndInteraction(this); objectsHoveringOver.Remove(interactingItem); interactingItem = null; } if (controller.GetPressDown(gripButton)) { if (AR.getActiveStatus()) { AR.setWand(this); AR.gripButtonPressed(true); } } if (controller.GetPressUp(gripButton)) { AR.gripButtonPressed(false); } }
// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized"); return; } gripButtonDown = controller.GetPressDown(gripButton); gripButtonUp = controller.GetPressUp(gripButton); gripButtonPressed = controller.GetPress(gripButton); triggerButtonDown = controller.GetPressDown(triggerButton); triggerButtonUp = controller.GetPressUp(triggerButton); triggerButtonPressed = controller.GetPress(triggerButton); if (gripButtonDown) { Debug.Log("Grip Button was just pressed"); } if (gripButtonUp) { Debug.Log("Grip Button was just unpressed"); } if (triggerButtonDown) { Debug.Log("Trigger Button was just pressed"); float minDistance = float.MaxValue; float distance; foreach (InteractableItem item in objectsHoveringOver) { distance = (item.transform.position - transform.position).sqrMagnitude; if (distance < minDistance) { minDistance = distance; closestItem = item; } } interactingItem = closestItem; if (interactingItem) { if (interactingItem.IsInteracting()) { interactingItem.EndInteraction(this); } interactingItem.BeginInteraction(this); } //pickup.transform.parent = this.transform; //pickup.GetComponent<Rigidbody> ().useGravity = false; } if (triggerButtonUp && interactingItem != null) { Debug.Log("Trigger Button was just unpressed"); interactingItem.EndInteraction(this); //pickup.transform.parent = null; //pickup.GetComponent<Rigidbody> ().useGravity = true; } }