How to Make a Simple Local (LAN) Multiplayer?

I’m completely new to the multiplayer aspect of Unity, and I don’t know where to start.

However as of right now, I have a Free-roam racing game, and Is there any way to simply, with no or minimal code, just have someone else join the game? There wouldn’t have to any changes to the game, it would be as if they are playing single player, but with the other car there too. Think how Rockstar makes their multiplayer, they just drop many people into a world and let them play it out. I imagine it would be simple enough.

Is there something on the asset store to do this? Or maybe some code somewhere so I can edit it but have a foundation for what to do?

The only networking example project I found, which was on the Unity website, is outdated and targeted for Iphones. When I copied it to the letter, It didn’t work.

Thanks,

Anyone? Sorry I’m struggling with the topic and can’t figure it out.

Again Sorry, but Bump

This will help you in the right direction.

http://cgcookie.com/unity/2011/12/20/introduction-to-networking-in-unity/

Btw. If you can’t figure out how to make others join over the internet, forward the ports on your router.

Thanks, I’m going to allocate some time to watch the whole video.

Or use NAT punchthrough?

Well using built in networking or UnityPark suite of www.muchdifferent you just need to change your instantiate and Destroy calls to Network.Instantiate and Network.Destroy
and add a smoothRigidbody to your racing stuff. If you have other world events then you should notify others using RPCs when they happen, otherwise nothing.

UnityPark suite is recommended and has a good SmoothRigidbody script for syncing rigidbodies. Unity’s own networking example has a script for that as well.

The tutorial does not work for me, it doesn’t draw the button on the screen. Help?

You replied to a 2 year old post but what’s the problem you’re having?

I just want a simple LAN join function, I want to create a menu with a “Single player” and a “Multiplayer” option.The Buttons are ready and all, but I don’t know how to allow players to connect over LAN, here is how far I got:

using UnityEngine;
using UnityEngine.UI;
public class PlayerScript : MonoBehaviour {
    public Button Single_Player;
    public Button Multi_Player;
    // Use this for initialization
    void Start () {
        Single_Player.onClick.AddListener (delegate {SetPlayer("Singleplayer");} );
        Multi_Player.onClick.AddListener (delegate    {SetPlayer ("Multiplayer");} );
    }
   
    // Update is called once per frame
    void Update () {
       
    }
    void SetPlayer(string Where){
        if (Where = "Singleplayer") {
            transform.position = new Vector3 (0f, 0f, 0f);
            Destroy (Single_Player);
            Destroy (Multi_Player);
        }
        if (Where == "Multiplayer") {
            //I have no idea what to do here
        }
    }
}

** @Thelegendofbrio ** - I’ve just been reading through the documentation so hopefully these will help you out.

When you’re clicking the multiplayer button, you’ll want to load a scene which has your NetworkManager script on a gameObject:
https://docs.unity3d.com/Manual/class-NetworkManagerUNet.html

To allow network discovery (LAN) you’ll need to use the following:
https://docs.unity3d.com/Manual/UNetDiscovery.html

The example in this document shows how you can host a server on your local machine or join a server:
https://docs.unity3d.com/Manual/UNetClientServer.html

For LAN i assume you’re using a listen server so that should work for you.

I don’t know how much multiplayer code you’ve actually implemented, multiplayer is not something you just switch on, you need to define the networked objects and variables that you want to synchronise and set up your spawnable objects etc before you can actually get basic multiplayer working.

I suggest reading through the documentation and/or watching some video tutorials as a starting point.
Understanding how everything works before you start trying to implement it is a lot easier than trying to add multiplayer piece by piece. There are a lot of considerations that are better to be dealt with up front.

2012 - 2014 - 2018 - 2021

someone make it 2012 - 2014 - 2018 - 2021 - 2022 or newer

2022 reporting for duty.

Almost 2023

Someone please lock this thread!

2023 is here.

continuing 2023

2024 Head checking in.

2025 and still reading this

2026 has arrived