#archived-networking

1 messages · Page 98 of 1

weak plinth
#

Any tips on this?

tough umbra
#

Lobby is coming along nicely new to photon

pseudo adder
#

@tough umbra you still there?

tough umbra
#

@pseudo adder I am now, how can I help

patent fog
#

Hey Erick, it's a shame audio cuts some words :/

gleaming prawn
#

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.

patent fog
#

👍

pseudo adder
#

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

rustic magnet
#

@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.

pseudo adder
#

ok

weak ferry
#

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.
tough umbra
#

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

weak ferry
#

I don't think that's it.

tough umbra
#

So your just trying to create a room, because i don't see anything that attempts to create the room.

weak ferry
#

Wait nevermind.

#

I'm not doing the multiplayer thing anymore. Might do in the future.

tough umbra
#

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

leaden robin
#

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?

tough umbra
#

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

foggy blaze
#

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?

patent fog
#

Maybe check if "Run In Background" is enabled ?

foggy blaze
#

well that was fast and it worked. thanks a lot!

frigid moss
#

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)?

analog oar
#

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?

patent fog
#

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.

arctic iris
#

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

}```
weak plinth
#

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.

graceful zephyr
#

@weak plinth you want to learn to code multiplayer from scratch yourself? Or use existing library

weak plinth
#

I'd be okay with using a library

#

as long as there was documentation

graceful zephyr
#

Then find a library that’s decent and learn that

weak plinth
#

any recommendations?

agile mica
#

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.

flat quartz
#

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

civic acorn
#

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

slim ridge
#

you can use .NET's socket stuff

civic acorn
left knoll
patent fog
#

This is the initial experimental **Unity **MLAPI Package, v0.1.0.

patent fog
#

Rewrite history like nothing happened

verbal lodge
#

It's because of Unity package naming conventions. Since MLAPI is now an experimental package we are following naming conventions.

flat quartz
odd island
#

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

flat quartz
#

There are also another couple examples of people doing it on youtube if you search

muted trench
#

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

muted trench
#

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

weak plinth
#

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

spring linden
#

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

spring linden
#

or maybe just a study buddy for a bit to help me get comfortable

flat quartz
#

@weak plinth Have you tried inheriting from MonoBehaviour as well as MonoBehariourPunCallbacks?

public class NetworkController : MonoBehaviour, MonoBehariourPunCallbacks

lapis scaffold
lapis scaffold
#

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...

mental lark
#

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

spring crane
#

Some setup their project to duplicate in 2 locations on disk so you can have 2 editor instances open

verbal lodge
#

There are some tools for this around like ParrelSync or UnityProjectCloner.

atomic vector
#

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!

novel locust
jade glacier
#

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.

agile field
#

Anyone had experience implementing agora video chat in unity multiplayer using photon?

solid crow
#

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

gleaming prawn
#

@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)

median flame
#

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...

gleaming prawn
#

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

raven spire
#

How to send a unity web request on local files, in editor ? what should be the the url ?

sleek blade
#

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?

haughty heart
#

@weak plinth Collaboration posts belong on the Unity forums, links are pinned in #💻┃unity-talk.

gleaming prawn
#

Assuming this is like a rest api. No need for an intermediate server, it’s unnecessary complexity.

sleek blade
#

Thanks for the reply. Yeah it's a REST API. Agree with the unnecessary complexity

undone raptor
#

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'

patent fog
#

everything you need can be easily extracted from the CURL command you sent, good luck, ask more questions if stuck 👍

north estuary
#

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)

slim ridge
#

what's on PhotonNetwork.cs line 1037?

#

all the github repos i can find have nothing on that line

north estuary
#

lol someone alreayd resolved my problem. hes my new guardian angel

#

turns out photon didnt import correctly

#

so i just had to reimport

honest zephyr
#

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

junior moat
#

has anyone did anything with the new MLAPI stuff?

grim bramble
#

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?

stiff ridge
# grim bramble Hi there! I am trying to place my spawned object as a parent of an object that i...

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.

slim wadi
#

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

undone raptor
neat totem
#

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?

somber drum
#

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

thorny gale
#

Any idea how to spawn player in MLAPI?

grim bramble
patent fog
weak plinth
#

whenever i press "host game" i get this error, why? im using the latest version and photon bolt

weak plinth
#

Hi, does photon free support 20 players at once or 20 players per server/host?

spring crane
#

20 players globally at the same time

weak plinth
#

Oh ok

#

Thanks

worn tulip
#

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.

olive vessel
worn tulip
#

@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?

thorny gale
hollow raven
#

So why does the NetworkTransform not sync scale 🤔

olive vessel
#

I assume you could use an RPC to send the scale to all clients?

graceful zephyr
#

Cos scale is seldom used

#

And when it’s used it almost never changes

slow lantern
#

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?

weak plinth
#

..Can we sync dictionary<Key,Value> using Photon pun 2.?.. if yes, then how??:/

opal kite
#

I like how this server instantly deletes my questions. Great feature.

spring crane
#

Consider using Discord's markdown features

opal kite
#

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.

opaque oracle
#

What documentation? Unity? Photon? when you delete something from the host you also have to tell the clients you deleted it @opal kite

opal kite
#

When Mirror destroys the game object on the server, it also destroys it on the clients

opaque oracle
#

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

opal kite
#

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.

slim ridge
#

you're using NetworkServer.Destroy?

opal kite
#

it appears so

arctic iris
#

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");

}```

