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
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.
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).
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
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.
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
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.
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.
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);
}
}
}