am creating an word multiplayer game in that am generating random 10 letters here for host am getting 10 letters but in client am getting different 10 letters but i need both client and host must have same 10 letters for this what i want to do??
You can generate your 10 random letters on the server and send them to the client, or you can make generating your 10 random letters deterministic based on a seed, and send the seed to the client where the client runs it through the same function the server did so should produce the same 10 random letters.
Sounds like you are calling server commands where you shouldn’t be. The easiest way to figure out where is to find all of the places where you think you have to be the server and add
Debug.Assert(isServer);
If it works at all, that would suggest that you may not be creating your generator in a networked way. Are the networkId of the generator object the same on your host and client? If they aren’t you created your object wrong, which is a very common bug and an easy one to make. I created about a dozen network objects this past week, and I did that more times that I’ll admit to here.
can u give some example codes
It’s not really something you’d see in code other than where you call Network.Spawn. It’s in how your scene is set up. You should not have your networked objects in the scene before your connection is set up. Make them prefabs, then remove them from your scene. Click on your network manager and you should see a list of “Spawnable” prefabs. Drag your prefab in there, then whenever your networked scene starts, spawn your objects.
i did the same but here my problem is am generating letters i made them prefab and it spawned correctly but the thing is for example the letters ‘A’ ‘B’ ‘C’ ‘D’ ‘E’ ‘F’ is generated in editor at the same time i took build and run the same thing it prints different set of letters but i need same set of letters for both editor in build for this what can i do??
If you’ve successfully spawned them, then you need to communicate between the server and client. The easiest way to do this would be use a SyncVar
[SyncVar]
string m_txt;
public void setLetterValue(string p_txt){
Debug.Assert(isServer); //This function should only be called from the server
m_txt = p_txt;
}