lavish spindle
#

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

final pagoda
#

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

latent horizon
#

Any chance it's a firewall/security software blocking Unity?

final pagoda
#

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

latent horizon
#

That's what made me think something's blocking it, because the symptom sounds fairly arbitrary otherwise

final pagoda
#

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?

latent horizon
#

I was going to move to the computer shortly; drop some code and I can try it if it's just some generic calls

final pagoda
#

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); 
            }
latent horizon
#

Ok. Gimme like 5-10

final pagoda
#

👍

latent horizon
#

@final pagoda All success here

final pagoda
#

Maybe a router issue, but why would that only occur in unity

latent horizon
#

Yeah, I dunno

final pagoda
#

Or an issue with the project somehow. Gotta test it fresh I guess

latent horizon
#

I'm using 2020.3.4 on a Mac, I imagine the Mac part at least adds another variable

final pagoda
#

Yeah, and the 2020.3 part

#

I’m on 2021.0f1

#

Guess I’ll do some more testing

latent horizon
#

You would think this wouldn't be very dependent on Unity itself though since it's just straight .Net stuff

#

Pretty weird problem

final pagoda
#

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

latent horizon
#

I don't have a PC or Linux machine to try on

final pagoda
#

I’ll get a couple others to try it if I can

final pagoda
#

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

latent horizon
#

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.

final pagoda
#

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

latent horizon
#

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

final pagoda
#

Sounds like the behaviour I'd expect

latent horizon
#

But, it doesn't fail at the NETWORK level, the Send API raises an exception

final pagoda
#

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

latent horizon
#

That is really weird

final pagoda
proven belfry
#

Guys

worn tulip
#

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]

olive vessel
#

I guess it will eventually just timeout?

worn tulip
#

@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

deft vector
#

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.
olive vessel
#

Just a thought, but don't you want to check if you are the local player in update?

deft vector
#

I don't understand why check if is it the local player ?

olive vessel
#

Well if each player has this script, and you have 4 players, won't the script run 4 times when 1 player presses F2?

deft vector
#

No, because I deactivate the script of other players for each instances

olive vessel
#

Well you didn't mention that, idk what the problem is but you could ask in the Mirror Discord

deft vector
#

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.

umbral hare
#

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

white plinth
#

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?

civic acorn
#

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?

clear night
#

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

civic acorn
#

Anyone have ideas on how to get something like TcpListener to work in WebGL? If that's even possible?

olive vessel
#

I don't know if you can do that, Mirror has a WebSockets transport

graceful zephyr
#

Yeah can't do that, need to use a custom websocket setup

sonic marsh
#

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

grim bramble
#

Hi there! Can anyone help me with Photon RPC functions?

