Ejemplo n.º 1
0
    public void ThrowCurrentItem(InputAction.CallbackContext context)
    {
        if (context.started && canInteract && currentHoldingItem != null)
        {
            Grabbable lastItem = currentHoldingItem;
            currentHoldingItem.Disattach();
            Vector3 throwDirection = transform.forward;
            throwDirection   = throwDirection.normalized * throwVelocity;
            throwDirection.y = throwHeight;

            Vector3 rotationDirection = new Vector3(-transform.forward.z, 0, -transform.forward.x);
            Debug.Log(rotationDirection.normalized);
            lastItem.rigid.AddRelativeTorque(new Vector3(Random.Range(minForwardRotationVelocity, maxForwardRotationVelocity), 0, Random.Range(minSidewaysRotationVelocity, maxSidewaysRotationVelocity)));
            lastItem.rigid.AddForce(throwDirection);
        }
    }