Sorry, guys, I’m late to the party
@britzl is correct, as always just some notes from me:
- minimal working matchmaker message for 1x1 multiplayer would look like
matchmaker_add = {
min_count = 2,
max_count = 2,
query = "*",
}
Once you just test it’s working, add the filters to your query or extra properties.
- define your listener within
nk.sync()
wrapper: in practice, you’d want to connect the socket first and only then add the listenter
nakama.sync(function()
local ok, err = nakama.socket_connect(socket)
nakama.on_matchmakermatched(socket, function(message)
-- omitted code
end)
local matchmaker_add_message = {
-- omitted code
}
local ticket = nakama.socket_send(socket, matchmaker_add_message)
end)
- keep the ticket and cancel the matchmaking request as soon as the players join the match;
- in a match, use
op_code
field to distinguish the events you send between the players. You can map those to event types/names (if your multiplayer is event-based) or state updates (if you’re sharing the state), and refer to them in the code. Don’t neglect this field (it’s easy because docs don’t advertise this much), it’s a simple but powerful way to keep your messages short while sharing event information between the clients; - once you feel like your matchmaking logic needs some adjustments and you might need an authoritative server, don’t hesitate much, it’s quite easy to write as well and it’s in Lua, too.
Also, just had a look at Defold client guide, it looks exactly the way I needed it when I just started, so you’ll be riding Nakama in no time!
Good luck and share your impressions!