weak plinth
#

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);
    } 
}```
olive vessel
#

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?

weak plinth
mystic orchid
#

If i want to connect unity to my Postgresql database do i need to implement it as a rest API and use the API?

patent fog
#

yeah this or maybe someone did a csharp-postresql lib on github 🤷‍♂️

white plinth
#

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?

bronze rivet
#

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

olive vessel
#

Otherwise you could just allow P2P games

verbal island
olive vessel
#

I'm not sure about that honestly

verbal lodge
#

It does not.

bronze rivet
#

No it is just multiplayer for uni

#

So 20 is fine I think

olive vessel
#

Ahh yeah, I doubt you'd need more

bronze rivet
#

Maybe in future

#

For basic 20 is fine

#

It will not be relased soon just some closed beta😂

#

Or I will just enable p2p

verbal island
#

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

olive vessel
#

How do you do movement?

verbal island
#

I have a Move() function in a Player script on the Player Prefab. The Move() function is inside FixedUpdate

olive vessel
#

I don't know if fixedupdate could be affecting it, but when you mentioned rubber banding I thought you'd done server authoritative movement

verbal island
#

would having server authoritative movement fix the issue?

olive vessel
#

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

white plinth
#

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?

verbal island
olive vessel
#

Have you tried it in Update instead?

verbal island
# olive vessel 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.

olive vessel
verbal island
#

Mirror

olive vessel
#

You could try asking people in there, they might have some ideas

verbal island
rough grotto
white plinth
#

damn it okay. Thanks @rough grotto

rough grotto
#

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

white plinth
#

so there is no way for me to have multiple people on the network but in different scenes?

olive vessel
#

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

white plinth
#

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.

deft vector
#

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

grim bramble
#

How can i reduce lag between players? i have two simple players and when one moves it lags like alot!

verbal island
#

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?

dense notch
verbal island
olive vessel
#

Oh I should probably mention, "players" is a NetworkList of a custom struct

dense notch
#

@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.

olive vessel
#

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

verbal lodge
#

ListUpdated should be

   {
       // your logic
   }
sonic garden
#

Hi there guys! Could anybody be so kind and explain how to connect (using mirror) to a hosted game via internet?

prisma warren
#

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

proven belfry
#

Can i ask questions thats releated to mlapi here?

olive vessel
#

Aye, or in the MLAPI Discord

proven belfry
#

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?

dense notch
#

@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.

white plinth
#

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?

white plinth
#

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.

white plinth
#

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

proven belfry
#

@dense notch thank you for help 🤍

grim bloom
#

Does anyone know if MLAPI supports html5 builds? I tried a test build earlier today and it threw a bunch of mlapi errors..

scarlet lily
#

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)

olive vessel
grim bloom
olive vessel
#

I'm not 100% sure myself, but I know Mirror has a dedicated Websockets transport

fervent slate
#

Is this the channel for making multiplayer thing

olive vessel
#

Yep, welcome to Networking

spring crane
#

I would expect MLAPI to support all Unity platforms until proven otherwise. Websocket support is generally the core for compatibility with browser networking.

grim bloom
spring crane
#

Could share the errors. First thing to try is to build for desktop.

grim bloom
#

building for desktop works, I'll try a web build again tomorrow and collect the errors

spring crane
#

Quick search for websocket mentions seems to suggest that UNet transport is used for websocket support

grim bloom
#

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!

verbal lodge
#

MLAPI does currently not support websocket. The UNet transport has some issue which prevents it from working.

grim bloom
#

ah, excellent, I'll let someone who is paid figure it out then 😄

verbal island
#

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.

grim bloom
#

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

verbal island
#

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

grim bloom
#

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

white plinth
#

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

verbal island
#

@grim bloom no worries, thanks, I will try to figure something out with client ID

teal obsidian
#

@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

prisma warren
#

Thanks for the ideas, players won't be able to join if the game is already in progress so that's no issue

tame urchin
#

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

weak plinth
#

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?

ocean sequoia
#

Hi, what is the best networking (asset) solution for an RPG multiplayer game ?

olive vessel
#

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

ocean sequoia
olive vessel
#

MLAPI is pretty new, but it's Unity's new solution and to be fair I am enjoying it

ocean sequoia
#

And my problem for now is: I don't have any Networking knowledge.

olive vessel
#

I think in games dev, scope is a struggle

ocean sequoia
olive vessel
#

Like, maybe start with a smaller networked game if you're new

#

Because networking adds a whole level of complexity to things

ocean sequoia
olive vessel
#

That has always been an argument, personally I prefer Unity because I prefer C# to C++ or Blueprints

olive vessel
#

Plus as a programmer, UE4's fancy lighting never appealed to me

#

But, Unity is getting better

slim ridge
weak plinth
#

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

grim bloom
#

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?

grim bloom
#

mlapi btw 🙂

olive vessel
#

Yeah I thought you just dragged it on too...

grim bloom
#

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?

weak plinth
#

@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

olive vessel
weak plinth
#

i was trying to do this stuff awhile back but ended up just doing a simple platformer and im gonna give it another shot

grim bloom
#

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

olive vessel
#

Honestly, me too

#

I didn't want to use Mirror, I'm sure Mirror is excellent but I wanted an actual Unity thing

upper harness
#

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.

olive vessel
#

Wow hello code

#

Y'all heard of paste sites?

grim bloom
#

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

upper harness
olive vessel
#

Don't worry, this channel isn't used too much really

weak plinth
#

if u guys have any id appreciate it

olive vessel
#

Honestly, that one by Tom Weiland was the best socket tutorial I have seen for Unity

#

I did do some looking round

weak plinth
#

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

grim bloom
#
[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

upper harness
grim bloom
#

reinstalling mlapi fixed the bug:

olive vessel
grim bloom
#

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

upper harness
# olive vessel Is there a specific line it dislikes?

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)

olive vessel
#

MenuController line 67

#

Does RoomOptions take in a name?

upper harness
#

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);
olive vessel
#

Ok so the JoinGameInput.text is the room name

#

If that is ever blank, I assume it will get upset

upper harness
#

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

upper harness
olive vessel
#

I'm not overly sure, but I would guess that the text is blank and so it throws an error

upper harness
#

hm, it gives me that error even when it isn't blank

olive vessel
#

Just before you do the join, Debug.Log the text

#

Just to check it is actually being passed through

upper harness
#

😮 somehow it started working

#

thanks for your help @olive vessel ... Unity can be strange!

olive vessel
#

I often think strange forces mess with my scripts

sleek laurel
#

(also posted on the photon server)

#

im using pun 2 btw

olive vessel
#

I don't have experience with Photon, but please don't use GameObject.Find in update...

sleek laurel
abstract compass
#

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

abstract compass
#

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!

tame urchin
weak plinth
#

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 !

olive vessel
#

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

spring crane
#

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. 😛

olive vessel
#

Scope is often an issue

weak plinth
#

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

olive vessel
#

I've been using MLAPI recently, it's good to be fair

weak plinth
#

MLAPI ?

olive vessel
#

Unity has a new networking solution called MLAPI

weak plinth
#

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

weak plinth
patent fog
#

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

spare tapir
#

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?

olive vessel
#

ServerRpcs are called on the Server

mental lark
#

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

spare tapir
#

but It says can be invoked by a client

#

If I wanna the server call the client method.What is the best way?

olive vessel
#

Is that what you're thinking of?

spare tapir
#

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?

olive vessel
#

Put your scripts in a paste site and show us

spare tapir
#

How do I make the client method to be executed on server?

umbral hare
#

I am new to unity and networking what would be the best solution for unity networking

spare tapir
umbral hare
spare tapir
#

@umbral hare 😁

spare tapir
#

How to make the client method be executed on server in MLAPI

spare tapir
#

Anyone who know it?I'm stuck in that problem

verbal lodge
#

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.

umbral hare
#

but make sure you have the networked behavior

#

instead of monobehavior

teal obsidian
#

How do you guys go about serializing the snapshot every tick to send to the clients?

#

json utility is behaving so slow for me

teal obsidian
#

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

slim ridge
#

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

teal obsidian
#

Is it going to be a lot faster?

slim ridge
#

it's a lot of unnecessary data tho, like brackets and type names

#

meanwhile the actual data may fit into a single byte

teal obsidian
#

So wait, does C# have built-in methods that will turn my objects into bits, and bits back into objects?

slim ridge
#

BitConverter, BinaryReader/Writer

teal obsidian
#

Ok

slim ridge
#

i think a good combo is MemoryStream + BinaryReader/Writer

spare tapir
spare tapir
#

When I start a host.It can call all the mothods,But clients cannot

teal obsidian
#

@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?

slim ridge
#

yeah

teal obsidian
#

yikes I was just hoping to feed it a single object

#

but alright I guess thats doable

slim ridge
#
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

teal obsidian
#
   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?

slim ridge
#

yep, then all you have to do is read it in the same order on the other end

teal obsidian
#

and it will be an object again?

#

or do I literally have to re-insert every item into the list again

#

for each object

slim ridge
#

well, you create the object, pass it the stream, let it read it's values 👍

teal obsidian
#

Ok

slim ridge
#

im sure if you look hard enough you can find libraries that make this easier

teal obsidian
#

I hate libraries

#

I'll probably figure it out

slim ridge
#

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

teal obsidian
#

This should be loads faster than doing unity's json serialization right? That's pretty much the only reason I'm doing this

slim ridge
#

it may not be as fast as you expect, but it'll certainly save bandwidth

teal obsidian
#

I'm only looking to save CPU time

slim ridge
#

bit packing is the same thing except taking the data and using algorithms to fit it into as few bits as possible 🥴

teal obsidian
#

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

slim ridge
#

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

teal obsidian
#

hmmm

#

alright

spare tapir
#

I still cannot invoke method in clients 😦

#

I can see the client player move in host view but nothing debug in client

olive vessel
#

Don’t you want a ClientRpc?

spare tapir
olive vessel
#

It's all well and good posting that, but what are Client(); and Host(); ?

#

If you want debugging help, you must show full scripts

spare tapir
#

Ohh,sorry,I forgot that

olive vessel
#

See if the transport you use, can select a different port

#

The error you have says port 7777 is being used

spare tapir
# olive vessel 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.

weak plinth
prisma hollow
#

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?

olive vessel
#

They have a new solution called MLAPI

weak plinth
#

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

grand sundial
#

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?

weak plinth
#

but i feel like this is a wrong approach and i am missing something

slim ridge
#

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

wide hull
#

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

olive vessel
#

I had trouble using GIT for the community Transports, I ended up just downloading the ZIP

wide hull
#

well that was easy, thank you so much!

olive vessel
#

Took me longer than I care to admit to get them

wide hull
#

Took me all day, asking for help was my last resort haha

spare tapir
#

Anyone who knows some open project about MLAPI

olive vessel
#

The most I know about customisation, is that you can write your own Transport

#

Oh you wanted a project using MLAPI

spare tapir
prisma hollow
olive vessel
prisma hollow
#

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

olive vessel
#

Well, Bolt is just a visual scripting system

harsh dew
#

I think he is referring to Photon BOLT

prisma hollow
#

Yeah. I should have clarified

spring crane
#

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 🤓

prisma hollow
#

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

spring crane
#

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™️

prisma hollow
#

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

spring crane
#

My understanding is that they offer rev share deals, though I imagine it shouldn't be your first rodeo in that case

prisma hollow
#

That would be applicable on the assumption I actually had revenue

spring crane
#

Odds are figuring out their ECS setup is a lot less headache than getting the same networking quality while rolling your own solution.

prisma hollow
#

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

graceful zephyr
#

@spring crane Fusion does not use any ECS setup or similar btw

#

It's standard gameobjects/monobehaviour/etc.

spring crane
#

Thanks for the correction

graceful zephyr
#

quantum has its own ECS/etc. though

#

So easy to mix them up

mental geode
#

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!

spare tapir
#

I'm new as well 😂 Maybe we can learn together

#

U can try attach the script containing ServerRpc to NetworkPrefab

mental geode
#

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

spare tapir
#

U can add if(islocalplayer) in your scripts

mental geode
#

roger that

umbral hare
#

What would be the best solution to use for fps multiplayer

carmine hearth
#

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. 😕

carmine hearth
#

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

wide hull
#

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 :/

north wing
#

anyone been using MLAPI? how would you rate it against something like Photon or Mirror?

prisma hollow
teal obsidian
#

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.

graceful zephyr
#

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

teal obsidian
graceful zephyr
#

0.7ms for just moving the CC?

#

that is slow yes

teal obsidian
#

yikes

graceful zephyr
#

i mean 60hz

#

u have 1/60 = 16.67ms

teal obsidian
#

I'm doing 50hz

graceful zephyr
#

... why?

teal obsidian
#

I'm not sure to be honest, I guess it's just because its the default fixedupdate right

#

rate*

graceful zephyr
#

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

teal obsidian
#

                            _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

graceful zephyr
#

¯_(ツ)_/¯

teal obsidian
#

It's literally only executed once per tick, once per player

#

so I dont know either

graceful zephyr
#

havent used the unity CC in a long time

#

so i have no idea sorry

teal obsidian
#

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?

graceful zephyr
#

yes

gleaming prawn
teal obsidian
#

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.

graceful zephyr
#

@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

teal obsidian
#

I'm planning on around 60. I just used 10 for my tests so far.

graceful zephyr
#

okey, then one game per core is feasible

teal obsidian
#

I don't mind lowering the tickrate, which seems like the most plausible way of getting this to work in the long run.

graceful zephyr
#

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

teal obsidian
#

Well, it's going to be 60 players + cars with wheel colliders

#

and probably a couple hundred entities

graceful zephyr
#

that should be easily doable within 20ms or 16.67ms imho

teal obsidian
#

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?

gleaming prawn
#

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

teal obsidian
#

I've only been testing in the editor

#

on windows.

gleaming prawn
#

ok, so for editor, depending on the specs this looks ok

teal obsidian
#

6700k with hyperthreading

#

so technically a 2ghz processor

gleaming prawn
#

it's single CPU that is being used

teal obsidian
#

yep

gleaming prawn
#

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

teal obsidian
#

I'm hitting my CPU cap at around 20

gleaming prawn
#

try IL2cpp build... Use a stopwatch....

teal obsidian
#

clients

gleaming prawn
#

Don't run clients

teal obsidian
#

can't use IL2CPP either, because my serialization library doesn't support it.

gleaming prawn
#

Just check the CC code running 60 "npcs" moving around

gleaming prawn
#

IL2CPP is basically the best thing since sliced bread on Unity-land

teal obsidian
#

It technically does support it, but you have to do a bunch of code generation stuff

#

I just haven't gotten that far yet

gleaming prawn
#

We don't even support live games with Mono with our stuff, for example

teal obsidian
#

Will it enhance the code for say, the character controller?

gleaming prawn
#

il2cpp can be 4x faster for the C# parts

#

Arguably the physx internals will not speed up much though

gleaming prawn
teal obsidian
#

alright. Well I need to sleep, so I'll definitely run some build tests tomorrow and let you know how that goes.

gleaming prawn
#

sure... you're testing nicely, you know what to do now

weak plinth
#

Can I use MLAPI to host a game on internet so players all around the world can connect?

olive vessel
#

Yeah

weak plinth
#

Uh, ok

#

And do you know any tutorial explaining this ? Everything I found explained how to create host / client (a.k.a. basics)

spring crane
olive vessel
#

Or you can use a relay thingy, but I don't know owt about them

graceful zephyr
#

IMHO MessagePack really is not good for networking games

echo flower
#

how i can make a online 2d game without server?

olive vessel
#

Let the players be a host?

teal obsidian
graceful zephyr
#

slow, uses tons of bandwidth

teal obsidian
#

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

teal obsidian
#

^ 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.

teal obsidian
#

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.

bold quest
#

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

teal obsidian
#

I really don't think I could make a better character controller than the nvidia engineers

#

seems pretty barebones after all.

bold quest
#

I dunno, nvidia has never made a game 😛 They're good with GPUs

teal obsidian
#

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

bold quest
#

hyperthreading doesn't really work like that

teal obsidian
#

I mean its known to shit on single threaded performance

#

If I'm not mistaken, it literally just splits each core in half.

bold quest
#

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

teal obsidian
#

Interesting

bold quest
#

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

teal obsidian
#

The screenshots I posted are build tests

#

server builds

#

using stopwatch to measure time

bold quest
#

Ah okay, was just skimming the text above and saw something about in editor

#

my b

teal obsidian
#

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

bold quest
#

It really depends on your type of game. From the comparison it's a large world survival game with vehicles?

teal obsidian
#

Rust has helicopters, boats, cars, all rigidbodies

bold quest
#

They very likely are not running a full character controller on the server, doesn't rust have really bad cheating issues?

teal obsidian
#

hmmm

#

it does, but its mainly just aimbot

#

and wallhacks

#

not really preventable

bold quest
#

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?

olive vessel
#

Having used Rust vehicles, they are definitely not

bold quest
#

not a detailed simulation? Or you mean I'm wrong

#

Sorry end of workday and getting that brainfog 😛

olive vessel
#

The cars always seemed hard to control, and the helicopter blades are fine with going through walls

bold quest
#

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

olive vessel
#

Absolutely

teal obsidian
#

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.

teal obsidian
#

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

teal obsidian
#

Could these garbage collections be a possible culprit?

spring crane
#

I would probably be more worried about the GC.Collect hitting.

grave ice
#

made a cross-platform physics game using lockstep, fixed point math and a custom physics engine 😛

teal obsidian
#

@grave ice How much slower is that than using floating point math?

grave ice
#

@teal obsidian the lib i use is written in C# and its unoptimized and very slow in comparison to floats

teal obsidian
#

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

grave ice
#

@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

teal obsidian
#

Interesting

grave ice
#

@teal obsidian thats why lockstep deterministic setups with rollback are the best solution, no lag + great bandwidth use (think cod and other games)

spare tapir
#

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

teal obsidian
#

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

weak plinth
#

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()
    {

    }
}

wide widget
#

using something

#

you're probably missing that

weak plinth
#

I have these two :

using MLAPI;
using MLAPI.Messaging;

#

This is what tutorial guy used

wide widget
#

click on [ServerRpc]

#

and alt+enter

weak plinth
#

Nothing

wide widget
#

Do you have intellisense?

weak plinth
simple cave
#

ctrl + . in VS / VSC

#

Should suggest the namespace

weak plinth
#

Nothing

simple cave
weak plinth
#

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

simple cave
#

What error do you get if you make it NetworkBehaviour?

weak plinth
#

1 sec

#

The type or namespace name 'NetworkBehaviour' could not be found (are you missing a using directive or an assembly reference?)

simple cave
#

Because everything I can see says it should be that, not "Networked"

weak plinth
#

Network does not really work

#

Networked does, but fails few lines later

simple cave
#
using MLAPI.Messaging;
using MLAPI.NetworkVariable;
using UnityEngine;```
From https://docs-multiplayer.unity3d.com/docs/tutorials/helloworldtwo
weak plinth
#

