Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by MenimalsEntertainment · Apr 13, 2021 at 09:45 PM · multiplayerservermultiplayer-networking

Using MLAPI to network across multiple computers

So I've recently been working with MLAPI networking to just get a very simple game working before I do anything complicated. Pretty much following the SRCoder tutorial on Youtube, I have a button that lets you join as a host or a client, and then it spawns in a player prefab. However, I'm trying to connect to the host's server from another computer. I have a second computer in my house, and I was able to do it through that, but my friend who is working on the project through Unity Collaboration was unable to connect from his place. The method I have in which the computers connect is by simply typing in the host's IP address into an input field, which then sets the IP in the U Net Transport script. Does anyone know what needs to be done in order to connect to a host who is not under the same wifi? Much thanks to anyone who can help!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by MenimalsEntertainment · Apr 14, 2021 at 04:40 PM

Ok so I did some research, and basically what you have to do is port forwarding on your router. Unfortunately, this is not a solution to multiplayer games and also has some risk, so I have decided to stop using MLAPI and instead use Photon for a public server, which is working well so far.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Aatifahmad · Jun 03, 2021 at 08:38 AM

Hey how did you manage to connect from another computer using same wifi? could you tell me?

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Llama_w_2Ls · Jun 03, 2021 at 09:20 AM 0
Share

Lan connection uses sockets, either TCP or UDP sockets, depending on the application you're making. I made a plugin you can just drag into your Plugins folder in your Unity project, that allows you to send and receive data from two devices on the same network, using TCP. You can find the github repo here: Lan Networking with an example file, and the plugin you can drag into your project files. @Aatifahmad

avatar image Aatifahmad Llama_w_2Ls · Jun 03, 2021 at 11:48 AM 0
Share

Have you check it in unity? i dont know where to put these scripts. Is it working in Mlapi?

avatar image Llama_w_2Ls Aatifahmad · Jun 03, 2021 at 12:09 PM 0
Share

My repo contains wrapper classes for TCP sockets, that help you to get a server and connect clients much faster, than having to worry about the extra details. If you want to use the plugin, I'll be more than happy to create some Unity scripts to get a simple application up and running for you. Otherwise, have a look at the more popular plugins, such as Mirror or Photon, which also support LAN connection.


Yes it works in Unity. In the repository, there's a folder called plugins. Create a new folder in your assets folder called Plugins, and drag the .dll file from the folder that says Net Core 2.0 into the Plugins folder. You should now have access to the namespace Networking.TCP in your Unity scripts


Drag in the example code for the Chat App, into a Unity script, and replace static void Main with void Start, and replace class Program with public class MyBehaviour : MonoBehaviour. Also Console.WriteLine() doesn't work in Unity, so you'll have to change those to key presses or button methods.

Show more comments
avatar image MenimalsEntertainment · Jun 03, 2021 at 06:00 PM 1
Share

This was the tutorial I used: https://www.youtube.com/playlist?list=PLbxeTux6kwSAseRmJeCyvkANHsI16PoM6

I found it very helpful when I was using MLAPI and I believe part 7 discusses how to connect over a local network. Obviously you don't have to follow the whole thing step-by-step, I think I skipped over part in order to see how to connect via LAN. There are also a number of other tutorials out there, but I found this one the most helpful for me. Hope this helps!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

203 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Multiplayer server choosing requirements VPS is this enough? 0 Answers

Player sets up server UNet. 0 Answers

Interchange player names in Multiplayer game 1 Answer

How to make multiplayer networking using C# as client and PHP as server,C# To PHP Server Based Multiplayer Game 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges