private IEnumerator ExecuteFlickRangedGrab() { var executionTime = 0f; var originPosition = activeRangedGrabTarget.transform.parent.position; var originRotation = activeRangedGrabTarget.transform.parent.rotation; var distance = (activeRangedGrabTarget.transform.position - transform.position).magnitude; var midPoint = transform.position + transform.forward * distance * 1.25f; if (activeRangedGrabTarget.transform.parent.GetComponent <Rigidbody>()) { activeRangedGrabTarget.transform.parent.GetComponent <Rigidbody>().isKinematic = true; activeRangedGrabTarget.transform.parent.GetComponent <Rigidbody>().useGravity = false; } executingRangedGrab = true; while (executionTime < rangedGrabDuration) { if (activeRangedGrabTarget == null) { break; } executionTime += Time.deltaTime; var percentT = executionTime / rangedGrabDuration; activeRangedGrabTarget.transform.parent.position = CalculateCurvedPoint(originPosition, midPoint, grabManager.transform.position, percentT); activeRangedGrabTarget.transform.parent.rotation = Quaternion.Slerp(originRotation, grabManager.transform.rotation, percentT * percentT); yield return(new WaitForEndOfFrame()); } if (activeRangedGrabTarget != null) { if (activeRangedGrabTarget.transform.parent.GetComponent <Rigidbody>()) { activeRangedGrabTarget.transform.parent.GetComponent <Rigidbody>().isKinematic = false; activeRangedGrabTarget.transform.parent.GetComponent <Rigidbody>().useGravity = true; } grabManager.PerformGrab(activeRangedGrabTarget.Grabbable); activeRangedGrabTarget = null; } executingRangedGrab = false; }