Questions about splitscreen logic

Announcements, support questions, and discussion for Quest Machine.
splinedrew
Posts: 13
Joined: Tue Mar 15, 2022 8:53 pm

Re: Questions about splitscreen logic

Post by splinedrew »

Thanks so much for the help! I like using the message system for this too. I decided to use it on the RefreshUI function, but I am running into one more snag. Here is my code:

Code: Select all

    
    void RefreshPOIs()
    {
        Debug.Log("Refresh is called!");
        for (int i = 0; i < PlayerJournals.Length; i++)
        {
            foreach (var quest in PlayerJournals[i].questList)
            {
                foreach (var node in quest.nodeList)
                {
                    POIItem poi = POI_Manager.AllPOIs.GetPOIItem(StringField.GetStringValue(node.id));
                    if (poi)
                    {
                        Debug.Log("P" + (i + 1) + " show in hud = " + quest.showInTrackHUD);
                        Debug.Log("Found a poi!" + StringField.GetStringValue(node.id));
                        if (!quest.showInTrackHUD)
                        {
                            poi.SetIsVisibleToPlayer(i, false);
                        }
                        else
                        {
                            if (node.GetState() == QuestNodeState.Active)
                            {
                                poi.SetIsVisibleToPlayer(i, true);
                            }
                            else
                            {
                                poi.SetIsVisibleToPlayer(i, false);
                            }
                        }
                    }
                }
            }
        }

    }
    
Now the issue is if I toggle the quest off in the Quest Journal UI it is turning off the POI for both players. Any ideas on how to get the showInTrackHUD value that's specific to the second player?
User avatar
Tony Li
Posts: 20731
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions about splitscreen logic

Post by Tony Li »

Is it possible that when you toggle tracking off it actually toggles off both players' instances of the quest?
splinedrew
Posts: 13
Joined: Tue Mar 15, 2022 8:53 pm

Re: Questions about splitscreen logic

Post by splinedrew »

Found the culprit in my code! I was caching my journals in an Awake method. It grabbed P1 journals only but when I cached them in a start method all was well. Thank you so much for all the help!
User avatar
Tony Li
Posts: 20731
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions about splitscreen logic

Post by Tony Li »

Glad you found the issue!
Post Reply