#archived-networking
1 messages · Page 98 of 1
Lobby is coming along nicely new to photon
@tough umbra you still there?
@pseudo adder I am now, how can I help
Hey Erick, it's a shame audio cuts some words :/
Ye, sorry about that, the noise filter was misconfigured.
Already fixed it for my last stream. These videos will all be remade with better editing for when we’ll release the public free version of fusion.
👍
Anyone know why i am getting this error?
Assets\Scripts\PlayerListItem.cs(22,26): error CS0115: 'PlayerListItem.OnPlayerLeftRoom(Player)': no suitable method found to override
@pseudo adder if you use "override" on your method, you must first be inheriting a class with the same method name and prepended with "virtual"
Given you error... if there isn't a suitable method to override... then just try taking the word override out.
ok
Hey everyone.
I'm working on a game in Unity & I'm using the Photon package for the Networking.
However, I have a error - When I create a room on my other device, I get a error in the unity editor;
NullReferenceException: Object reference not set to an instance of an object
RoomListItem.SetUp (Photon.Realtime.RoomInfo _info) (at Assets/Scripts/RoomListItem.cs:18)```
Thank you.
Any support is appericated.
Are you calling an RPC, if so you need to reference that on the call make sure it has a photon view @weak ferry
but its hard when we cant see code
I changed MonoBehaviour to MonoBehaviourPunCallback.
So, That might fix the problem.
I don't think that's it.
So your just trying to create a room, because i don't see anything that attempts to create the room.
Wait nevermind.
I'm not doing the multiplayer thing anymore. Might do in the future.
hey don't give up if you want something being made you gotta go for it ( this is how i generate my room ) and it makes a random code that other players can join with it
the room name is a 5 digit room code that is generated through the roomNum(); method
Then join the room on different clients
the roomInput.text is just an inputfield and just grabbing the text from it
Uh, I just saw the new Unity networking system. Should I transfer my project to it? Or should I keep going with bolt or pun?
It depends, if you want an out the box experience stick with Pun, if you know how to set up your own matchmaking servers and probably save money mirror or any other p2p networking
@leaden robin
Hello,
when my client connects to the server, the server sends a message back to the client. but it only does that as soon as i have focus on the server.
does anyone know why?
Maybe check if "Run In Background" is enabled ?
well that was fast and it worked. thanks a lot!
What are the best networking solutions for hosting 17 simultaneous games of 15v15 FPS matches? AWS, Google Cloud? Photon? Local (and if so, what hardware)?
I have a linux server running in my house that I have many of the main ports forwarded to. I can connect to that no problem and use it for an auth server no problem. When I try to use a basic MLAPI network manager and player setup on my windows 10, with the designated port forwarded my friends can't connect nor does the port appear open from the internet while hosting. I've gone as far as turning off the fire wall completely. Any ideas why my ports wouldn't appear open or allow connections?
Check access logs on your linux servers, you might get a hint what's wrong
Also your firewall package logs, it's been a long time for me doing dedicated, can't remember if they get aggro'ed in the access logs or their own file.
So once i connect to the masterserver i create a room named Lobby and when i want to join the GameRoom i leave the LobbyRoom before joining the GameRoom but i get this error Also Code Below.
Client is on GameServer (must be Master Server for matchmaking)but not ready for operations (State: DisconnectingFromGameServer). Wait for callback: OnJoinedLobby or OnConnectedToMaster.```
**Lobby Room Unique To Each Player**
```CSharp
public override void OnConnectedToMaster()
{
connectingText.text = "Connected To The Master Server!!";
RoomOptions options = new RoomOptions();
options.MaxPlayers = 4;
options.IsVisible = false;
options.IsOpen = true;
options.PlayerTtl = 120;
PhotonNetwork.CreateRoom(PlayerInfo.username, options); // Lobby Room Unique To Each Player
}```
Leaving The Lobby Room
public void OnClickReady()
{
if (PlayerInfo.currentGamemode == "TDM")
{
PhotonNetwork.LeaveRoom(false); // Leaving The Lobby Room
}
}```
Joinning The Game Room
public override void OnLeftRoom()
{
RoomOptions options = new RoomOptions();
options.MaxPlayers = 10;
options.IsVisible = true;
options.IsOpen = true;
options.PlayerTtl = 60;
PhotonNetwork.CreateRoom("TDM", options, TypedLobby.Default);
}```
How should I go about learning networking? I'd like to create a game that uses lobbies and servers with <20 players, rather than open world style-multiplayer. I'd consider myself a fairly skilled programmer, but I don't even know where to start. Any tips?
I found a few promising youtube tutorials and one on Udemy, but I figured I'd ask here before committing.
@weak plinth you want to learn to code multiplayer from scratch yourself? Or use existing library
Then find a library that’s decent and learn that
any recommendations?
Hey all. I am pretty new to Photon and had a bit of a newbie question. I am making a lobby screen and instantiate a prefab (with PhotonNetwork.Instantiate) with their name, a button to select which team they want to be on, and a "ready up" button (as seen in pic).
My problem is that currently despite the RPC method being called to change the color of a particular button and referencing all targets, it is not updating the object on the other players' views. I have a PhotonView script attached to the parent container object as well as one for each of the two buttons (pretty sure this is not how you do it, but I saw something about having to attach PhotonViews to child objects). I have gone through the intro tutorial on Photon's website but I am still a bit confused. I am sure it is something simple, but do yall have an idea what my problem might be?
I can post what I have currently for code if need be. Thank you.
Hey guys, I'm working on a simple multiplayer co-op VR concept (Quest 2, so Android build target), trying my hand at networking since I've not done it very much before, I think I've used bolt successfully for a simple project in the past (a couple of years ago can't remember exactly) but not sure whether bolt or pun 2 would be a better solution in this case?
I've looked through their comparison online but without proper experience I'm not sure exactly what the pros/cons of each package mean
A few notes about what I'm hoping to achieve:
- User creates a lobby, 3 of their friends can find and join it, spawn a random procedural level (Level is created at start, shouldn't need to be updated as the level progresses), semi roguelite/like, enemies spawn, can be killed, drop loot, progress from different "runs" will be stored locally as I'm not bothered about cheat prevention.
Things i'd like to be replicated to all players: - Other player transforms (head + hands) + info (username + health)
- Enemy transforms + health
- Visuals from other player actions (eg. gun shot trails)
- Physics on objects that are 'grabbable'? - this isn't key but would be nice
- Pickups / drops (items / what have you that would appear when an enemy dies)
From this summary would you guys recommend Photon bolt or Photon PUN2? Thanks for any suggestions
Hey, I'm just trying to read ports on localhost with Unity... any idea where to get started? Using Unity 2019
basically trying to mimic some NodeJS port reading stuff, but have it done through Unity
const net = require('net');
const hostname = 'localhost';
const receivePort = 39998;
const sendPort = 39999;
const getScriptsJson = JSON.stringify({ messageId: 0 });
let thinger = () => console.log('hey');
const server = net.createServer(socket => {
console.log('Connection established');
socket.on('data', bytes => {
console.log(bytes.toString());
})
});
server.listen(receivePort, hostname, () => {
console.log(`server listening on ${receivePort}`)
});
const client = net.Socket();
client.connect(sendPort, hostname);
client.on('connect', () => {
console.log('Client connected');
})
client.on('data', data => {
console.log(data.toString())
});
client.on('error', e => console.log('CLIENT ERROR\n', e));
client.write(getScriptsJson);
Trying to get something like that to work in Unity
I was looking into https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcplistener
It kind of worked but wouldn't parse properly... I'm on the right path but don't know how to implement it I think
Why did the MLAPI go from version 12 to version 0.1?
https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi/releases
This is the initial experimental **Unity **MLAPI Package, v0.1.0.
Rewrite history like nothing happened
It's because of Unity package naming conventions. Since MLAPI is now an experimental package we are following naming conventions.
If anyone has any recommendations or suggestions regarding my question that'd be super helpful 🙂
What's the best way to start if you want to connect a Discord bot to Unity? I would like to change certain world parameters via Discord commands
@flat quartz Good Question, but i dont know :D
Jelle Vermandere basically did this in a video, the game still goes live occasionally on his discord i think, info & video here:
https://jelle-vermandere.fandom.com/wiki/About_RoboYal
There are also another couple examples of people doing it on youtube if you search
Can anyone tell me how to run multiple instances of a build at the same time?
Found the solution: Just launch the built `.exe`` as many times as needed. lol
thx
A quick google answers that
So it is supposed to be checked? @flat quartz
I did google and it was a mention of 'it is not possible' and project settings thingy. And I had it disabled assuming that was the correct setting
Nope did not help
Thanks tho
I am making a network for my game right now
So it needs MonoBehaviourPunCallbacks
So how do i add it as a component??
Please help
hey everyone, I am looking for a good netcode sample (Unity.NetCode). The online docs are ok but seem to be a little broken and don't explain subscene conversion workflow that well
or maybe just a study buddy for a bit to help me get comfortable
@weak plinth Have you tried inheriting from MonoBehaviour as well as MonoBehariourPunCallbacks?
public class NetworkController : MonoBehaviour, MonoBehariourPunCallbacks
Hi, have you followed the Getting Started Tutorial? https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/intro
I recently found the mirror networking library, free on github
Anybody's got Android to Android Network.Connect to connect successfully with the Legacy Networking Components? I'm using masterserver and facilitator on Centos Linux on a hosted machine, the hostinfo is retrieved successfully, Network.Startserver works ok, and the Network.Connect issued by the "client" using the network's guid in order to perform NAT Punch Through is used, but in reality fails...
I am working on a game with photon and i was wondering if there is an easier way to test my game other than build it every time
Some setup their project to duplicate in 2 locations on disk so you can have 2 editor instances open
There are some tools for this around like ParrelSync or UnityProjectCloner.
Hey, I´m an absolute beginner to networking. I´ve started programming and building games in unity about 1.3 Years ago, and have finished one small( 6-8 hours playtime) and one little game (<1 hour Playtime) until now. Now i would like to go into networking and am pretty overwhelmed by all the possibilitys Unity offers. Could you tell me, which solution would be the best for me to start with, please? Thank you very much!
photon (pun2) is often recommended.
For very very first Pun2 and Mirror are the usual starting points yeah.
MLAPI right behind that, but until recently it didn't have much community happening.
Anyone had experience implementing agora video chat in unity multiplayer using photon?
is photon chat outdated? the documentation + the official guides are kinda hard to understand and i'm attempting to integrate it with a game using PUN2 right now, if anyone has any pointers or resources
@solid crow I suggest you to join Photon's own DIscord for that. The chat lead dev is there and is very active.
I can send you in PM (we can't post links for that here AFAIK)
why are my players not joining same server/lobby
i am using pun2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class NetworkController : MonoBehaviourPunCallbacks
{
public Text txtStatus = null;
public GameObject btnStart = null;
public byte MaxPlayers = 4;
private void Start ()
{
PhotonNetwork.ConnectUsingSettings();
btnStart.SetActive(false);
Status("Connecting to server");
}
public override void OnConnectedToMaster()
{
base.OnConnectedToMaster();
PhotonNetwork.AutomaticallySyncScene = true;
btnStart.SetActive(true);
Status("Connected to " + PhotonNetwork.ServerAddress);
}
public void btnStart_Click()
{
string roomName = "Room1";
Photon.Realtime.RoomOptions opts = new Photon.Realtime.RoomOptions();
opts.IsOpen = true;
opts.IsVisible = true;
opts.MaxPlayers = MaxPlayers;
PhotonNetwork.JoinOrCreateRoom(roomName, opts, Photon.Realtime.TypedLobby.Default);
btnStart.SetActive(false);
Status("Joining " + roomName);
}
public override void OnJoinedRoom()
{
base.OnJoinedRoom();
SceneManager.LoadScene("TanksGame");
}
private void Status(string msg)
{
Debug.Log(msg);
txtStatus.text = msg;
}
}
thats my netowrkng code...
you may be using "best region", and different players connect to different regions based on ping.
You can only join rooms on the same region/cluster you are connected to
How to send a unity web request on local files, in editor ? what should be the the url ?
I'm working on an asynchronous multiplayer game, meaning there is no real-time instance where two players will be in a match with each other. I've written an API that the game talks to but I was wondering if I should put a server in between the two.
What's the recommended route for asynchronous gameplay? Should the game talk directly to the API or should the game talk to a game server, which then routes to the API?
@weak plinth Collaboration posts belong on the Unity forums, links are pinned in #💻┃unity-talk.
Just the api directly
Assuming this is like a rest api. No need for an intermediate server, it’s unnecessary complexity.
Thanks for the reply. Yeah it's a REST API. Agree with the unnecessary complexity
Hi friends I need to use a curl request via UnityWebRequest how can I achieve this any help will be much appreciated:
curl -X POST -d '{
"registrationNumber": "string"
}' https://driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1/vehicles
-H 'Content-Type: application/json' -H 'Accept: application/json' -H 'x-api-key: string' -H 'X-Correlation-Id: string'
With UnityWebRequest you can achieve same result as your CURL call, in this case an HTTP POST request https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.Post.html
- as you'll need to set some headers before sending, look also this https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.SetRequestHeader.html
everything you need can be easily extracted from the CURL command you sent, good luck, ask more questions if stuck 👍
Hi everyone, I'm a new user to Unity and PUN, and I am absolutely stumped with this nullreferenceexception error. My project works completely fine in editor, but immediately gets a NRE when I build and run.
Launcher is the only script being executed, and it literally only has a Start() method.
Here is the error message (Corruption is project name):
NullReferenceException: Object reference not set to an instance of an object
at Photon.Pun.PhotonNetwork.StaticReset () [0x00013] in C:\Users\Ryan\Corruption\Assets\Photon\PhotonUnityNetworking\Code\PhotonNetwork.cs:1037
at Photon.Pun.PhotonNetwork..cctor () [0x00241] in C:\Users\Ryan\Corruption\Assets\Photon\PhotonUnityNetworking\Code\PhotonNetwork.cs:1020
Rethrow as TypeInitializationException: The type initializer for 'Photon.Pun.PhotonNetwork' threw an exception.
at Photon.Pun.MonoBehaviourPunCallbacks.OnEnable () [0x00001] in C:\Users\Ryan\Corruption\Assets\Photon\PhotonUnityNetworking\Code\PunClasses.cs:111
(Filename: C:/Users/Ryan/Corruption/Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs Line: 1037)
what's on PhotonNetwork.cs line 1037?
all the github repos i can find have nothing on that line
lol someone alreayd resolved my problem. hes my new guardian angel
turns out photon didnt import correctly
so i just had to reimport
Anyone knows whether Mirror(the network plugin) and Entitas( a ECS framework) are compatible with each other, in terms of game object spawning and lifecycle management ? Thanks
has anyone did anything with the new MLAPI stuff?
Hi there! I am trying to place my spawned object as a parent of an object that i have. I can make it work on local game, but i am usign PHOTON to make it a multiplayer and on the server i cant place that as a child. Maybe i am doing something wrong.
code:
Vector3 PlayerVector3 = new Vector3(Player.transform.position.x, Player.transform.position.y, Player.transform.position.z);
SpearSpawned = PhotonNetwork.Instantiate(Path.Combine("Weapons", "Spear_Item"), PlayerVector3, Player.transform.rotation) as GameObject;
SpearSpawned.transform.parent = Player.transform;
Maybe i have to add something?
Reparenting networked objects adds some complexity to the networking.
You need to replicate the reparenting on all clients, of course, or else the object's positioning may be off on some clients (due to being parented)...
Either you use some script on the prefab and run code in OnEnable or you can implement OnPhotonInstantiate (definition in IPunInstantiateMagicCallback). This will run as soon as the object got created, which means other components are maybe not initialized yet.
Anyone know about sending emails from unity? I'm trying to figure out how to have an inline image in the message body
oop nvm figured it out
Thanks for your answer I tried to make it work but unsuccessfully 😦 can you please guide me with this thanks!
hey has anyone here worked with using the A* project to path agents and synchronizing it via photon?
do i need to do anything special or will the standard photon transform be enough to handle it?
you need to sync position/rotation info to other clients
I don't think network transform actually does that for you, though I don't use photon
eg if you make the AI's destination to x how is network transform supposed to know about that destination? since it has no idea about a nav agent especially not a third party/custom
so you'd be doing all that yourself
Any idea how to spawn player in MLAPI?
Can i explain what i am trying to do and if you can help me understand the logic the i have to place in?
What did you try and how does it fail ? (do you have code to show and the error you get ?)
whenever i press "host game" i get this error, why? im using the latest version and photon bolt
Hi, does photon free support 20 players at once or 20 players per server/host?
20 players globally at the same time
Hey, can anyone give me an advice on how to use the "NetworkTransform" component in the new Unity Networking Solution with MLAPI.
For example how to sync Player Movement using this.
https://docs-multiplayer.unity3d.com/docs/components/networktransform
AFAIK you just put the component on, and it should synchronise the movement of the object
@olive vessel Yeah, seen that some minutes ago. The documentation was quite helpful. But can somebody explain me where´the diffrence is between Unity's MLAPI networking Solution and normal MLAPI networking?
Few name of the function and classes are changed and the Unity's MLAPI works in top of Mono Cecil Package
So why does the NetworkTransform not sync scale 🤔
Hello, using pun2, i want to be able to damage the other player if i stomp on it like mario stomps on a goomba. I currently dont have any damage and/or health system. Where should I start?
..Can we sync dictionary<Key,Value> using Photon pun 2.?.. if yes, then how??:/
I like how this server instantly deletes my questions. Great feature.
Consider using Discord's markdown features
When I trigger Destroy(GameObject) from a client, the Host and the Client both destroy the object, but when triggered from the Host, only the Host destroys the object.
That behaviour is definitely not in the documentation.
What documentation? Unity? Photon? when you delete something from the host you also have to tell the clients you deleted it @opal kite
When Mirror destroys the game object on the server, it also destroys it on the clients
Do you have a simple example of the client code that seems to work and the server code that does not?
The only thing I can think is you are not sending the information (that you destroyed a gameobject) to all of the clients from the host, maybe when you do it from the client it triggers the host to send it to the rest of the clients but when you destroy on the host it is not for some reason
It runs the same code
Also I need to refine the problem statement, since I did some more testing. It seems like it doesn't matter who triggers the Destroy, it sometimes does not update the other clients.
you're using NetworkServer.Destroy?
it appears so
why isn't photon switching the scene on mobile platform it works on PC ```CSharp
if (PhotonNetwork.CurrentRoom.Name == PlayerInfo.username)
{
PhotonNetwork.AutomaticallySyncScene = true;
PhotonNetwork.LoadLevel("LobbyScene");
Debug.Log("On Joined Room Called");
}```
Does anyone know how to call commands on objects that are not to the player's network identity. I want to sync destroying an object that has been picked up by a client
o/
Anyone know what this error means in the context of .Net's Ping.Send NotSupportedException: Unexpected socket error during ping request: MessageSize?
It occurs when polling online machines on the local network, but I can ping 8.8.8.8 fine with it and the error only occurs within Unity - a console app can ping 127.0.0.1 just fine.
Hm. It also occurs when pinging some external IPs? Namely 139.130.4.5 (Telstra's IP)
The error has not been mentioned online a single time, at least as far as google knows
Not a single search result
Any chance it's a firewall/security software blocking Unity?
Unlikely, as I can ping 8.8.8.8 from Unity.
Additionally after further testing, small pings seem to work even to the problematic addresses
However an exception is not the defined behaviour of a ping when the message size is too large
And the error happens at least at 100 bytes, which is ridiculously small
73 bytes is the largest valid packet size I can get for 127.0.0.1 within unity using Ping.Send() without getting an exception
The Telstra IP gets 72
Meanwhile in the console app, I can send 40,000 bytes without issue locally
That's what made me think something's blocking it, because the symptom sounds fairly arbitrary otherwise
I've tried making ICMPv4 and ICMPv6 allow rules for inbound and outbound, allowed all ports in/out for Unity, and disabling the firewall altogether
No difference
@latent horizon if you've got access to a unity instance, maybe you could give it a try?
I was going to move to the computer shortly; drop some code and I can try it if it's just some generic calls
This should do
IPAddress ip = new IPAddress(new byte[] { 127, 0, 0, 1 });
System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping();
for (int i = 0; i < 100; i++)
{
var r = p.Send(ip, 200, new byte[i], new System.Net.NetworkInformation.PingOptions(250, false));
Debug.Log("(local) " + r.Status + " @ " + i);
}
ip = new IPAddress(new byte[] { 139, 130, 4, 5 });
for (int i = 0; i < 100; i++)
{
var r = p.Send(ip, 200, new byte[i], new System.Net.NetworkInformation.PingOptions(250, false));
Debug.Log("(telstra) " + r.Status + " @ " + i);
}
Ok. Gimme like 5-10
👍
@final pagoda All success here
Huh... I’ve tested it over two PCs on my network and had the same issue
Maybe a router issue, but why would that only occur in unity
Yeah, I dunno
Or an issue with the project somehow. Gotta test it fresh I guess
I'm using 2020.3.4 on a Mac, I imagine the Mac part at least adds another variable
You would think this wouldn't be very dependent on Unity itself though since it's just straight .Net stuff
Pretty weird problem
That’s why I’m so dumbfounded, but it only occurs within the engine
And only on arbitrarily specific ips
And not on your machine but on both of the ones I have access to
And at an arbitrary size
I don't have a PC or Linux machine to try on
I’ll get a couple others to try it if I can
hm @latent horizon out of curiosity, is there a limit to what the ping will do?
The max theoretical single packet size is like 65k
I had another friend (windows, 2019 unity) try it out and they had it break on 73 as well
So, just increase the loop to go up through 65500 right?
I'd love to tell you, but for some reason Unity doesn't want to enter play mode anymore, it just goes into lala land doing nothing forever.
I wouldn't do all the way to 65k iterating by one
Maybe 65k by 1000s
Because ping.send() is a blocking call
Ie. it'll probably take like 10-15 minutes to complete 65,500 pings
Yeah, maybe that's what's happening here even though it appears frozen
Yeah. The UI totally freezes until this completes. Fascinating.
Well, the answer is that it succeeds on every value up to and including 65500, fails immediately even at 65501
Sounds like the behaviour I'd expect
But, it doesn't fail at the NETWORK level, the Send API raises an exception
This is perplexing. I'm gonna post to the subreddit about it
See if I can get some more users to test it
Just had another user test Mac and windows
Windows fails at 73, Mac suceeded up to at least 100
That is really weird
Guys
Is it normal that I'm not getting an error while trying with the client to connect to a server, which doesn't exist (ip-address not hosted at that point) [using Unity's MLAPI]
I guess it will eventually just timeout?
@olive vessel sure, but how long should that normally take?
Is there a better way to see if the ip-adress is actually hosting a game without trying to join
Hi, I'm new in multiplayer and I use Mirror. I just want when a player collides with a power block (simulate by pressing F2), it will call a function on all clients except the sender. I show you my code :
using System.Collections.Generic;
using Mirror;
using UnityEngine;
public class PlayerPowers : NetworkBehaviour
{
[SerializeField]
private GameObject cam;
public float rotationCameraTime;
void Start()
{
cam = GameObject.FindGameObjectWithTag("PlayerCamera");
}
void Update()
{
if (Input.GetKeyDown(KeyCode.F2))
{
CmdRotationCamera(this.netId); //It send the Id of the transmitter
Debug.Log("Call Cmd : " + this.netId);
}
}
[Command]
public void CmdRotationCamera(float clientCallCmdId)
{
Debug.Log("Id of the Cmd : " + clientCallCmdId);
ClientRotationCamera(clientCallCmdId);
}
[ClientRpc]
public void ClientRotationCamera(float clientCallCmdId)
{
Debug.Log("Client id : " + this.netId + " clientcallcmdid : " + clientCallCmdId);
if (this.netId != clientCallCmdId)
{
StartCoroutine(RotationCameraTimer());
}
}
IEnumerator RotationCameraTimer()
{
cam.transform.localRotation = Quaternion.Euler(0f, 0f, 180f);
yield return new WaitForSeconds(rotationCameraTime);
cam.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
}```
But when I start the program and test it, in the void ClientRotationCamera the id of the player who starts the function (client 2) is correctly stored (clientCallCmdId = 2) but in the consol of the Client 1 the client id (this.netId) should be the id of the player of the client 1 (so 1) but it's equal to 2. I don't know what happened. Thank you for your help and tell me if I don't tell you enough information.
Just a thought, but don't you want to check if you are the local player in update?
I don't understand why check if is it the local player ?
Well if each player has this script, and you have 4 players, won't the script run 4 times when 1 player presses F2?
No, because I deactivate the script of other players for each instances
Well you didn't mention that, idk what the problem is but you could ask in the Mirror Discord
The problem is that when the server calls the clients with the clientRpc, the id of the player running the ClientRpc is that of the second instance while we are on the first.
I am working on a networked game usuing MLAPI and I have 2 cameras in my world so I want it so when you start a game or when you join a game when your character spawns you instantly host it
hey guys, I'm trying to set up unity to use a dedicated server using MLAPI, but I cant get it to work. I've tried using relay but that also hasnt given me a whole lot of luck either. Anyone have any advice?
Anyone have any success getting MLAPI to work in WebGL? I'm trying to just listen to a port on the computer and output the data from the port into the console. Any idea how to do that or if it is possible?
Hi all. If you're a multiplayer developer and have 10 minutes to spare, we're doing a survey here at Unity. Unity wants the input of multiplayer creators to better understand how profiling network activity is working for you and what are uncovered needs. The survey is short, averaging around 10 minutes with less than 30 questions.
If you have a moment, may you consider providing your perspective? Our learnings from the data will help Unity understand how to better support the needs around multiplayer and network profiling. https://unitysoftware.co1.qualtrics.com/jfe/form/SV_a5jS6WtpgNCoY4u?source=UnityDiscord
The most powerful, simple and trusted way to gather experience data. Start your journey to experience management and try a free account today.
Anyone have ideas on how to get something like TcpListener to work in WebGL? If that's even possible?
I don't know if you can do that, Mirror has a WebSockets transport
Yeah can't do that, need to use a custom websocket setup
Anyone using Unity.Transport?
I'm wondering if there a max number of packets I can send per frame
As it seems be dropping a packet but only when im doing my stress tests (8kish entities being synced)
In my smaller tests those packets are definitely working fine
The packets are commands (rpcs basicly) but they all send/receive in the same way as any other synced data
There are VERY few of these commands (only ~2 each frame) which easilly fit within one packet
I haven't configured any Transport Pipelines, looking at getting the debug one in to confirm if packets are dropped
I havnt yet started my network optimisation path, things like bit packing/data compression ect are still missing, however i have good access to all this low level stream writing so should be easy enough to plug in
Hi there! Can anyone help me with Photon RPC functions?
so im having a problem where a client can move their camera and it moves the camera of the host, how do i fix this? do i do an if(isLocalPlayer)? heres my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class MouseLook : NetworkBehaviour
{
public float mouseSensitivity = 5f;
public Transform playerBody;
float xRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}```
In Update, I would do an !IsLocalPlayer and return
So if they aren't the local player, we just return out of the update loop
I guess you could also just disable the script?
ok, ill try that
If i want to connect unity to my Postgresql database do i need to implement it as a rest API and use the API?
yeah this or maybe someone did a csharp-postresql lib on github 🤷♂️
hey guys is there a way to make a client join separate scenes that the server can switch between using mlapi
like I have player1 and player2 join. They are both playing the same game in separate instances?
i new to multiplayer games i have racing game can i add multiplayer mode for free or i will need to buy server any know plz help
ah ok thanks
Photon Unity Networking gives you 20 CCU free, but after that I believe you have to pay
Otherwise you could just allow P2P games
Do you know does Photon require a credit card for thoes 20 CCU free?
I'm not sure about that honestly
It does not.
Ahh yeah, I doubt you'd need more
Maybe in future
For basic 20 is fine
It will not be relased soon just some closed beta😂
Or I will just enable p2p
Does anyone know how to deal with rubber banding on the client? It's not latency since the host and client are on the same machine
I'm using mirror
How do you do movement?
I have a Move() function in a Player script on the Player Prefab. The Move() function is inside FixedUpdate
I don't know if fixedupdate could be affecting it, but when you mentioned rubber banding I thought you'd done server authoritative movement
would having server authoritative movement fix the issue?
No, server auth movement introduces latency in and of itself
Because you ask the server to move you, then it moves you
Show us how you do movement atm
hey guys is there a way to make a client join separate scenes that the server can switch between using mlapi
like I have player1 and player2 join. They are both playing the same game in separate instances?
https://hatebin.com/wfeqkleczn this is is the Move() function
Have you tried it in Update instead?
Yeah. I just tried it again and I get the same issue. The issue though is on the objects the player is pushing into. So I have the player and then the blocks. If th player moves really slowly, I can push the blocks a bit, but often they snap back to where they were, or if the player is moving fast, the player will just go through them.
Which networking solution are you using?
Mirror
You could try asking people in there, they might have some ideas
ok, thanks for having a look
I haven't looked too much into MLAPI yet but you are describing additive scenes. AFAIK it is not yet supported
damn it okay. Thanks @rough grotto
dont take my word for it but I saw this issues (which is 1 year old) https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi/issues/307
and no mention in the docs about this
I am still using mirror so haven't jumped on the MLAPI train yet
it looks to be quite far from the features mirror has
so there is no way for me to have multiple people on the network but in different scenes?
I don;t think so in MLAPI
I think I remember a video, on something like that for Mirror
Where each "Room" was issued a code, and you joined by code
I'll try and look into that. Thanks.
Another question, has anyone worked with networkvariables in mlapi? mine are saying on the server side that the internal value is 0 but on the client side its not.
Hey, I was looking for the ClientRpc and I don't understand how that works. I just create a script and when the local player press G, it should call a command and after a ClientRpc to execute a void in all instances, but the ClientRpc is only call on the client who calls the command. How execute a void on all clients from one? I share you my script. Thanks for your help. 🙂
https://pastie.io/wetboq.cs
How can i reduce lag between players? i have two simple players and when one moves it lags like alot!
Can someone help me with this on Mirror? It is my understanding that ClientRpc functions only run on Clients (though are called from the Server). Yet I put a line into my RpcMove function: "if (isServer) {Debug.Log("This shouldn't run");} and yet it does run. Can someone explain how this happens or what I'm not getting?
@verbal island Is it a dedicated server? If the connection is hosting and a client than it's normal:
https://mirror-networking.gitbook.io/docs/guides/communications/remote-actions#clientrpc-calls
"When running a game as a host with a local client, ClientRpc calls will be invoked on the local client even though it is in the same process as the server. "
So because it's both client and server, both ClientRpc runs and isServer returns true?
Hi all, I've been struggling to comprehend this error for a while now, and would appreciate any help.
https://hatebin.com/btsjyiuowf
Oh I should probably mention, "players" is a NetworkList of a custom struct
@olive vessel So basicly it's saying that no version of the ListUpdated method is accepting a NetworkList<PlayerInfo>.OnListChangedDelegate, so basicly, whatever argument you're passing to the ListUpdated function, isn't a valid! And reading the signature of your method, it's true. You need to send him an Object and an EventArgs. Maybe show us how you're calling the method it would help.
I'm not very knowledgeable regarding events.
The NetworkList class has this inside
public event OnListChangedDelegate OnListChanged;
I thought I could subscribe to the event like I did in that hatebin script, but I have no idea what it wants for args
This is with MLAPI by the way
ListUpdated should be
{
// your logic
}
Ah right, thank you
Hi there guys! Could anybody be so kind and explain how to connect (using mirror) to a hosted game via internet?
I'm trying to synchronise spawning of 100+ objects over a network, currently we have a local spawner class that relies on button presses to trigger certain states. I started to rewrite the network code inside the same class but it's beginning to get messy. How would you recommend separating the network and local code?
The functions themselves are pretty much the same, however I want to be able to pass in parameters for the networked functions
This would change the signature of the functions, which steered me away from the idea of using interfaces / inheritance. Please let me know if I'm missing something obvious in this choice
Doing some reading it looks like I should be looking into event driven code
Can i ask questions thats releated to mlapi here?
Aye, or in the MLAPI Discord
im just trying to setup scripts. I want to make a game about cards that will be spawned on start and players will rotate it by pressing.
So i think cards should have a network script to sync their movements to other player.
And i should make a global network script to spawn them and destroy?
How should i set it up?
@proven belfry This is quite a big question, But yes, you could have a script to spawn your cards. So with the MLAPI, you can attach NetworkObject to your cards and have some NetworkVariable to update their status (Like Rotation angle). That way, whenever a player press the card, you call a ServerRPC and update one of the variable, and every client is going to have that variable for that gameobject updated. So if in your update loop you look for this value, you'll see it change.
That's the basic of it. You can check the doc's getting started to get a feel of it: https://mp-docs.dl.it.unity3d.com/docs/tutorials/helloworldintro/index.html
This "Hello World" guide walks you through creating a project, installing the MLAPI package, and creating the basic components for your first networked game.
hey guys. I'm working with mlapi and I'm having this issue where my player prefab disappears when I jump to a ceratin scene on the client side. Has anyone run into this before?
it seems like i have 2 prefabs. One of which is not a networkobject, but it still kicks out the network prefab when I introduce the other one.
It also starts giving me keynotfounderrors. Its like when i press the button it just deletes the player prefab. Any advice would be very much appreciated
@dense notch thank you for help 🤍
Does anyone know if MLAPI supports html5 builds? I tried a test build earlier today and it threw a bunch of mlapi errors..
Hi, anyone here has a working entity interpolation code to see as an example? No matter how i try to do it i get jittery movement (way better than without interpolation, but still noticeable)
Wouldn't you need to use Websockets?
alas I have no idea. probably for a web build eh? is that the core of the compatibility problem?
I'm not 100% sure myself, but I know Mirror has a dedicated Websockets transport
Is this the channel for making multiplayer thing
Yep, welcome to Networking
I would expect MLAPI to support all Unity platforms until proven otherwise. Websocket support is generally the core for compatibility with browser networking.
so it's possible I just needed to debug maybe
Could share the errors. First thing to try is to build for desktop.
building for desktop works, I'll try a web build again tomorrow and collect the errors
Quick search for websocket mentions seems to suggest that UNet transport is used for websocket support
@grim bloom There are few open issues regarding WebGL. https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi/issues?q=is%3Aissue+is%3Aopen++WebGL
ah yes, I see there's a couple of merge requests for fixes 😛
tbh its kind of a non-issue for me atm, by the time the game's ready to build i'll just have to update mlapi and it'll just work!
MLAPI does currently not support websocket. The UNet transport has some issue which prevents it from working.
ah, excellent, I'll let someone who is paid figure it out then 😄
in Mirror, how can you reference a variable specific to a client? I'm trying to have it so if two clients do an action, the server then does something.
hmm, maybe server can collect and count tokens from clients, expiring if the action needs to be synchronized between the players, but adding up to 2+ if it gets a couple of +1s
prooooobably not the best solution
I tried to create a variable on the server but I don't know how to get a specific client's variable and put it into the server variable
Alas, I'm unfamiliar with Mirror, so I don't know either, trying to think of hacks 😛
I know mlapi applies an ID to each connected client
hey guys i have this weird issue where the networkvariables are being sent correctly across the network with mlapi on my computer but when a friend tries to run the same project, it doesnt work. anyone know why
@grim bloom no worries, thanks, I will try to figure something out with client ID
@prisma warren I don't know if this is what you're looking for, but every tick, my server sends a full list of entities/players/etc to each client, so the client can see if he's missing something, or has something that the server doesn't have, so he knows to spawn/remove them on the clientside
If you just tell the server to tell the clients "spawn an entity here" when it happens, you're going to have problems when players join after that message was sent
Thanks for the ideas, players won't be able to join if the game is already in progress so that's no issue
Hello,
I’m currently working on a WEBGL application where children could create their stories by picking heroes and place.
The application went too heavy so i split it in several webgl.
So, i’m looking for hints on how making these webgl connect together.
My readings let me think that webgl can’t launch another webgl, i would know if it is true or not.
And if it is not, is it possible to call the webgl from an html page with javascript.
Thank you by advance with any clue you can provide
Have a nice day
so both my players spawn in the scene, but neither of them can move? both have a network transform, a camera, a network identity, and the player controller script. im not sure what the problem is, and im not getting any errors. https://pastebin.com/J8ghkXwS is the code, can someone help?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Hi, what is the best networking (asset) solution for an RPG multiplayer game ?
There's Photon but that has a limit of 20 CCU for free, or Mirror and MLAPI which you host yourself or allow clients to be hosts
I know that I'm crazy but: I want to create a massive MMORPG, even if I have to work like 5 years.
MLAPI is pretty new, but it's Unity's new solution and to be fair I am enjoying it
And my problem for now is: I don't have any Networking knowledge.
I think in games dev, scope is a struggle
Yep, but is in beta now, i think
Like, maybe start with a smaller networked game if you're new
Because networking adds a whole level of complexity to things
Yep, I watched for 3 days tutorials on YouTube, and somebody suggested me to go with UE4 instead of UNITY
That has always been an argument, personally I prefer Unity because I prefer C# to C++ or Blueprints
aaand that's my reason too
Plus as a programmer, UE4's fancy lighting never appealed to me
But, Unity is getting better
photon quantum probably what you need.
if you want to spend 5 years this is a good place to start https://www.gafferongames.com/
hey are there any good examples on github of a unity game made using only c# udp sockets?
i want to learn and eventually make something w/o unet, thanks
my player prefab got corrupted, and I had to make a new one - for some reason I thought the way to set it was just dragging the prefab into where it says default player prefab.. am I missing something?
https://www.youtube.com/channel/UCa-mDKzV5MW_BXjSDRqqHUw This guy did a whole series of C# networking tutorials
mlapi btw 🙂
Yeah I thought you just dragged it on too...
grmbl maybe it took a hit when my player prefab ate dirt
can't do anything to the current box
yeesh today's been nasty, couple more bugs like this, and its on to the next unity project to start again lol
boo, same thing with a new network manager, guess ill re-import mlapi and make a bug report 😛
is 0.1.0 still the newest?
@olive vessel ty i saw that guy
i was trying to find a github repo or something that only used udp though, i tried looking at quake source code but its too complicated so ive been looking for something smaller/ learning focused
According to my package manager, yes
i was trying to do this stuff awhile back but ended up just doing a simple platformer and im gonna give it another shot
tbh im surprised everyone isnt all over mlapi - when I heard the announcement earlier this year, I marked it on my calendar, and was downloading it as soon as I could figure out how 😛
seems like a lukewarm reception
Honestly, me too
I didn't want to use Mirror, I'm sure Mirror is excellent but I wanted an actual Unity thing
Hi all, I'm using free Photon asset and following this tutorial to set up multiplayer for my game https://www.youtube.com/watch?v=l2ybEFWHsz8
I can Create Room without any problems but face problems with Join Room... it is supposed to create a new room with the text from the Input but I get this error whenever I try: "JoinOrCreateRoom failed. A roomname is required. If you don't know one, how will you join?"
This is my code: https://wtools.io/paste-code/b4Lg
Any help would be appreciated.
I was waiting for an official something that would be supported long term, to try and learn how to make something multiplayer - I am reasonably pleased with mlapi, it does what I need, mostly
Good point, my bad!
Don't worry, this channel isn't used too much really
like if theres more stuff like this itd be a godsend https://github.com/maciejspychala/sdl-game
if u guys have any id appreciate it
Honestly, that one by Tom Weiland was the best socket tutorial I have seen for Unity
I did do some looking round
i think he explains stuff well but i want to see a whole project u feel me?
and i want to stay away from using tcp aswell
[Package Manager Window] Unable to add package [https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi.git?path=/com.unity.multiplayer.mlapi#release/0.1.0 ]:
Cannot checkout repository [https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi.git] on target path [com.unity.multiplayer.mlapi]:
Error when executing git command. fatal: invalid reference: release/0.1.0
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()```
I wonder if maybe it isnt 0.1.0 but they havent updated the tutorial yet
grmbl
ah, no, wait, this is a problem on my end
I remember now, I had to manually install it the first time
Fixed up my message. Please, if anyone has worked with Photon before and knows the fix, let me know! This is for a uni project and this is my last hurdle until I submit it on Wednesday 😄
reinstalling mlapi fixed the bug:
Is there a specific line it dislikes?
dunno if worth making a bug report - how to duplicate, corrupt your player prefab so it's still there but missing all its contents and is totally broken, the network manager will follow suit
Nope, it doesnt mention any specific line. Full error reads:
JoinOrCreateRoom failed. A roomname is required. If you don't know one, how will you join?
UnityEngine.Debug:LogError(Object)
PhotonNetwork:JoinOrCreateRoom(String, RoomOptions, TypedLobby, String[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1845)
PhotonNetwork:JoinOrCreateRoom(String, RoomOptions, TypedLobby) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1806)
MenuController:JoinGame() (at Assets/MenuController.cs:67)
UnityEngine.EventSystems.EventSystem:Update() (at /Applications/Unity/Hub/Editor/2019.4.14f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
hmm not sure, this is the code with roomOptions bit
public void JoinGame()
{
RoomOptions roomOptions = new RoomOptions();
roomOptions.MaxPlayers = 5;
PhotonNetwork.JoinOrCreateRoom(JoinGameInput.text, roomOptions, TypedLobby.Default);
}
(this is line 67 btw)
PhotonNetwork.JoinOrCreateRoom(JoinGameInput.text, roomOptions, TypedLobby.Default);
Ok so the JoinGameInput.text is the room name
If that is ever blank, I assume it will get upset
to make it clearer: the join room button should join an already created room with the text from CreateGameInput, otherwise, if there is no room with that name, it should create a new room with the JoinGameInput text
yes, tried that just now. it got upset.. poor thing
I'm not overly sure, but I would guess that the text is blank and so it throws an error
hm, it gives me that error even when it isn't blank
Just before you do the join, Debug.Log the text
Just to check it is actually being passed through
😮 somehow it started working
thanks for your help @olive vessel ... Unity can be strange!
I often think strange forces mess with my scripts
can someone explain why my chat is only working locally https://pastebin.com/ZGPxA1Ba
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
(also posted on the photon server)
im using pun 2 btw
I don't have experience with Photon, but please don't use GameObject.Find in update...
i remember i had this issue a while ago so i think i fixed it
#archived-networking message
yeah i know i was just lazy
I feel like I'm missing something really obvious here, but, using MLAPI I have two custom classes (BattleGroup, which has a name, and an array of UnitDeployment, and UnitDeployment, which has a name and a string array of equipped items). Sending a battlegroup with unit deployments through a server/client rpc doens't work, it only receives the name. However, I can send a single or array of unit deployment through an rpc. I have both classes setup to use INetworkSerializable, and arrays of UnitDeployment are working as expected when sending on their own, so I seem to be missing something for it to properly work when serializing as part of the BattleGroup class.
I've attempted to iterate over the list and call .NetworkSerialize on each item, and I've tried to serialize the array directly, but when attempting to serialize directly I get an error about not being able to use non nullable type UnitDeployment[].
Does anyone have some thoughts or directions I could look in? This isn't hugely detrimental to the project, but if I'm just doing something wrong, I'd like to figure it out
Well, in case anyone has a similar issue, it turns out I had to read the portion of the conditional serialization on the INetworkSerializable page closer where it discusses serializing arrays. My original assumption was it only pertained to primitive types but that solved my problem!
Bad call.
Was just an issue with my request.
Application.OpenURL is perfectly fine to launch a webgl from an other webgl.
Hello there ! Is unity a good engine to make a MMORPG ? I know some tutorials said that its not..but I wanna make sure. Thanks !
I don't see why you can't make an MMORPG in Unity, I think at the end of the day, engine choice is somewhat down to personal preference
It's great for most MMORPG projects, as most people who start such projects pretty soon realize how much work it will actually take and move on to projects that are very suitable for Unity. 😛
Scope is often an issue
I know I tried a few years ago to make a multiplayer game, but at that time Networking Package wasnt that stable
And I also had issues when tried to connect 2 different devices to the game in LAN
I've been using MLAPI recently, it's good to be fair
MLAPI ?
Unity has a new networking solution called MLAPI
Also, if you have a nice tutorial explaining how to make a multiplayer game (MMORPG), it would be great to post it here 🙂 Already followed Brackey's
Oh, that's nice
MLAPI won't allow you to achieve the first M in MMO
It is very hard to publish a mmo, tutorials you 've seen warned you for a reason
oftentimes it's a combination of multiple techs in the stack, so usually the answer is NO, Unity on itself won't allow you to make ALL parts of your MMO, and also if you ask it probably means you're not ready for it
So in a nutshell, every MMO is a custom implementation, but nothing prevents Unity from being part of it
Hey,guys.Im new to learning MLAPI.I'm trying to use functionServerRpc().But it only can work in host mode.But not in client mode.Why?
ServerRpcs are called on the Server
I followed pun docs and basic tutorial but i have a problem in leaving the room for some season the leave room button works but when the health is < 0 and i cell the leave room method i have this error
but It says can be invoked by a client
If I wanna the server call the client method.What is the best way?
A ClientRpc can be invoked by the server to be executed on a client.
Is that what you're thinking of?
Yup
I'm confused.
I have 2 robots.The host can shoot.But client cannot
If the client cannot invoke ServerRpc.How to make it works?
Put your scripts in a paste site and show us
I am new to unity and networking what would be the best solution for unity networking
I'm new as well. I am learning MlAPI
ok thx ill read up on it maybe we can learn together 🙂
@umbral hare 😁
How to make the client method be executed on server in MLAPI
Anyone who know it?I'm stuck in that problem
Move the input.GetButtonDown check out of the RPC. What you want to do is have the client check for inputs and then send the RPC.
put !isClient
but make sure you have the networked behavior
instead of monobehavior
How do you guys go about serializing the snapshot every tick to send to the clients?
json utility is behaving so slow for me
Benchmark tests indicate that JsonUtility is significantly faster than popular .NET JSON solutions, even though this class provides fewer features in some cases. Straight from the docs
bit packing, but that can be difficult to learn. i'd start with serializing yourself to bytes.
put your info into a struct, give it a serialize/deserialize function that converts each member to bytes and adds it to an array
Is it going to be a lot faster?
it's a lot of unnecessary data tho, like brackets and type names
meanwhile the actual data may fit into a single byte
So wait, does C# have built-in methods that will turn my objects into bits, and bits back into objects?
BitConverter, BinaryReader/Writer
Ok
i think a good combo is MemoryStream + BinaryReader/Writer
When I start a client. All the methods doesnt work.I'm sure it's out of the Rpc
When I start a host.It can call all the mothods,But clients cannot
@slim ridge I'm very stuck. I looked up tutorials for memorystream and binaryreader for serializing objects but there's very few of them. Do I literally have to go through each value in my class's list and feed it to the memorystream?
yeah
yikes I was just hoping to feed it a single object
but alright I guess thats doable
byte[] txBuffer = new byte[1024];
MemoryStream txStream = new MemoryStream(txBuffer, 0, 1024);
BinaryWriter txWriter = new BinaryWriter(txStream);
txWriter.Write(value);
...
...
...
it's not so bad if your data isn't a mess.
you basically have to make the objects able to serialize themselves
mainClass.h.Code = 1;
mainClass.h.Length = 2;
mainClass.a = 3;
mainClass.b = new int[100];
mainClass.c = new int[100];
using (MemoryStream ms = new MemoryStream())
{
using (BinaryWriter sw = new BinaryWriter(ms))
{
sw.Write(mainClass.h.Code);
sw.Write(mainClass.h.Length);
sw.Write(mainClass.a);
foreach (int b in mainClass.b)
sw.Write(b);
foreach (int c in mainClass.c)
sw.Write(c);
sw.Flush();
}
}```
This is an example I found online
that I've been using
is this correct?
yep, then all you have to do is read it in the same order on the other end
and it will be an object again?
or do I literally have to re-insert every item into the list again
for each object
well, you create the object, pass it the stream, let it read it's values 👍
Ok
im sure if you look hard enough you can find libraries that make this easier
i use interfaces. IDeserialize, ISerialize
that implement a function taking a reader/writer
then it's all in one place so you dont make mistakes and your socket code only has to use the interface
This should be loads faster than doing unity's json serialization right? That's pretty much the only reason I'm doing this
it may not be as fast as you expect, but it'll certainly save bandwidth
I'm only looking to save CPU time
bit packing is the same thing except taking the data and using algorithms to fit it into as few bits as possible 🥴
I might just dump the json method into a background thread and be done with it 🤣
if I'm not gonna see that big of CPU improvements
every character in JSON is basically an unsigned short's worth of data (2 bytes)
this should reduce the amount of data by a lot if your objects are big
and thus the amount of time spend reading/writing
I still cannot invoke method in clients 😦
I can see the client player move in host view but nothing debug in client
Don’t you want a ClientRpc?
It's all well and good posting that, but what are Client(); and Host(); ?
If you want debugging help, you must show full scripts
See if the transport you use, can select a different port
The error you have says port 7777 is being used
It executed twice Host(). I am thinking of that by pressing Enter key, auto-create a server if there's no server created ,and auto-join if there's already server created. So the issue is after I created a host in one game,then I started another game which ought to create client,but "Ishost" is false that client() cannot be executed.
Hi, I try to stay logged in to Unity with connecting google account. I found https://firebase.google.com/docs/auth/unity/manage-users#get_the_currently_signed-in_user this website and try to use AuthStateChanged(object, System.EventArgs). The question is how to use and I'm not quite sure I found the correct function to do this. Could somebody help me with this problem?
It's been a while since I kept up with unity. Do they have a good multiplayer solution yet, or are photon/mirror still the best options?
They have a new solution called MLAPI
Hey quick questions what would be the best way to move around 100+ entitys at once from Server -> Client
currently i loop over all the entitys and check if they should move -> put them in a new list -> loop over them where i send the new position to client until destination is reached
Would it make sense to use PUN to have a game playable by other people, and push updates while developing, as a cheap way to get alpha testers?
but i feel like this is a wrong approach and i am missing something
you can fit the state of all of the objects into one message first
further messages only need to communicate the differences from the last message
or at least a new message with all the state in it
but if it works and stays within your bandwidth requirements there's no reason to optimize it
has anyone had any trouble importing the photon real time package? When I import it using git URL I get these error messages
Package name 'https://github.com/Unity-Technologies/mlapi-community-contributions/tree/master/Transports/com.mlapi.contrib.transport.photon-realtime' is invalid. [InvalidParameter].See console for more details```
and
```Error adding package: https://github.com/Unity-Technologies/mlapi-community-contributions/tree/master/Transports/com.mlapi.contrib.transport.photon-realtime.
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()```
sorry, its the photon transport
I had trouble using GIT for the community Transports, I ended up just downloading the ZIP
well that was easy, thank you so much!
Took me longer than I care to admit to get them
Took me all day, asking for help was my last resort haha
Anyone who knows some open project about MLAPI
The most I know about customisation, is that you can write your own Transport
Oh you wanted a project using MLAPI
Unity released their "Boss Room" sample:
https://blogs.unity3d.com/2021/04/08/enter-the-boss-room-our-new-multiplayer-sample-game/
Thx a loooooooot 🙂
Interesting. How feature complete and stable is it? And what about tutorials/documentation? Can it do whatever photon/mirror can
Well obviously Photon is a bit different to both MLAPI and Mirror, for those two you have to host your own dedicated servers, or allow players to be hosts. The documentation site is pretty good and it being new means a few people have started series using it on YouTube, but if you really need help the MLAPI Discord is a good place for answers.
I'm actually looking to start learning networking. I had initially planned to follow a series on bolt, but I though I'd check up here on the feasibility of Unity's own solution
Well, Bolt is just a visual scripting system
I think he is referring to Photon BOLT
Yeah. I should have clarified
I don't think MLAPI offers the stuff Photon Bolt or Photon Fusion are offering, certainly not what Photon Quantum is.
Though I recall Unity promising RTS, FPS and Fighting game networking solutions 🤓
I see the most tutorials for photon bolt and PUN, and of those bolt looks easier, so I'll stick to it. Quantum looks interesting, but I haven't really done ECS much. Never heard of fusion though
Thanks for the advice
Photon Fusion is described to be PUN 3 and Photon Bolt 2 combined into one (minus WebGL), but it's not out yet
Public beta soon™️
Hm. I like photon quantum a lot from what it seems to be, but I don't really have money, nor am I aiming to make anything professional quality
Maybe if they removed all the nonzero digits I could afford it
My understanding is that they offer rev share deals, though I imagine it shouldn't be your first rodeo in that case
That would be applicable on the assumption I actually had revenue
Erick from ExitGames made this about Photon Fusion https://www.youtube.com/watch?v=MfEbjFH3Zwo [Hello Fusion FPS]
Odds are figuring out their ECS setup is a lot less headache than getting the same networking quality while rolling your own solution.
That looks pretty interesting. But I have no knowledge of networking and I'd rather start with an older tool that has tutorials to "hold my hand along the way" as it may be
@spring crane Fusion does not use any ECS setup or similar btw
It's standard gameobjects/monobehaviour/etc.
Thanks for the correction
Hi, I am relatively new to networking with unity and I would love to do something like a multiplayer platformer. I have followed the MLAPI tutorial that unity provided and it worked well, and I wanted to start off with something simple so I decided to do a 1 dimensional simple test. However, as I implemented my idea into the code, stuff just went wrong: The client's movements are buggy but the host can move smoothly; it happens that the client will receive one error at the start of the connection saying "Only the owner can invoke a ServerRpc that requires ownership".
Here are my scripts:
ControlPlayer.cs : The script that will be attached on the NetworkObject
using MLAPI;
using MLAPI.Messaging;
using MLAPI.NetworkVariable;
using UnityEngine;
public class ControlPlayer : NetworkBehaviour
{
public float speed;
public NetworkVariableVector2 Position = new NetworkVariableVector2(new NetworkVariableSettings
{
WritePermission = NetworkVariablePermission.ServerOnly,
ReadPermission = NetworkVariablePermission.Everyone
});
public override void NetworkStart()
{
if (NetworkManager.Singleton.IsServer)
{
Position.Value = Vector2.zero;
}
else
{
SubmitPositionRequestServerRpc(Vector2.zero);
}
}
public void Move(Vector2 translateVector)
{
if (NetworkManager.Singleton.IsServer)
{
Position.Value += translateVector;
}
else
{
SubmitPositionRequestServerRpc(Position.Value + translateVector);
}
}
[ServerRpc]
void SubmitPositionRequestServerRpc(Vector2 finalPos)
{
Position.Value = finalPos;
}
void Update()
{
transform.position = Position.Value;
}
}
ControlManager.cs : The script that will be attached on the NetworkManager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
public class ControlManager : MonoBehaviour
{
void OnGUI()
{
GUILayout.BeginArea(new Rect(10, 10, 300, 300));
if (!NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)
{
StartButtons();
}
else
{
StatusLabels();
}
GUILayout.EndArea();
}
static void StartButtons()
{
if (GUILayout.Button("Host")) NetworkManager.Singleton.StartHost();
if (GUILayout.Button("Client")) NetworkManager.Singleton.StartClient();
if (GUILayout.Button("Server")) NetworkManager.Singleton.StartServer();
}
static void StatusLabels()
{
var mode = NetworkManager.Singleton.IsHost ?
"Host" : NetworkManager.Singleton.IsServer ? "Server" : "Client";
GUILayout.Label("Transport: " +
NetworkManager.Singleton.NetworkConfig.NetworkTransport.GetType().Name);
GUILayout.Label("Mode: " + mode);
}
private void Update()
{
if (NetworkManager.Singleton.ConnectedClients.TryGetValue(NetworkManager.Singleton.LocalClientId,
out var networkedClient))
{
var player = networkedClient.PlayerObject.GetComponent<ControlPlayer>();
if (player)
{
float xAxis = Input.GetAxisRaw("Horizontal");
player.Move(new Vector2(xAxis * Time.deltaTime * player.speed, 0));
}
}
}
}
Any help will be appreciated, thanks!
I'm new as well 😂 Maybe we can learn together
U can try attach the script containing ServerRpc to NetworkPrefab
pretty sure i did that
let me double check just to confirm
Yeah here is the prefab and the script
I think the issue on my hand is that I have totally no idea how to manage inputs for a client and also a host
U can add if(islocalplayer) in your scripts
roger that
What would be the best solution to use for fps multiplayer
Hey folks, are there any special stipulations with the WebGL build system that would cause an app to not be able to reach the network? I have a plugin that tries to initialize with a service I'm workihg with that is fast and such (via HTTPS) when run natively but seems not to connect at all via the WebGL build. 😕
OK, so the network manager is gone now. I got a feeling I'm going to have to figure out how to get websockets opened up via MLAPI
yay
Do NetworkVariable<T> work with say a list of custom type? something like NetworkVariable<List<SomeClass>>?
Does*
I do
NetworkVariable<List<SomeClass>>.Value = new List<SomeClass>();
from the server when my game starts but when a client connects NetworkVariable<List<SomeClass>>.Value is null
I can't seem to find what am I doing wrong :/
anyone been using MLAPI? how would you rate it against something like Photon or Mirror?
I asked a similar question here @north wing. Maybe this answers your question?
Can one of the big brain networking guys tell me how long my networking code on the server, should take to execute every tick, in milliseconds?
Right now I'm doing about 0.5-0.7ms of script execution for my whole networking logic for 10 players on the server every tick
I feel like that's way too slow and that I'm going to run into problems later on
I'm really stressing over this so I'll appreciate any feedback
It's completely server authoritative, btw.
I feel like this is why some bigger games run lower tickrates like 10-30, so they have lots of time to execute logic in between ticks.
0.7ms for the entire game, or just 0.7ms for replicating/networking stuff for 10 objects on the server?
0.5-0.7ms can be great or really bad, depending on exactly what you are measuring
As of right now, that's just handling character controller based movement for all players connected
yikes
I'm doing 50hz
... why?
I'm not sure to be honest, I guess it's just because its the default fixedupdate right
rate*
its a pretty weird non/standard update rate
common ones are like 1, 10, 20, 30, 32, 60, 64, 120, 128
but w/e works i suppose
nothing "bad" with it per ce i suppose
just a bit odd
_StoredData_ConnectedPlayer[i].CharacterController.Move(move * 0.2f);```
This is the chunk of code thats slowing me down
when I remove it, it basically cuts execution time in half, if not more
¯_(ツ)_/¯
But like you were saying, I have a specific amount of milliseconds in between ticks, in this case 20ms. So technically I'll be fine as long as all of my code executes within that time frame?
yes
Also consider that if you can use a lot less than those 20ms, you can technically spin more than one instance per core on server VMs, and that is one of the points: cut server costs...
If hosting with players machines, you have to account for slower cpus, etc... So always nice to try to cut down these times as much as possible
You're absolutely right, I'm just not sure how to optimize this any more. All of my lookups are optimized with dictionaries too. Literally been scraping away at any possible optimizations for the past few days.
@teal obsidian if you have a 10 player game
you have to expect to run 3-4 instances of the game
per core
if it's to be a dedicated server hosted game
for it to be feasible
I'm planning on around 60. I just used 10 for my tests so far.
okey, then one game per core is feasible
I don't mind lowering the tickrate, which seems like the most plausible way of getting this to work in the long run.
a common tick rate for higher player count games is 30 or 32 hz
but im not sure i would consider 60 players high enough to think it's justified to lower it to 30/32hz
Well, it's going to be 60 players + cars with wheel colliders
and probably a couple hundred entities
that should be easily doable within 20ms or 16.67ms imho
wait hang on, this might be my shitty spherecheck code
Ok, totally removed my spherecheck that was used for gravity. Doing 20 players at around 0.7ms now
does that sound at all within what I should be aiming for?
even depends on how you are testing this
IL2CPP on a CPU with which specs, etc?
win/linux, etc?
make sure it's a release or master unity build as well, etc
ok, so for editor, depending on the specs this looks ok
it's single CPU that is being used
yep
0.7 is a bit high, but unity cc tests with these low numbers (20) may be just a lot of overhead)
Test all 60
I'm hitting my CPU cap at around 20
try IL2cpp build... Use a stopwatch....
clients
Don't run clients
can't use IL2CPP either, because my serialization library doesn't support it.
Just check the CC code running 60 "npcs" moving around
well, that is bad
IL2CPP is basically the best thing since sliced bread on Unity-land
It technically does support it, but you have to do a bunch of code generation stuff
I just haven't gotten that far yet
We don't even support live games with Mono with our stuff, for example
Will it enhance the code for say, the character controller?
il2cpp can be 4x faster for the C# parts
Arguably the physx internals will not speed up much though
probably not a lot, just the c# parts
alright. Well I need to sleep, so I'll definitely run some build tests tomorrow and let you know how that goes.
sure... you're testing nicely, you know what to do now
Can I use MLAPI to host a game on internet so players all around the world can connect?
Yeah
Uh, ok
And do you know any tutorial explaining this ? Everything I found explained how to create host / client (a.k.a. basics)
MessagePack, right? IIRC it was relatively trivial to setup for IL2CPP.
If you want external connections you just need to port forward
Or you can use a relay thingy, but I don't know owt about them
IMHO MessagePack really is not good for networking games
how i can make a online 2d game without server?
Let the players be a host?
How so? Performance seems to be fine.
slow, uses tons of bandwidth
Anything better you can recommend?
I'd rather not write my own serialization, rather just use something straightforward that lets me pack up objects to send over a network
^ That's all of the fixedupdate logic for the server with charactercontroller.move being called for every player for every tick, with 30 players connected
^ That is again 30 players but without charactercontroller.move being called.
With charactercontroller.move, server uses about 4-6% CPU, without it, uses about 3-5%.
It idles on the lower side.
All I'm using is C#'s built-in stopwatch. Starts at the top of fixedupdate() and ends at the bottom. The code that handles my player movement and such, is called during fixedupdate.
So apparently this is a known issue :/
I guess the only option is to just take the performance hit and lower the tickrate if needed.
Seems less like an "issue" and really just the reality of a robust character controller. Sounds like a customized one would be much more efficient than the unity one, which makes sense as they want to cover a million possibilities
I really don't think I could make a better character controller than the nvidia engineers
seems pretty barebones after all.
I dunno, nvidia has never made a game 😛 They're good with GPUs
So lets just go ahead and call it 2-3ms for all of the player movement code for 60 players. Then I still need to be able to spawn in cars for each player (worst case) with 4 wheel colliders each. Those are also known to eat up CPU
It's also worth noting that my 6700k is clocked to 4ghz, but hyperthreading is enabled, so the server is technically running on a 2ghz core
hyperthreading doesn't really work like that
I mean its known to shit on single threaded performance
If I'm not mistaken, it literally just splits each core in half.
It's way more sophisticated than that, check some benchmarks or run your own comparison. In pure single threaded tasks nowadays it practically loses no performance because it regonizes this
It's worst in multithreaded systems that load balance across cores very well, generally better than HT could do with a less sophisticated way of distributing your app
But still only takes like a 20% hit in worst-cases from what I've seen
Interesting
Also I see above you're testing while running in the editor? The editor killlllls your perf
And not only does it kill performance, it doesn't do it in a reliable predictable way
So running your game from the editor isn't necessarily the same as just running it on a crappier machine
The editor features will slow down lots of code paths that won't be slow in your finished build. Hiding some of your real performance problems
The screenshots I posted are build tests
server builds
using stopwatch to measure time
It didn't seem to make much of a difference tbh
I hate making assumptions like this, but the developer of Rust have the default tick rate set at 10. I know for a fact they use physx wheel colliders on their cars so I'm wondering if maybe they use the default character controller too
and have the tick so low because of the performance impacts of it
I have no idea really though
because their player counts go up to like 300+ per server
It really depends on your type of game. From the comparison it's a large world survival game with vehicles?
Rust has helicopters, boats, cars, all rigidbodies
They very likely are not running a full character controller on the server, doesn't rust have really bad cheating issues?
Also are you sure they use things like wheel colliders and the stock character controller?
Only played a couple hours of rust a long time ago, wish I remembered it better
Not really my genre. But I'd still imagine maybe their vehicles aren't a very detailed simulation?
Having used Rust vehicles, they are definitely not
not a detailed simulation? Or you mean I'm wrong
Sorry end of workday and getting that brainfog 😛
The cars always seemed hard to control, and the helicopter blades are fine with going through walls
Ah yeah gotcha. Honestly there isn't much reason to. A "gamey" vehicle controller is lighter on the CPU and typically more fun if it's not a simulation game for that type of thing
Absolutely
The cars are hard to control, because its hard to do prediction with physx. It's just entity interpolated from the server
same with helicopters, etc
the wheels they use pretty much mimic physx wheel colliders including suspension and everything, and given the size of the dev team, they most likely don't make their own wheels, especially since they just use standard physx rigidbodies.
just assumptions though
In the blogs though, they do specifically mention using rigidbodies for the vehicles.
Anyways back to the main topic, I think that the character controller and wheel colliders might be where most of my CPU time is being spent every tick, so hopefully that's the end of my problems after that
I would probably be more worried about the GC.Collect hitting.
made a cross-platform physics game using lockstep, fixed point math and a custom physics engine 😛
@grave ice How much slower is that than using floating point math?
@teal obsidian the lib i use is written in C# and its unoptimized and very slow in comparison to floats
Wouldn't it be much faster to just use physx on the server, and have it echo the positions of every entity to the other clients
I thought lockstep wasn't really used anymore
@teal obsidian I'm doing a turnbased game so because I use lockstep I only network the inputs
@teal obsidian it can operate with super high ping but more importantly bandwidth does not grow in proportion to number of networked objects
if you do it the way you describe then bandwidth does grow proportionally with number of net objects
Interesting
@teal obsidian thats why lockstep deterministic setups with rollback are the best solution, no lag + great bandwidth use (think cod and other games)
I have a question.The bullets I instaniate in other clients by ClientRpc method dont call OnCollisionEnter() method
Why?
The problem is the bullet that instantiate didnt call OnCollisionEnter() when hitting client2
So how would you go about doing player movement in a first person shooter if you were running a 10hz tickrate?
I've tried running movement code in fixedupdate at 10hz and it was incredibly choppy, even with a good amount of interpolation.
Maybe I'm just doing something wrong
Hello there !
I am getting this compile error, can someone help me ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
using MLAPI.Messaging;
public class PlayerShooting : NetworkedBehaviour
{
public TrailRenderer bulletTrail;
public Transform gunBarrel;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (IsLocalPlayer)
{
if (Input.GetButtonDown("Fire1"))
{
ShootServerRpc();
}
}
}
[ServerRpc]
void ShootServerRpc()
{
}
[ClientRpc]
void ShootClientRpc()
{
}
}
I have these two :
using MLAPI;
using MLAPI.Messaging;
This is what tutorial guy used
Nothing
Do you have intellisense?

Nothing
Although this suggests it's MLAPI.Messaging, which you already have
https://mp-docs.dl.it.unity3d.com/docs/mlapi-api/MLAPI.Messaging.ServerRpcAttribute/index.html
Marks a method as ServerRpc.
The only difference between my code and tutorial guy's code is
I have
public class PlayerShooting : NetworkedBehaviour
And he has
public class PlayerShooting : NetworkBehaviour
But If I write NetworkBehaviour, another error pops
I used Networked for other scripts and i though it would work
This is his code
What error do you get if you make it NetworkBehaviour?
1 sec
The type or namespace name 'NetworkBehaviour' could not be found (are you missing a using directive or an assembly reference?)
Because everything I can see says it should be that, not "Networked"
using MLAPI.Messaging;
using MLAPI.NetworkVariable;
using UnityEngine;```
From https://docs-multiplayer.unity3d.com/docs/tutorials/helloworldtwo
This guide follows on from the work completed in Your First Networking Game "Hello World". You should complete that guide before starting this one.
May be worth stepping through that tutorial to make sure everything's set up correctly? https://docs-multiplayer.unity3d.com/docs/tutorials/helloworldintro
This "Hello World" guide walks you through creating a project, installing the MLAPI package, and creating the basic components for your first networked game.
Not sure how, because none of the documentation says that's a thing!
NetworkBehaviour is an abstract class that derives from MonoBehaviour and is the base class all your networked scripts should derive from. Each NetworkBehaviour is owned by a NetworkObject.
Ah, it looks like you're using an old implementation of MLAPI potentially.
NetworkedBehaviour is in the legacy documentation
I installed the newest version
What version of it do you have? Should be able to see in the package manager
Yeah sounds like there'll be a few things to fix in your code if you had things working on the old version
Assets\Scripts\ButtonManager.cs(4,7): error CS0246: The type or namespace name 'MLAPI' could not be found (are you missing a using directive or an assembly reference?)
lol
really lol
You might need to regenerate your project files
No, 2 secs I'll get you a screenshot. Just firing up Unity

Close your code editor, then in Unity > Preferences
Then re-open your script. Hopefully that will sort it
What are you using to edit scripts?
You need to do all that
Part of that is setting your IDE in Unity, which will give you the regenerate option
It'll also give you intellisense for Unity methods etc. and compilation error highlighting in VS
Oh that link was going to MacOS, this is the Windows one https://docs.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/getting-started-with-visual-studio-tools-for-unity?pivots=windows#configure-unity-to-use-visual-studio
Close VS, click regenerate, double click your script in Unity and make sure it opens VS for you
Have you installed the Unity game development pack in VS?
It's in that setup document, go through each step in there
Once Visual Studio is selected in the External Script Editor list, confirm that the Editor Attaching checkbox is selected.
I dont have this box
Should I update unity or smth ?
I think that might be a Pro thing only - allows you to attach Unity to VS for debugging. You should be OK without it.
Yeah. Might need a restart of Unity too, just to be safe
Ok, so regenerate then restart unity
Either way, shouldn't matter
Paste the error and relevant script?
There are 11 errors 😄
lol ok screenshot them
OK, paste your ButtonManager code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
public class ButtonManager : MonoBehaviour
{
public GameObject menuPanel;
public void Host()
{
NetworkingManager.Singleton.StartHost();
menuPanel.SetActive(false);
}
public void Join()
{
NetworkingManager.Singleton.StartClient();
menuPanel.SetActive(false);
}
}
That's inheriting MonoBehaviour but using network components
Actually yeah that shouldn't matter, it still can't find MLAPI as a namespace
What version of Unity are you using?
2020.1.5f1
Maybe try updating that? You can have a new version installed alongside, and backup your project before upgrading the version it uses
Are you using .asmdef files in your project?
No
Wait a second
I installed 0.1.0 MLAPI
All my components such as NetworkManager, NetworkObject are gone
And cannot add them
Can you post the full stack trace?
What ? 🙂
If you click on the error message it will show more information in the console.
Error adding package: https://github.com/Unity-Technologies/mlapi-community-contributions.git?path=/com.unity.multiplayer.mlapi-patcher.
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
This error happens for every git package
Do you have git installed?
For unity ?
Yeah we are still an experimental package. Will get much easier once we release.
Don't forget to restart your machine after installing.
Oh
I suggest following the migration guide exactly point by point. Else you can run into some ugly issues.
So I have to restart my pc
Brb then
Back
So now adding package with git should work
Woaaah
from 11 to 2 errors
😄
Thanks
But now
NetworkingManager.Singleton.StartClient();
NetworkingManager is broken
And same for MLAPI components
They are gone 
I can only repeat what I said so far. Start with a clean v12 project. Follow the steps in the upgrade guide. Then your components won't be broken.
If I usr MLAPI , am I supposed to use photon, too ? For a MMOROG
Transport is your choice
Can I do online leaderboard for free in unity game if yes plz tell me how or if no what is the cost plz need help guys
U need dedicated server?
In the MLAPI transport I chose unet
Should work fine, right ?
🤷♂️ idk what you need from a Transport
:D
If you're making your own MMORPG, you should probably make your own
So you've fallen into the trap of scope then
If it's your first multiplayer game, I doubt you should try and make a big MMORPG game
Multiplayer pong could be cute

Do you mean LAN as in hot seating?
I can create a host a join with 2 or more clients in my network
So the game is multiplayer then
Sorry when you were asking about Transports, I thought you were just beginning to make it multiplayer
Did you ever get that working? I'm currently trying to communicate from a Unity desktop build to a Unity WebGL build. Any thoughts?
yeah, webGL builds do not support typical networking like Unity does with the other platforms. https://docs.unity3d.com/Manual/webgl-networking.html
you can use WWW and UnityWebRequest, maybe even MLAPI (the new Unity Networking) but I've not seen anything about it supporting WebGL. 🤷
You can do relatively typical networking through WebSockets. MLAPI's websocket transport is currently broken
PUN and Mirror for example handle it fine
My sadness is that the project I'm running on is relying on an external .NET plugin that relies on the System libraries. Therefore, for me, this scenario is the end of the road (for the WebGL option)
I was told to use Socket.IO or SignalR or WebRTC ... but almost all of those require a client side server or proxy server. I'm literally just trying to send a single string every second or so from a desktop Unity build to a WebGL build and that's it
Seems overkill to set up an entire server and all this other stuff just to send a single string
I'm looking into WebRTC now but almost everything that does stuff with it has some super expensive Unity Store Asset plugin. Just want something quick and cheap ><
I feel ya buddy. It's an onion problem (with every layer you peel you cry all the more)
Yeah, I got communication from someone else's game to my desktop build... just want to now send that data to my WebGL build
best of luck and happy Friday 🙂
Oh yeah, today is Friday... time doesn't seem to exist anymore as an indie dev + pandemic 😛
Thanks though, I've found a few other workarounds but not exactly what I'm looking for. If anyone else has any thoughts or ideas, tag me... thanks 😄
I ve trying to work with photon and someone told me to use rpc to sync my raycast gun can someone tel me more about it i dont really understand it
Does NetworkVariable<T> work with say a list of custom type? something like NetworkVariable<List<SomeClass>>?
I create a new list on the server when the game starts like so
NetworkVariable<List<SomeClass>>.Value = new List<SomeClass>();
but when a client connects NetworkVariable<List<SomeClass>>.Value is null
this should work right? If not, what is the best way to make a networkvariable list?
sorry, I create the new list like so
myList.Value = new List<SomeClass>();
NetworkVariable only works for serializable types https://docs-multiplayer.unity3d.com/docs/advanced-topics/serialization/serialization-intro
There is NetworkList if you need a networked list.
Thanks!
Has anyone seen any content explaining how to run a MLAPI server and client simultaneously during development?
So when a client connects I get this error:
[MLAPI] NetworkReader cannot find the NetworkBehaviour sent in the SpawnedObjects list, it may have been destroyed. networkObjectId: 4
And this is the game object with newtworkId: 4
The Network Team script in that game object inherits from NetworkBehaviour
And the client read the network variable as if it was empty
but in the server it shows the real values:
Is it has something to do with m_NetworkBehaviour being null?
If you want a way to do that without creating a build each time have a look at ParrelSync or UnityProjectCloner
Can you share a screenshot of the NetworkVariables in the NetworkTeam script?
@verbal lodge thanks. ParrelSync looks like what I need. 👍
here
So when my player reloads his weapon, how should the server determine when the reload has finished?
the server wouldn't run animations right?
depends on the game @teal obsidian
I mean, just in general
If you are doing a fps/shooter then yes server runs animations
alright
It's required for hit detection on the server
So then what if my player predicts the reload animation, and then the reload packet to the server gets lost in transit
Depending on timings, etc.
that might mean you have a correction
and game glitches for client
Ok
can someone help me with colour, i want it change like a name tag to green but its only client, can someone help me?
photon im using
Does anyone know the proper way to rotate the player with a character controller when using client prediction?
I currently send the users mousex and calculate the rotation for the server and client at a certain tick (in fixedupdate) but this is not always that smooth.
But if I rotate the player in Update() and send its rotation to the server at a given tick and let the server calculate the rotation still using the mousex for that same tick then the predictions gets out of sync really quickly.
How to deal with onColliosionEnter in Mirror
I am making a tennis game, when a player(collider) will collide the ball (network prefab), it will be pushed toward target,
but, the problem I am facing is that, it only works for server instance, the result in other clients is pretty crazy
I have a problem, my network manager in mainmenu (used to host and join games) goes to don't destroy on load and becomes unasigned to my script
Odds are the network manager is a singleton of some sort. What networking solution are you using?
Mirror
Yea pretty sure it's a singleton
did anyone have problem when migrating to MLAPI 0.1.0 ?
I followed the intructions and i get this
From the original MLAPI?
Yes
I haven't done it, but it seems like you have both in the same project?