Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        myView = Camera.main.WorldToViewportPoint(this.transform.position);


        if (dir == true)
        {
            //transform.Translate(-Vector2.right * movementSpeed * Time.deltaTime);
            //transform.position = new Vector3(2 * Time.deltaTime, this.transform.position.y, this.transform.position.z);
            rb.AddForce(Vector3.left * movementSpeed);

            if (myView.x < 0)
            {
                //seen = false;
                //dir = false;
                mySpawn.setUsed(false);
                mySpawn.getCorSpawn().setUsed(false);
                treadScript.turnOffEnemy(this.gameObject);
                rb.velocity = Vector3.zero;
                //seen = true;
            }
        }
        else
        {
            //transform.Translate(Vector2.right * movementSpeed * Time.deltaTime);
            //transform.position = new Vector3(2 * Time.deltaTime, this.transform.position.y, this.transform.position.z);
            rb.AddForce(Vector3.right * movementSpeed);

            if (myView.x > 1)
            {
                //seen = true;

                //seen = false;
                //dir = false;
                mySpawn.setUsed(false);
                mySpawn.getCorSpawn().setUsed(false);
                treadScript.turnOffEnemy(this.gameObject);
                rb.velocity = Vector3.zero;
            }
        }

        //if (levelRenderer.isVisible)
        //{
        //    seen = true;
        //}

        //if (seen && !levelRenderer.isVisible)
        //{
        //    seen = false;
        //    dir = false;
        //    mySpawn.setUsed(false);
        //    mySpawn.getCorSpawn().setUsed(false);
        //    treadScript.turnOffEnemy(this.gameObject);

        //}
    }