I did

#

Other scripts are working perfect, even with Networked

simple cave
#

Not sure how, because none of the documentation says that's a thing!

weak plinth
#

I see

#

No networked here..

simple cave
#

Ah, it looks like you're using an old implementation of MLAPI potentially.

#

NetworkedBehaviour is in the legacy documentation

weak plinth
#

I installed the newest version

simple cave
#

What version of it do you have? Should be able to see in the package manager

weak plinth
#

1 sec

#

12.1.7

simple cave
#

Definitely MLAPI? Because apparently 0.1.0 is the current version 😛

weak plinth
#

I installed 0.1.0

#

And its worse 😄

simple cave
#

Yeah sounds like there'll be a few things to fix in your code if you had things working on the old version

weak plinth
#
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?)
simple cave
#

lol

weak plinth
#

really lol

simple cave
#

You might need to regenerate your project files

weak plinth
#

Aka reopen the project?

#

Or make a new one?

simple cave
#

No, 2 secs I'll get you a screenshot. Just firing up Unity

weak plinth
simple cave
#

Close your code editor, then in Unity > Preferences

#

Then re-open your script. Hopefully that will sort it

weak plinth
#

I think I have to update Unity first

simple cave
#

What are you using to edit scripts?

weak plinth
#

Visual Studio

