Esempio n. 1
0
    void FixedUpdate()
    {
        if (tossed)
        {
            Debug.Log(transform.parent);
            tossing          = true;
            tossed           = false;
            transform.parent = null;
            distancePoints(restPoint.transform.position);

            switch (status.getLocalScale())
            {
            case 1:
                rb.velocity = new Vector2(tossVelocity, rb.velocity.y);
                Debug.Log("Local scale is 1");
                break;

            case -1:
                rb.velocity = new Vector2(-tossVelocity, rb.velocity.y);
                Debug.Log("Local scale is -1");
                break;

            default:
                break;
            }

            //rb.velocity = new Vector2(tossVelocity, rb.velocity.y);
            canToss = false;
        }

        if (tossing)
        {
            currentTossDistance = Vector2.Distance(restSpot, transform.position);
        }


        if (currentTossDistance > tossDistance && tossing)
        {
            //tossed = false;
            stationary  = true;
            tossing     = false;
            rb.velocity = new Vector2(0, rb.velocity.y);
            GetComponent <BoxCollider2D>().enabled = true;
        }
    }