How can I maintain multiplayer game state in Unity?

i’m developing turn based multiplayer board game. i want to maintain game state in server when player left room and rejoin room player will get game state from server.

@srirampandiyan115

You can use Authoritative Multiplayer to maintain the game state
https://heroiclabs.com/docs/gameplay-multiplayer-server-multiplayer/#authoritative-multiplayer
when the player join the game dispatch the state of the game to him

function M.match_join(context, dispatcher, tick, state, presences)
// dispatcher the state to the player joined the match here 
  return state
end
1 Like

actually i saw this but i’m very beginner to nakama i don’t understand this where i have to write this script and how i call this script from unity3d

@srirampandiyan115

What language did you decide to use Lua , Typescript or Golang?

i’m completely blank on server side scripting. which is easy you suggest me i’ll learn

@srirampandiyan115
I will try to make my explanation easy and not very technical

Lua and Javascript
(+) It will guard against poor programming that could cause "index out of range" and other kinds of error that cause a panic in your code.
(-) Relatively slower than go (this doesn’t mean it is SLOW)
(-) some features are not available (will be added soon, like process events but you still can use go for that part)

Go
(-) if you don’t make hight quality code you can crash your server (you need testing skills)
(+) performance better than LUA & Javascript
(+) more features as the server built in Go

Side notes: you can not call go function from lua or Javascript and vice versa, check below for more about this

for more about the difference between LUA & GO

To learn Nakama I suggest to read the full documentation (it may take you a day or less but you will benefit more and you will understand the things discussed in the forum)

1 Like