public override void UpdateInputAxis(float axis) { if (axis < axisOpeningThreshold) //hand is opened { isOpen = true; if (itemHeld != null) { itemHeld.ReleaseItem(); SendMessage("SetDefaultTarget", grabPoint.transform, SendMessageOptions.DontRequireReceiver); itemHeld = null; } grabPoint.SetActive(false); } else if (axis > axisClosingThreshold) //hand is closed { isOpen = false; if (itemHeld == null && currentCollectableInRange != null) { grabPoint.SetActive(true); itemHeld = currentCollectableInRange; itemHeld.rigidbody.isKinematic = true; //HACK: Keeps the held object from flying away (should drop straight down) itemHeld.transform.position = grabPoint.transform.position + transform.forward * (itemHeld.transform.localScale.x - 1); itemHeld.GrabItem(grabPoint.rigidbody); itemHeld.rigidbody.isKinematic = false; } } }
public void SetHandClosed(float axis) { if (axis < axisOpeningThreshold) //open hand { isOpen = true; if (itemHeld != null) { itemHeld.ReleaseItem(); } grabPoint.SetActive(false); } else if (axis > axisClosingThreshold) { isOpen = false; if (currentCollectableInRange != null) { grabPoint.SetActive(true); itemHeld = currentCollectableInRange; itemHeld.rigidbody.isKinematic = true; itemHeld.transform.position = grabPoint.transform.position; itemHeld.GrabItem(grabPoint.rigidbody); itemHeld.rigidbody.isKinematic = false; } } }