// Use this for initialization

    // Update is called once per frame
    void Update()
    {
        int direction = 0;

        //Get the direction based on what button they're pressing
        direction += Input.GetKeyDown(KeyCode.LeftArrow) ? -1 : 0;
        direction += Input.GetKeyDown(KeyCode.RightArrow) ? 1 : 0;

        timeCounter -= Time.deltaTime;
        if (!is_instantiated && timeCounter <= 0 && isLocalPlayer)
        {
            int rand = Random.Range(0, 6);
            selectedObject = block_list[rand];

            //Choose block to spawn and re-enable highlight
            toDrop = Instantiate(selectedObject, this.gameObject.transform.position, Quaternion.identity, this.gameObject.transform);
            //disables box colliders in indicator
            foreach (BoxCollider child in toDrop.GetComponentsInChildren <BoxCollider>())
            {
                child.enabled = false;
            }
            //Cmdtry_block_spawn();
            areaHighlight.AdjustHighlightScaleAndOffsetFor(toDrop);
            SetHighlightActive(true);

            resetCurrentRotation();
            is_instantiated = true;
        }
        if (toDrop)
        {
            RotateObject(direction);
            toDrop.transform.position = this.gameObject.transform.position;
            areaHighlight.MoveHighlightTo(toDrop);

            if (Input.GetKeyDown(KeyCode.Space) || timeCounter <= -3f)  //change value here to determine the amount of time it takes to auto drop block subtracting from 1.5f so at -3f it auto spawns in 4.5 seconds etc.
            {
                if (isLocalPlayer)
                {
                    // Let the block drop and disable the highlight
                    Destroy(toDrop);
                    Cmdtry_block_spawn();

                    is_instantiated = false;

                    SetHighlightActive(false);
                    timeCounter = timeTilNextBlock;
                    toDrop      = null;
                    //next_selected_object();
                }
            }
        }
    }
    //================================================================================
    // Indicator functions
    //================================================================================


    //moves the indicator object to the spot on the grid in front of the camera.
    void PositionIndicator(Vector3 cameraPosition)
    {
        if (indicator == null)
        {
            return;
        }
        Vector3 newPosition = new Vector3((int)cameraPosition.x, (int)cameraPosition.y, GameConstants.playPlaneZ);

        indicator.transform.position = newPosition;

        //Adjust highlight position after indicator moves
        areaHighlight.MoveHighlightTo(indicator);
    }