I’m creating a multiplayer game for our school project and I wanted it to work even without access to the internet, I heard that Relay can be used to creating one but I don’t know where to start/ how to make it to work offline as it needs to access authentication first which requires internet connection to perform.
Our game will be run on android devices.
Hi,
You can find the answer on the FAQ from the Netcode documentation : Frequently asked questions - How do I join from two devices on the same network? | Unity Multiplayer Networking (unity3d.com)
Clients need to connect to the local IPv4 address of the server.
You can do it inside Unity by retrieving your local IP address and display it on screen on your server. (There is a way to find your local IP address in C# by using System.Net.Dns class, like used inside this thread : Get the device IP address from Unity - Questions & Answers - Unity Discussions)
This way, just like you’d do it on Relay, you will be able to share your server “join code” (i.e. the IP address) to the clients, and inside the game, you wanna set the transport layer to UnityTransport and use method like SetConnectionData
to change the IP address to where the client should connect.
I don’t have any information about Unity Relay working offline, and it seems to me like it wouldn’t work just like you mentioned that you can’t access it nor Authentication.
If you want server/client(s) to find themselves on LAN without entering the IP address, I suggest you to search Network Discovery, which can found be on Netcode via the community contributions :
GitHub - Unity-Technologies/multiplayer-community-contributions: Community contributions to Unity Multiplayer Networking products and services.
Hope this helps, please ask for more information if you need
Will this configuration work on android devices? I forgot to mention that the game that I am creating is a mobile game
I have never used Netcode for a Mobile project so I won’t be able to tell you exactly.
All I can say is that from what I found on forums, getting the IP address on Android is not as easy as it can be on Windows. I have found this thread where someone tried to get the IP address on an Android tablet : Can’t get Android’s (tablet) Local IP address - Unity Engine - Unity Discussions, so maybe you can make something work on your Android setup.
Other than that, setting the connection Data inside the Transport of the NetworkManager is basic Netcode, which is supported on Android so it should work.
I can’t tell you how Android devices will act when using the Network Discovery feature, I guess best is to just try it out if you’ve got the time and need to do it
But are there any multiplayer solutions that can be used/work normally on mobile devices and is able to be used without any connection to the internet? Sorry if I ask so many questions, it has been only a few months since I started using unity and it’s my first time creating a game
Don’t worry about asking questions, that’s what Unity discussions is for
In order for your server and clients to be able to join automatically on LAN, this is what Network Discovery is for. This is available as a community contributions inside Netcode, so you can use it :
I can’t tell you for sure if it works on mobile devices (I want to say yes but not sure), so you might just try it and see by yourself !
Fish-Net is a networking solution available for Unity and has a Network Discovery feature that IS “Fully Supported” on Android : Fish-Network-Discovery | Fish-Net: Networking Evolved (gitbook.io), so this is can be an alternative solution