#

2019

simple cave
#

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

weak plinth
#

Oh

#

Now I press regenerate

#

Should i close VS ?

simple cave
#

Close VS, click regenerate, double click your script in Unity and make sure it opens VS for you

weak plinth
#

Closed VS

#

Clicked regenerate

#

Errors are still there FeelsBadMan

simple cave
#

Have you installed the Unity game development pack in VS?

#

It's in that setup document, go through each step in there

weak plinth
#

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 ?

simple cave
#

I think that might be a Pro thing only - allows you to attach Unity to VS for debugging. You should be OK without it.

weak plinth
#

Cool

#

Regenerate, again ?

simple cave
#

Yeah. Might need a restart of Unity too, just to be safe

weak plinth
#

Ok, so regenerate then restart unity

simple cave
#

Either way, shouldn't matter

weak plinth
#

Waiting for unity to open

#

No changes

simple cave
#

Paste the error and relevant script?

weak plinth
#

There are 11 errors 😄

simple cave
#

lol ok screenshot them

weak plinth
simple cave
#

OK, paste your ButtonManager code

weak plinth
#
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);
    }
}

simple cave
#

That's inheriting MonoBehaviour but using network components

weak plinth
#

It worked tho

#

Tested it for 2 clients and worked

simple cave
#

Actually yeah that shouldn't matter, it still can't find MLAPI as a namespace

