public void DropDragObject() { if (DraggableObject != null) { DraggableObject.Drop(); } DraggableObject = null; }
void Update() { if (GameController.Instance.GameState != GameStates.Game) { return; } // Search for interactive objects InteractiveObject = null; DragObject dragObject = null; IsHoverDragObject = false; RaycastHit hit; if (Physics.Raycast(mainCamera.transform.position, mainCamera.transform.TransformDirection(Vector3.forward), out hit, 2.0f)) { InteractiveObject = hit.collider.gameObject.GetComponent(typeof(IUse)) as IUse; if (InteractiveObject != null && InteractiveObject.IsActive == false) { InteractiveObject = null; } dragObject = hit.collider.GetComponent <DragObject>(); if (dragObject != null && dragObject.Rigidbody.isKinematic) { dragObject = null; } IsHoverDragObject = dragObject != null; } if ((InteractiveObject != null) && (InputController.Use)) { InteractiveObject.Use(); } if (InteractiveObject == null && dragObject != null && DraggableObject == null && InputController.Drag) { dragObject.Drag(dragPoint); DraggableObject = dragObject; } if (DraggableObject != null && InputController.Dragging == false) { DraggableObject.Drop(); DraggableObject = null; } if (DraggableObject != null && InputController.Throw) { DraggableObject.Throw(throwForce); DraggableObject = null; } }