A question before I get started with Nakama (Making a realtime game)

Hello.

Previously, I’ve made some multiplayer games with Unreal and Godot, but maaan, after suffering all the client-server replication thingies and finishing my multiplayer games, then I had to manually make matchmaking stuff, user registration, etc.

Then, I found Nakama: Yay, realtime multiplayer, database storage, user login, google play purchase handling and all of that for free (except servers, you know). So, I got interested on making an Unity game with it.

I went a bit deep into the documentation and, if I understood correctly, there are no RPC events and data is shared with JSON files via webpackets with no udp or something.

Well, then, there’s the question. I want to make an online third person game, like Fall Guys, but simplified. So, I thought on making something like this:

Every player shares to the server their data every 0.1 seconds - So, they’re sharing their location, Z rotation (I only need the yaw rotation, not roll nor pitch) and finally, the player state = 0 is idle/walking , 1 is jumping, 2 is double jumping, 3 is dead… etc) Things like Idle/walking calculation are done on client side after gathering the data by comparing the current location with the last one.

Example:
“x”: 345.34,
“y”: 502.20,
“z”: 302.01,
“rz”: 359,
“s”: 0

That data gets sent to the server, and shared across the clients on a specificmatch.

And that’s it!
I don’t want a server authoritative game, having stuff calculated on the server side seems expensive and probably not worth the effort - hack the game as much as you want if you’re happy winning that way, just eat my ads and I’ll be fine.

So, can I do that? Or are there better ways? Should I even use Nakama?
Also, if sharing that kind of JSON data is the way is the way to go, does it get optimized? I mean,

this:

“x”: 345.34,
“y”: 502.20,
“z”: 302.01,
“rz”: 359,
“s”: 0

seems like a waste of data when we compare it to this:

[345.34,502.20,302.01,359,0]

1 Like

Hey @uwu your approach is mostly sound to me. Your use case is exactly what Nakama was built for. I wouldn’t worry about prematurely optimizing your payloads for data usage – use a structure that makes logical sense to you and any other programmers.

Keep in mind that it may make more sense to send player inputs as payloads (e.g., move up, move left) rather than positional data since those can be validated and then applied on the host client.

1 Like

Thank you a lot for your reply.

I’ve tried out nakama and got the basic “connect to the server with your device ID” and matchmaking things done.

But unfortunately, I’m stuck there. I don’t know how to spawn a character and then broadcast that spawn along all the clients on a match.
I’ve checked out the Pirate game and it’s a great resource for understanding RPCs, how and where the data is stored in the server and how the social system works, but it’s pretty much authoritative and I didn’t understand how most of the code works.

In a nutshell, I’m blindfolded. Are there docs or tutorials I’m missing out? I’ve checked out all of the 6 YouTube tutorials, the Unity client guide and the pirate game, but I’m not yet ready to make something that isn’t just a simple connection to my server.

Nevermind, a lot of Unity tutorials have just spawned in the Heroic Labs channel, teaching exactly what I needed. Thanks!!!

5 Likes

hey can you please help me with this, I really have no idea how to spawn players properly, I followed the fish game tutorial and it spawns in a very complex way by creating two different object for local and remote player, if you guid me to do this better I will be very much thankful.

Hi @sana2024 your question is a bit too open-ended for me to answer further. In general, you want to receive IPresence objects off the socket and spawn a game object for each IPresence. If you have more specific questions I can help further.

sorry for the confusing comment, I want to spawn an object for each player in the session and assign that object to that player session id and lastly synch that objects movement through the network so the other players can see that movement and know who sent it.
what is the best way to synch objects through the network?? I tried to do that but seems like nakama mostly allows small messages to be synched like a text or something when I pass a large object it gives me error about " can only be called through the unity main thread, I even added main thread dispatcher to my project but I need more explanation on how does it works.

Hey @sana2024 you should pass useMainThread: true to the socket when creating it instead of using the main thread dispatcher.

1 Like