#

What version of Unity are you using?

weak plinth
#

2020.1.5f1

simple cave
#

Maybe try updating that? You can have a new version installed alongside, and backup your project before upgrading the version it uses

verbal lodge
#

Are you using .asmdef files in your project?

weak plinth
#

No

#

Wait a second

#

I installed 0.1.0 MLAPI

#

All my components such as NetworkManager, NetworkObject are gone

#

And cannot add them

verbal lodge
#

Did you follow the upgrade guide?

weak plinth
verbal lodge
#

Can you post the full stack trace?

weak plinth
#

What ? 🙂

verbal lodge
#

If you click on the error message it will show more information in the console.

weak plinth
weak plinth
verbal lodge
#

Do you have git installed?

weak plinth
#

For unity ?

weak plinth
#

Installing..

#

So much stuff to be done here I see 😄

#

Done, installed

verbal lodge
#

Yeah we are still an experimental package. Will get much easier once we release.

#

Don't forget to restart your machine after installing.

weak plinth
#

Oh

verbal lodge
#

I suggest following the migration guide exactly point by point. Else you can run into some ugly issues.

weak plinth
#

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 FeelsBadMan

verbal lodge
#

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.

weak plinth
#

Allright then

#

Thanks, Luke, SiJiL

weak plinth
#

