// Update is called once per frame
    void Update()
    {
        redo = new Redo(lastObjPos, lastObjBuilt);
        undo = new Undo(unwanted);

        if (buildEnable == true)
        {
            if (Input.GetKeyDown(KeyCode.P))
            {
                builder = factory.Type(1);
                builder.Build(gameObject.transform.position, new Vector3(0.7f, 0.7f, 0.7f));
                lastObjPos   = gameObject.transform.position;
                lastObjBuilt = builder;
                unwanted     = builder;
            }

            if (Input.GetKeyDown(KeyCode.O))
            {
                builder = factory.Type(2);
                builder.Build(gameObject.transform.position, new Vector3(0.7f, 0.7f, 0.7f));
                lastObjPos   = gameObject.transform.position;
                lastObjBuilt = builder;
                unwanted     = builder;
            }

            if (Input.GetKeyDown(KeyCode.L))
            {
                builder = factory.Type(3);
                builder.Build(gameObject.transform.position, new Vector3(0.7f, 0.7f, 0.7f));
                lastObjPos   = gameObject.transform.position;
                lastObjBuilt = builder;
                unwanted     = builder;
            }

            if (Input.GetKeyDown(KeyCode.K))
            {
                builder = factory.Type(5);
                builder.Build(gameObject.transform.position, new Vector3(0.7f, 0.7f, 0.7f));
                lastObjPos   = gameObject.transform.position;
                lastObjBuilt = builder;
                unwanted     = builder;
            }

            if (Input.GetKeyDown(KeyCode.J))
            {
                builder = factory.Type(4);
                builder.Build(gameObject.transform.position, new Vector3(0.7f, 0.7f, 0.7f));
                lastObjPos   = gameObject.transform.position;
                lastObjBuilt = builder;
                unwanted     = builder;
            }

            if (Input.GetKeyDown(KeyCode.U))
            {
                builder = factory.Type(6);
                builder.Build(gameObject.transform.position, new Vector3(0.7f, 0.7f, 0.7f));
                lastObjPos   = gameObject.transform.position;
                lastObjBuilt = builder;
                unwanted     = builder;
            }

            if (Input.GetKeyDown(KeyCode.I))
            {
                builder = factory.Type(7);
                builder.Build(gameObject.transform.position, new Vector3(0.7f, 0.7f, 0.7f));
                lastObjPos   = gameObject.transform.position;
                lastObjBuilt = builder;
                unwanted     = builder;
            }

            if (Input.GetKeyDown(KeyCode.N))
            {
                button = new RedoUndoButton(redo);
                button.press();
            }

            if (Input.GetKeyDown(KeyCode.M))
            {
                button = new RedoUndoButton(undo);
                button.press();
            }
        }

        if (Input.GetKeyDown(KeyCode.Backspace))
        {
            gameObject.AddComponent <BoxCollider>();
            gameObject.AddComponent <Rigidbody>();
            buildEnable = false;
        }
    }