void Update()
    {
        if (playerObj == null)
        {
            playerObj = GameObject.FindGameObjectWithTag("Player");
        }
        else
        {
            //Debug.Log("HERE1 " + playerObj.transform.position + ", " + transform.position + ", " + portalDist + ", Triggered/Fading: " + triggered + ", " + xa.fadingOut);
            if (Vector3.Distance(playerObj.transform.position, transform.position) < portalDist)
            {
                if (!triggered)
                {
                    triggered           = true;
                    xa.allowPlayerInput = false;
                    xa.hasCheckpointed  = false;
                    Time.timeScale      = 1;
                    FreshLevels.Type levelType = FreshLevels.GetTypeOfCurrentLevel();


                    if (!isSecretExit)
                    {
                        Fresh_Saving.SaveLevelDeaths(levelType, za.deaths);
                        Fresh_Saving.SaveLevelTime(levelType, fa.speedrunTime);

                        FrFuncs.Qc_ReportLevelTime(levelType, fa.speedrunTime, "noGhostData");
                        SteamLeaderboards.SendPBToSteam(levelType, fa.speedrunTime);
                    }



                    //Update unlocked levels (lvlNum)
                    NodeController.WonLevel(levelType);

                    xa.re.cleanLoadLevel(Restart.RestartFrom.RESTART_FROM_MENU, FreshLevels.GetStrNameForType(gotoLvl));
                }
            }
        }
    }
    void Update()
    {
        bool changed = false;

        if (!oncePerGameStart)
        {
            Debug.Log("ONCE");
            oncePerGameStart = true;
            changed          = true;

            for (int i = 0; i < nodes.Length; i++)
            {
                if (nodes[i].levelType == FreshLevels.Type.IntroStory)
                {
                    currentNode = nodes[i];
                    break;
                }
            }
            currentLevelName.text = currentNode.levelName;
            LoadLevelStats();
        }

        if (!checkedForSavedMapPos)
        {
            checkedForSavedMapPos = true;
            if (fa.lastLevelPlayed != FreshLevels.Type.None)
            {
                for (int i = 0; i < nodes.Length; i++)
                {
                    if (nodes[i].levelType == fa.lastLevelPlayed)
                    {
                        currentNode = nodes[i];
                        changed     = true;
                    }
                }
            }
        }

        if (Controls.GetInputDown(Controls.Type.MenuUp, 0))
        {
            if (currentNode.north != null)
            {
                currentNode        = currentNode.north;         //
                fa.lastLevelPlayed = currentNode.levelType;
                changed            = true;
            }
        }
        if (Controls.GetInputDown(Controls.Type.MenuDown, 0))
        {
            if (currentNode.south != null)
            {
                currentNode        = currentNode.south;
                fa.lastLevelPlayed = currentNode.levelType;
                changed            = true;
            }
        }
        if (Controls.GetInputDown(Controls.Type.MenuLeft, 0))
        {
            if (currentNode.west != null)
            {
                currentNode        = currentNode.west;
                fa.lastLevelPlayed = currentNode.levelType;
                changed            = true;
            }
        }
        if (Controls.GetInputDown(Controls.Type.MenuRight, 0))
        {
            if (currentNode.east != null)
            {
                currentNode        = currentNode.east;
                fa.lastLevelPlayed = currentNode.levelType;
                changed            = true;
            }
        }

        if (Controls.GetInputDown(Controls.Type.MenuSelect, 0))
        {
            if (currentNode.locked)
            {
                Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Fart);
                iTween.PunchRotation(currentNode.gameObject, iTween.Hash("z", 17.5f, "time", 0.3f));
            }
            else
            {
                string lvlName = FreshLevels.GetStrNameForType(currentNode.levelType);
                //Debug.Log("Tried to go to level: " + lvlName);
                if (lvlName != "")
                {
                    xa.re.cleanLoadLevel(Restart.RestartFrom.RESTART_FROM_MENU, lvlName);
                }
            }
        }

        if (changed)
        {
            for (int i = 0; i < allSkies.Length; i++)
            {
                allSkies[i].SetActive(false);
            }

            iTween.MoveTo(nodeCamera, iTween.Hash("x", currentNode.transform.position.x, "y", currentNode.transform.position.y, "easetype", iTween.EaseType.easeInOutSine, "time", 0.2f));

            if (currentNode.setCamPos)
            {
                //iTween.MoveTo(camera, iTween.Hash("x", currentNode.camPos.x, "y", currentNode.camPos.y, "easetype", iTween.EaseType.easeInOutSine, "time", 0.5f));
                //camera.transform.SetX(currentNode.camPos.x);
                //camera.transform.SetY(currentNode.camPos.y);
            }

            iTween.RotateTo(nodeCamera, iTween.Hash("z", currentNode.cameraAngle2, "easetype", iTween.EaseType.easeInOutSine, "time", 0.2f));


            for (int i = 0; i < currentNode.objsOn.Length; i++)
            {
                currentNode.objsOn[i].SetActive(true);
            }


            currentLevelName.text = currentNode.levelName;

            LoadLevelStats();
        }

        cursor.transform.SetX(currentNode.gameObject.transform.position.x);
        cursor.transform.SetY(currentNode.gameObject.transform.position.y);
    }