Example #1
0
    public void Throw()
    {
        if (carryObjectController != null)
        {
            if (carryObjectController.transform.parent != null)
            {
                carryObjectController.setThisParent(null);
            }
        }


        carryObjectController.beingCarried = false;
        carryObject.GetComponent <BoxCollider2D>().enabled = true;
        carryObjectRB.isKinematic = false;
        Invoke("setCarrying", .1f);


        Vector2 throwDirection = (throwPosition.position - transform.position).normalized;

        carryObjectController.cantMove = true;
        carryObjectController.Invoke("CannotMove", throwTime);
        carryObjectRB.AddForce(throwDirection * throwForce, ForceMode2D.Impulse);

        carryObjectController.beenThrown = true;
        //canCarry = false;
        carryObject           = null;
        carryObjectRB         = null;
        carryObjectController = null;
    }