Search Unity

Free tutorials: Unity multiplayer - the easy way

Discussion in 'Multiplayer' started by adamascj, Feb 3, 2012.

  1. adamascj

    adamascj

    Joined:
    Apr 22, 2010
    Posts:
    55
    I believe that only using Unity resources (not an "external" server) , is the easiest way to learn multiplayer.
    Enjoy our tutorials and let me know here if you have any doubt.
    http://www.dmu.com/unity/dmuint0.html
     
    Last edited: Feb 3, 2012
  2. Hokage

    Hokage

    Joined:
    Feb 2, 2012
    Posts:
    4
    hi adamascj, thanks for the tutorial.

    I love clear outlines on how to do things from start to finish to get results.

    Even though I have been studying sockets, at the end of the day. I need examples, I need to see how someone else is doing things. Or else I would just be guessing, and that wastes too much time.

    I wish there were as many tutorials on networking as there is everything else game dev related. Tons of tutorials on animation, modeling, texturing, rigging, programing simple games etc. But hardly anything on networking.
     
  3. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Do note that Unity networking is NOT P2P but a client-server model.

    The server routes all traffic from all clients: a message from client B to client C will always go trough the one that is acting as server (i.e. client A).
     
    Last edited: Feb 3, 2012
  4. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Good tutorials, but Unity is never really peer-to-peer. Client/Server is still Client/Server when the server is a player.

    Edit: Missed Leepo's response :)
     
  5. Hokage

    Hokage

    Joined:
    Feb 2, 2012
    Posts:
    4
    Hi Leepo, I will be buying your networking tutorial soon. So far its the best solution towards learning networking. Clear examples that guide you towards results from start to finish.

    To the people who have knowledge on how to get results with Unity using .Net sockets........write a tutorial.

    Hell charge if you want, ill lbuy it. I understand you had to spend lots of your time guessing or spent lots of $ on college or a trainer to learn in order to get desired results, which is why you dont want to share that knowledge, I understand that.....and trust me im not mad at you for it. But if you charge a fee for your knowledge, it will make up for all the time you spent in front of the computer guessing.

    The difference between good examples and guessing games is like yin and yang.

    Thanks Leepo.
     
    Last edited: Feb 3, 2012
  6. BlueRadius

    BlueRadius

    Joined:
    Nov 14, 2010
    Posts:
    370
    Yo Hokage

    Ill write a tutorial

    Ive been so busy at work cranking out these realtime simulations of machines so it may not be as fast as you like.

    Ive decided to turn my upcoming game Alpha Glide into a multiplayer game so I will whip up something after I make a trailer of that.

    -Blue
     
  7. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Right, but that's not what P2P means in the game development community at large, so by referring to it as such in your tutorials, you run the risk of teaching people incorrect terminology.
     
  8. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    adamascj: you're confused, the "server" being a player or not has nothing to do with the naming, it's still called Server/Client model.
     
  9. azueta9

    azueta9

    Joined:
    Jan 26, 2014
    Posts:
    2
    Buenas tardes.

    Estoy haciendo un juego en multiplayer que consiste en unas carreras en bicicletas, cuando un jugador llegue a la meta, por medio de la función OnTriggerEnter() se carga la escena donde se despliegan los resultados. El problema es que cuando uno de los jugadores llega a la meta, en todas las pantallas se despliegan los resultados de quien llegó, el problema al parecer es que cuando se clona el jugador por medio de Insantiate no se elimina cuando llega a la meta. Agradecería mucho su ayuda.

    Este es el código del Multiplayer, va en un Game Object Empty y lo llamo "Menu":

    using UnityEngine;
    using gui = UnityEngine.GUILayout;

    public class GameMenu : MonoBehaviour
    {
    public GameObject PlayerPrefab;
    string ip = "127.0.0.1";
    static public bool connected;
    private GameObject[] redSpawnPoints;
    public bool amIOnTheRedTeam = false;
    //_____Variables para el menu__________
    public GUISkin Skin;
    private string titleMessage = "ECORIDE";
    private Rect connectionWindowRect;
    private int connectionWindowWidth = 400;
    private int connectionWindowHeight = 80;
    private int leftIndent;
    private int topIndent;
    public bool bandera;

    public void CreatePlayer()
    {
    connected = true;
    amIOnTheRedTeam = true;
    redSpawnPoints = GameObject.FindGameObjectsWithTag("SpawnRedTeam");
    GameObject randomRedSpawn = redSpawnPoints[Random.Range(0, redSpawnPoints.Length)];
    var g = (GameObject)Network.Instantiate(PlayerPrefab, randomRedSpawn.transform.position, transform.rotation, 1);
    g.camera.enabled = true;
    camera.enabled = false;
    }
    void OnDisconnectedFromServer()
    {
    connected = false;
    }
    public void OnPlayerDisconnected(NetworkPlayer pl)
    {
    Network.DestroyPlayerObjects (pl);
    }
    void OnConnectedToServer()
    {
    CreatePlayer();
    }
    void OnServerInitialized()
    {
    CreatePlayer();
    }

    void Ventana(int WindowID)
    {
    if (!connected)
    {
    ip = gui.TextField(ip);
    if (GUILayout.Button ("Conectarse", GUILayout.Height (60)))
    {
    Network.Connect(ip, 5300);
    //Bandera = true;
    }
    if (GUILayout.Button ("Crear Host", GUILayout.Height (60)))
    {
    Network.InitializeServer(10, 5300, false);
    }
    }
    }

    void OnGUI()
    {
    if (connected == false)
    {
    GUI.skin = Skin;
    leftIndent = Screen.width / 2 - connectionWindowWidth / 2;
    topIndent = Screen.height / 2 - connectionWindowHeight / 2;
    connectionWindowRect = new Rect (leftIndent, topIndent, connectionWindowWidth, connectionWindowHeight);
    connectionWindowRect = GUILayout.Window (0, connectionWindowRect, Ventana, titleMessage);
    }
    }
    }