If I usr MLAPI , am I supposed to use photon, too ? For a MMOROG

olive vessel
#

Transport is your choice

bronze rivet
#

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

olive vessel
#

You could... Google it

#

I doubt you'll find completely free

bronze rivet
#

U need dedicated server?

olive vessel
#

Depends how you do it

#

I saw a tutorial recently which used a SQL database

weak plinth
#

Should work fine, right ?

olive vessel
#

🤷‍♂️ idk what you need from a Transport

weak plinth
#

:D

olive vessel
#

If you're making your own MMORPG, you should probably make your own

weak plinth
#

it is my first multiplayer game, i am absolute 0 with MLAPI 😺

#

Deep words tho

olive vessel
#

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

weak plinth
#

Ihhh

#

Cant be that hard, I can already play in LAN 😸

olive vessel
#

?

#

That doesn't make sense

weak plinth
olive vessel
#

Do you mean LAN as in hot seating?

weak plinth
#

I can create a host a join with 2 or more clients in my network

olive vessel
#

So the game is multiplayer then

weak plinth
#

Yes.. MMORPG...MLAPI

#

😺

olive vessel
#

Sorry when you were asking about Transports, I thought you were just beginning to make it multiplayer

civic acorn
carmine hearth
#

you can use WWW and UnityWebRequest, maybe even MLAPI (the new Unity Networking) but I've not seen anything about it supporting WebGL. 🤷

