Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        antPosition = new Vector3(transform.position.x, 43.2f, transform.position.z); // not sure if i should add a transform.hasChanged test so it doesnt call this every frame?
        timer      += Time.deltaTime;

        if (health <= 0)
        {
            //gameObject.SetActive(false);
            WorldHandler.unitsSelected.Remove(gameObject);
            isUnitSelected = false;
            WorldHandler.DestroyFlags();
            GetComponent <Collider>().isTrigger = false;
            localPlayer.Cmd_disableUnit(gameObject);
        }

        if (isUnitSelected)
        {
            displayAntInfo();
        }

        if (antPosition != Vector3.zero)
        { // when space is pressed, move camera to the anthill
            if (Input.GetKey(KeyCode.Space) && isUnitSelected)
            {
                Camera.main.transform.position = antPosition;
            }
        }
    }