Ejemplo n.º 1
0
    public void Poop()
    {
        if (pooping)
        {
            PlayClip(poopClip, 1f);

            GameObject poop = Instantiate(poopPrefab, poopPos.position, Quaternion.identity);
            poop.GetComponent <DirectionalGravity> ().levelSelector = dirGrav.levelSelector;

            Rigidbody2D poopBody = poop.GetComponent <Rigidbody2D> ();
            Vector2     dir      = transform.rotation * Vector2.left;
            poopBody.AddForce(dir * 30f * transform.localScale.x, ForceMode2D.Impulse);
            poopBody.AddTorque(Random.Range(-20f, 20f));

            body.AddForce(-dir * 2f * transform.localScale.x, ForceMode2D.Impulse);

            levelSelector.AddPoop(poop);

            DelayedPoop();
        }
    }