示例#1
0
    // Throws the given item (assumes it is instanciated)
    IEnumerator ThrowItem(GameObject throwable)
    {
        SetItemCooldown(stats.THROW_COOLDOWN);
        throwable.transform.parent        = throwingHand;
        throwable.transform.localPosition = Vector3.zero;
        throwable.transform.position      = throwingHand.position;
        throwable.GetComponent <Rigidbody>().isKinematic = true;
        throwable.GetComponent <Collider>().enabled      = false;
        playerAnimator.Throw();
        yield return(new WaitForSeconds(0.5f));

        throwable.GetComponent <Rigidbody>().isKinematic = false;
        throwable.transform.SetParent(null);
        throwable.GetComponent <Rigidbody>().AddForce(transform.forward * 700);
        yield return(new WaitForSeconds(0.2f));

        throwable.GetComponent <Collider>().enabled = true;
        throwable.AddComponent <ThrowableItem> ();
    }