private void OnTriggerStay(Collider other) { StolableUI item = other.GetComponent <StolableUI>(); if (item != null) { PickObject(item); } }
void PickObject(StolableUI item) { if (!isPlayingPickupAnimation) { if (Input.GetKeyDown(InteractKeyCode)) { isPlayingPickupAnimation = true; //get the rotation to the object Vector3 temp = (lookItem.transform.position - transform.position).normalized; temp.y = 0; Quaternion newRotation = Quaternion.LookRotation(temp, Vector3.up); //apply it transform.DORotateQuaternion(newRotation, 2.0f); StartCoroutine(PickUpObjectSequence(item)); } } }
private IEnumerator PickUpObjectSequence(StolableUI item) { playerAnimator.SetTrigger("Pick"); controller.enabled = false; canDetectInput = false; item.OnInteractKeyPressed(InteractKeyCode); while (Input.GetKey(InteractKeyCode)) { isPlayingPickupAnimation = false; controller.enabled = true; canDetectInput = true; yield return(null); } playerAnimator.SetTrigger("InterruptPick"); isPlayingPickupAnimation = false; controller.enabled = true; canDetectInput = true; }