The FAQ provides immediate answers for questions collected from the Community on developing games with Multiplayer, including MLAPI, Transport, and more.
If you receive
ClientRPC errors like the following, you may have difficulty debugging:
⚠️ [MLAPI] ClientRPC message received for a non existant object with id: 16. This message will be buffered and might be recovered. UnityEngine.Debug:LogWarning(object)
You can set Enable Message Buffering to
NetworkManager. It will store those RPCs and apply them later once the object spawns.
We recommend the following:
Upload your server build to a cloud provider or another server machine and run it there.
Host your game locally and open ports in your router.
It should work just like over LAN you just have to connect to the public IP itself. Make sure to open UDP on the router. Many forward ports tutorials are available to review, including this option https://portforward.com/.
Use a relay.
There is an unofficial MLAPI relay application which you can try to host on a server. The relay server uses IP addresses to index hosts. You can connect to it using an IP address and port, but it will be routed through the relay server. You could also use MLAPI's list server to browse through all hosts.
The other option is to use something like the
SteamP2PTransport, which will work without the need of setting up any servers if you release your game on Steam.
We know there is a high demand for an out-of-the-box relay solution for MLAPI, and have plans to resolve in the future.
Yes, but you need to ensure that all your clients add the same object to their configs as well. You cannot only add it on the host.
Spawning can always be done on the host/server. If you want to give a client control over spawning objects, you need to implement a server RPC that you call on the client to spawn the object.
Networked physics is complicated, with many different ways to handle them. Currently, physics can be a little difficult to handle with MLAPI and the built-in
We recommend the following:
- Simulate the physics on the server and transforms on the client.
- Remove the
Rigidbodycomponent from all of your client objects and have just the server drive the position of the physics object. This should help reduce stutter on the client.
The Steam transport should be quite straightforward to use. Just add it to your project and set the
ConnectToSteamID in the transport on the client to connect to the host that's all you need.
Using Windows' built-in extracting tool may generate an "Error 0x80010135: Path too long" error window which can invalidate the extraction process.
As a workaround, shorten the zip file to a single character (for example "c.zip") and move it to the shortest path on your computer (such as in root C:) and retry. If that solution fails, another workaround is to extract the downloaded zip file using an application like 7zip.
If you attempt to run a build on OSX and receive a warning dialog mentioning an "unidentified developer", you may need to override your security settings for this application:
In the Finder on your Mac, locate the application you want to open.
Do not use Launchpad, it does not allow you to access the shortcut menu.
Control-click the app icon, then choose Open from the shortcut menu.
The app is saved as an exception to your security settings. You can open it in the future by double-clicking it just as you can any registered app.
See Apple Support for details.