Ejemplo n.º 1
0
    public IEnumerator LaunchBall()
    {
        if (endDragPosition.x < -1)
        {
            FindObjectOfType <AudioManager>().Play("luandaSpeak");
            FindObjectOfType <AudioManager>().Play("throwRock");

            GameObject pooledPickup = ObstaclePooler.Instance.GetPooledObject2();
            pooledPickup.transform.position = spawnpoint.position;
            pooledPickup.transform.rotation = spawnpoint.rotation;
            pooledPickup.SetActive(true);

            //pooledPickup = Instantiate(kunai, spawnpoint.position, spawnpoint.rotation) as GameObject;
            Rigidbody2D rigidbody2D = pooledPickup.GetComponent <Rigidbody2D>();

            rigidbody2D.AddForce(-endDragPosition * speed, ForceMode2D.Impulse);

            Vector3 camerTarget = pooledPickup.transform.position;
            if (!manager.CheckIfWithinScreenLimits(camerTarget))
            {
                Vector3 offsetFromCamPosition = Vector3.zero;
                offsetFromCamPosition = camerTarget - Camera.main.transform.position;
                pooledPickup.SetActive(false);
            }

            yield return(new WaitForSeconds(1f));
        }


        endDragPosition = new Vector3(0f, 0f, 0);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    private void Update()
    {
        Vector3 camerTarget = transform.position;

        if (!manager.CheckIfWithinScreenLimits(camerTarget))
        {
            Vector3 offsetFromCamPosition = Vector3.zero;
            offsetFromCamPosition = camerTarget - Camera.main.transform.position;
            Destroy();
        }
        if (transform.position.y < 1.5)
        {
            rb2D.drag = 0.5f;
        }

        else if (transform.position.y > 1.5)
        {
            rb2D.drag = 1f;
        }
        if (transform.position.y > 3.2)
        {
            rb2D.drag = 1.5f;
        }
    }