spring crane
#

You can do relatively typical networking through WebSockets. MLAPI's websocket transport is currently broken

#

PUN and Mirror for example handle it fine

carmine hearth
#

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)

civic acorn
#

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 ><

carmine hearth
#

I feel ya buddy. It's an onion problem (with every layer you peel you cry all the more)

civic acorn
#

Yeah, I got communication from someone else's game to my desktop build... just want to now send that data to my WebGL build

carmine hearth
#

best of luck and happy Friday 🙂

civic acorn
#

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 😄

mental lark
#

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

wide hull
#

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>();

verbal lodge
wide hull
#

Thanks!

weak plinth
#

Has anyone seen any content explaining how to run a MLAPI server and client simultaneously during development?

wide hull
#

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?

verbal lodge
verbal lodge
weak plinth
#

@verbal lodge thanks. ParrelSync looks like what I need. 👍

teal obsidian
#

So when my player reloads his weapon, how should the server determine when the reload has finished?

#

the server wouldn't run animations right?

graceful zephyr
#

depends on the game @teal obsidian

teal obsidian
#

I mean, just in general

graceful zephyr
#

If you are doing a fps/shooter then yes server runs animations

teal obsidian
#

alright

graceful zephyr
#

It's required for hit detection on the server

teal obsidian
#

So then what if my player predicts the reload animation, and then the reload packet to the server gets lost in transit

graceful zephyr
#

Depending on timings, etc.

#

that might mean you have a correction

#

and game glitches for client

teal obsidian
#

Ok

weak plinth
#

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

soft palm
#

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.

thick forge
#

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

real hemlock
#

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

spring crane
#

Odds are the network manager is a singleton of some sort. What networking solution are you using?

real hemlock
#

Mirror

spring crane
#

Yea pretty sure it's a singleton

weak plinth
#

did anyone have problem when migrating to MLAPI 0.1.0 ?

#

I followed the intructions and i get this

spring crane
#

From the original MLAPI?

weak plinth
#

Yes

spring crane
#

I haven't done it, but it seems like you have both in the same project?