#i am trying to make a tic tac toe game

1 messages · Page 1 of 1 (latest)

distant grove
#

I would just have an Active Turn network variable to control that

dry sapphire
#

yeah i do have two network variables

#

current turn and hostSide

#

current turn stores whose turn it currently is

#

and hostSide stores the side that host initiaally picked

#

i know its messy but i could make it work like this only

dry sapphire
distant grove
#

You can use either RPC or network variable for that but you would not need to use both, just have ge host set the network vsribale and it will automatically sync to the client

dry sapphire
#

i am currently calling this from the cleint side

[ServerRpc (RequireOwnership = false)]
    private void UpdateButtonsServerRpc(int grid)
    {
        //cells[grid] = 1;
        buttonList[grid].transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = currentTurn.Value.ToString();
        integerList[grid] = 1;
 
        for (int i = 0; i < integerList.Count; i++)
        {
            if (integerList[i] == 0)
            {
                buttonList[i].interactable = true;
            }
            else
            {
                buttonList[i].interactable = false;
            }
        }
 
 
        if (playerX.panel.color == activePlayerColor.panelColor)
        {
            SetPlayerColor(playerO, playerX);
        }
        else if (playerO.panel.color == activePlayerColor.panelColor)
        {
            SetPlayerColor(playerX, playerO);
        }
 
        buttonList[grid].interactable = false;
        UpdateButtonsClientRpc(grid);
    }
dry sapphire
distant grove
# dry sapphire i was able to get the turns right it is almost complete but how can i make the...

If the main menu is a scene with the network manager already in it, then when you go back to it, you will have duplicate network managers. So you will either need to destroy the one already there or just remove the network manager from the main menu scene. Most folks will have a bootstrap scene that sets up all the managers before the main menu scene. That way you can go back to the menu with no issues

dry sapphire
distant grove
#

That should be fine too

dry sapphire
#

which time zone are you in btw?

i dont think our time zones coincide
thats why our replies are far apart
and then school take almost half a day too

distant grove
#

-6 UTC. Central time in the US

dry sapphire
#

Oh that explains UTC+5:30 Central time in India

dry sapphire
# distant grove If the main menu is a scene with the network manager already in it, then when yo...

yeah that worked

now one last step is left before its completion
i am trying out relay services for the first time

the code i am using is like this :

public async void StartHost()
    {
        try
        {
            Allocation allocation = await RelayService.Instance.CreateAllocationAsync(1);
            joinCode = await RelayService.Instance.GetJoinCodeAsync(allocation.AllocationId);

            RelayServerData relayServerData = new RelayServerData(allocation, "dtls");
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);
            NetworkManager.Singleton.StartHost();
            ActivatePlaceholderPanel(true);//This is a game object which just displays the current join code
        }catch (RelayServiceException e)
        {
            Debug.Log(e.ToString());
        }
    }

public async void JoinGame()
    {
        try
        {
            JoinAllocation joinAllocation = await RelayService.Instance.JoinAllocationAsync(codeArea.transform.GetChild(0).GetChild(2).GetComponent<TextMeshProUGUI>().text);
            
            RelayServerData relayServerData = new RelayServerData(joinAllocation, "dtls");
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);
            NetworkManager.Singleton.StartClient();
        } catch (RelayServiceException e)
        {
            Debug.Log(e.ToString());
        }
    }

and for disconnecting i am doing the following:

    public void Disconnect()
    {
        if(NetworkManager.Singleton.IsConnectedClient)
            NetworkManager.Singleton.Shutdown();
        Destroy(NetworkManager);
    }
#

i just want to know wether i have to do soemthing else too

#

like when i am acclocating apce on relay do i need to erase it too when the game is done

#

and in disconnect fucntion do i need to turn off relay or signout clients

#

i did what i could from what i had learnt

distant grove
#

No, shutdown() is all you need to do there

dry sapphire
#

ok then ill remove the Destroying function

dry sapphire
#

its giving me this error :
Bad Request : invalid requiest schema or decoding failure

distant grove
dry sapphire
#

yeah i entered the code

#

i have a text box which shows up

#

and it can read the code from their

#

at first i thought it wasnt able to get the code from the input field

#

but i tried to debug it and its value updated

#

i read a few threads

#

i think it might be either due to the wifi

#

it shows that tmpro adds an empty space at the end when value is taken from it

#

i have tried to cut it down

#

its currently building

dry sapphire
#

the problem was the empty space only

dry sapphire
dry sapphire
#

have you ever heard of ultimate tic tac toe?

dry sapphire
distant grove
#

No that will cause errors. It would be easier to just flatten the double list

dry sapphire
# distant grove No that will cause errors. It would be easier to just flatten the double list

i want the canvas to have a render mode of ScreenSpace - Overlay
but that requires a camera componenet
as it is a netowrk prefab i am not able to enter the camera componenet which i am using for other canvases as the camera is a component in the heiarchy
i tried making it a prefab, i was able to enter is as a component but it still isnt displying anythign when i join it to the game

distant grove
#

The canvas should not be a network object. that will cause some weird scaling issues. But in any case you will need a script to assign the camera

dry sapphire
dry sapphire
distant grove
#

I will usually just keep them as regular objects in the scene. Then in the objects that need them, in their OnNetworkSpawn() use GameObject.Find() to grab what they need

dry sapphire