#archived-networking

1 messages · Page 104 of 1

stone goblet
#

"com.unity.multiplayer.mlapi": "0.1.0",

#

???

#

its correct

olive vessel
#

Do you know what a namespace is?

stone goblet
#

yes

olive vessel
#

I have no idea if that is how you install MLAPI, but if the rest of MLAPI works, just using the correct namespace for NetworkBehaviour

stone goblet
#

work!

#

thanks!

#

another error

#

if(!NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)

#

Object refence no set instance of an object

olive vessel
#

Is there a NetworkManager in your scene?

stone goblet
#

no

#

i beginner

#

and I repeat everything from the video

olive vessel
#

No

stone goblet
#

yes, no!

olive vessel
#

You are trying to access a NetworkManager, but you don't have one?

stone goblet
#

to be honest, I don't even know what I'm trying to access

#

hah

olive vessel
#

Are you totally beginner at Unity and C#?

stone goblet
#

no

#

im begginer in network

stone goblet
olive vessel
#

Ok well, follow the video properly

#

Because if you don't have a NetworkManager, you either missed a step, or haven't got to a step

#

Either way, you cannot access what doesn't exist, null reference

stone goblet
#

I have not missed anything

olive vessel
#

If NetworkManager.Singleton is giving you a NRE, you have missed something, don't try and argue the toss

stone goblet
olive vessel
#

Do you have an object with a NetworkManager?

stone goblet
#

4.30

#

5.40

olive vessel
#

Answer my question

stone goblet
#

ok

#

im russian

#

sorry

#

and use the google translator

stone goblet
#

how to add it

olive vessel
#

You do know this is a video series?

#

This was the installation guide, find the next video

stone goblet
#

ok

#

No..

#

in the next videos it's different

stone goblet
olive vessel
#

It's a component

stone goblet
#

щл

olive vessel
#

But find a different series if you don't like this one

stone goblet
#

ok

#

create empty object

#

and add component

#

???

olive vessel
#

Give it a go

stone goblet
#

???

stone goblet
olive vessel
#

Did I say NetworkObject or NetworkManager?

stone goblet
#

oh sorry

#

work

#

button

#

host

#

server

#

and client

#

but when i click on them nothing happens

#

Network transport

#

= None

#

but should i do

#

in video

#

its defined

olive vessel
#

Well there's only two options

stone goblet
#

workkk

#

!!!

#

i click to the UNET

#

transport

#

and this work

#

lol

#

it remains to add a network prefab

#

but how?

olive vessel
#

You should follow the tutorial I linked

river meteor
#

Lel

river meteor
#

Respect

olive vessel
river meteor
#

So you must be in very good mood today

stone goblet
#

Does anyone know how to test a networked game using unity itself without building the project

olive vessel
#

You have two Editors open, and one is mirrored to the other

cunning sluice
#

So for Pun2 I added a OnOwnerChange to a script, and a targetcallback in the awake and destroy but it still doesn't work
Is there something else I need to have it receive the event for when the objects owner changes?
Could it be I'm not inheriting from the right class?

spring crane
#

@cunning sluice Put the script up somewhere. The target callback addition stuff should do what inheriting used to.

cunning sluice
#
using Photon.Pun;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;

public class XRGrabNetworkInteractable : XRGrabInteractable, IOnPhotonViewOwnerChange
{

    private PhotonView photonView;
    private Rigidbody rBody;
    // Start is called before the first frame update

    

    void Start()
    {
        
        photonView = GetComponent<PhotonView>();
        rBody = GetComponent<Rigidbody>();
    }

    protected override void Awake()
    {
        PhotonNetwork.AddCallbackTarget(this);
        base.Awake();
    }

    protected override void OnDestroy()
    {
        PhotonNetwork.RemoveCallbackTarget(this);
        base.OnDestroy();
    }

    protected override void OnSelectEntered(XRBaseInteractor interactor)
    {
        photonView.RequestOwnership();
        rBody.isKinematic = true;
        gameObject.transform.parent = interactor.transform;
        if(!photonView.IsMine)
        {
            
        }
        base.OnSelectEntered(interactor);

    }
    protected override void OnSelectExited(XRBaseInteractor interactor)
    {
        if(photonView.IsMine)
        {
            rBody.isKinematic = false;
            gameObject.transform.parent = null;
            base.OnSelectExited(interactor);
        }

    }

    public void OnOwnerChange(Player newOwner, Player previousOwner)
    {
        print("Changed Owner");
        if (!photonView.IsMine)
        {
            Drop();
            print("This is not mine");
            if (!rBody.isKinematic)
                rBody.isKinematic = true;
        }

    }
}
#

Is it because I don't have the monobehaviourpun?

#

I'm about to try making a separate script inheriting from that

spring crane
#

@cunning sluice Looks like AddCallbackTarget might not cover that interface

#

Ah yes, that's a PhotonView callback, so instead of registering to PhotonNetwork, you register to the photonView instance

#

You might be looking for IPunOwnershipCallbacks?

#

Though I think the photonview specific one fits your usecase better

cunning sluice
spring crane
#

I wouldn't change that stuff, just change the CallbackTarget lines

#

Some callbacks are photonview specific, and some are.. network specific.

#

PhotonView callbacks should be added to the photonView instance, and not to PhotonNetwork

#

All classes implementing any PhotonView callbacks interfaces except IPunObservable must be registered and unregistered. Call photonView.AddCallbackTarget(this) and photonView.RemoveCallbackTarget(this).

cunning sluice
#

oh I see, and I was calling PhotonNetwork and not the photonView itself

#

so if I switch that up, it should receive the event correctly?

spring crane
#

Right

cunning sluice
#

ahhhhh

#

okay hopefully that works lol

#

this thing has been a pain in the butt since it's hard to test by myself

#

thank you

chilly vapor
#

hello guys

#

is there any production ready solution?

#

or i should use something like mirror or photon?

spring crane
#

MLAPI being at 0.1.0 implies that they don't think it's production ready.

chilly vapor
#

@spring crane do unity have any other solution except MLAPI?

spring crane
#

High level networking solutions for Monobehaviour, no.

#

I think they have a transport layer of some sort, but no idea what is the state of that, and I imagine you want something a bit more than just a transport layer

#

ECS has a networking solution of some kind, but no idea what the state of that is and you probably aren't going to be using ECS.

chilly vapor
#

yep, i'm coming from another engine, and having hard time struggling to pick the right networking solution

verbal lodge
#

Both MLAPI and the Unity Transport Package are still experimental.

chilly vapor
#

cuz i don't wanna just play around with it, i come to unity to remake my 2D game

#

so what is the top/best solution as for now?

cunning sluice
#

Well there are a lot of different frameworks that work fine

spring crane
cunning sluice
#

photon is pretty popular, and so is mirror

#

I think microsoft also has something

#

and epic games

chilly vapor
cunning sluice
#

yeah I believe so, I looked into it at one point

#

let me grab the links

spring crane
#

They likely have backend services and transport layers, I doubt they have high level frameworks for Unity

cunning sluice
#

and even though it's name brand

#

I don't believe they have as many resources as some of the other options

#

like mirror and photon

#

idk, danny knows way more than me on this stuff

#

I just started 2 weeks ago panda_sob

chilly vapor
#

ok, thanks much

cunning sluice
#

on multiplayer experiences anyways

chilly vapor
#

unity should make things more clearly-easier for beginners

#

the downside of that other game engine (i think i can't tell his name), is that don't care about 2D games

#

and the downside of unity is that don't care about beginners

#

most of my time is wasting to pick the right tools, instead of learning unity-coding-designing game

spring crane
#

Mentioning Unity's competition by name is fine 😄

chilly vapor
#

the problem with photon is CCU payment, and my game would be F2P and asking for support devs DLC

verbal lodge
#

What would you recommend we do to make it more clear to you?

chilly vapor
#

@verbal lodgeif unity can't give us a native networking solution, at least setup an official page where we can read about top/best current solutions and read those pros-cons

#

or something like it

verbal lodge
chilly vapor
#

ah, that's good, pls place it upfront of the unity page

#

or somewhere which we can find it more easily

mild salmon
#

What would be the best way to just send and receive data over two devices in Unity? I don't need replication or anything, just support for transferring data like audio files, etc

#

easy mode: devices are on the same network

ornate zinc
river meteor
spring crane
#

@river meteor I wouldn't worry about it. That guide is not a replacement for your own evaluation.

river meteor
#

yeah I know but Mirror is free

#

I dont know why but Photon Pun is not even listed in that decision making tree xD

#

I am also still worried about photon pun limitations for ex. number of declared RPC shortcuts

#

My project is at early stage so changing network API will not be much work

limber holly
#

hello, I have a basic question about PUN and RPC, when My first player spawn in the map, I have header with healthBar + nickName, when the scond player login, this player can't see the nickname and the Healthbar not updated for the other player too. Can I have advise for understand this mistake ? 🙂

river meteor
#

so any player dont see their correct values for nickname and health?

limber holly
#

they can see their own information, not other one

river meteor
#

okey

limber holly
#

same for the healthbar update

river meteor
#

You must sync these values and it is easy af

#

just inherit IPunObservable interface in your player class

#

then implkement the interface

#
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.IsWriting) // Here you are sending values to other clients. REMEMBER, all values must be readen then in the SAME OREDER as WRITTEN
{
stream.SendNext(nicknameValue);
stream.SendNext(healthValue);
}
else if (stream.IsReading)
{
this.nicknameValue = (string)stream.ReceiveNext();
this.healthValue = (int)stream.ReceiveNext(); // you must cast it to type which your values uses, so I dont know if your health is int or float or double...
}
}```
#

and thats it

#

it should work

limber holly
#

ok I read and try to understand this code; thanks so much

river meteor
#

If you will have any problem ping me I will try to help best I can

spring crane
river meteor
#

so what is paid in mirror?

spring crane
#

The opportunity cost of spending your time figuring out the replacements for PUNs matchmaking and relay server infra, not to mention that you still need to host these somewhere

river meteor
#

In small coop game listen server is the best solution I think... in this case still I need matchmaking and relay server infrastructure?

spring crane
#

Odds are your players are not going to open their own ports

#

It can also be nice to have rooms players can discover instead of passing IP addresses around

river meteor
cunning sluice
#

honestly could just use pun2

#

they have room sizes of 20 for free

#

I believe among us uses it

river meteor
#

I dont understand this pricing system at all

spring crane
#

Among Us doesn't use PUN specifically, just something very similar to it

chilly vapor
#

do pun2 allow for creating server scripts & networking? , creating master server for authoritative and player profile system?

#

or instead of aut match making, let players to create custom lobby, add/invite friend

#

as mirror give u full control over client and server, i'm sure i can create such these things with mirror, but running and managing relay server still need some works, which in pun2 u don't need to worry about

#

i don't know much about pun2, so if anyone tell me some of it`s strength over mirror, the only thing that i know is about auto managing relay servers

spring crane
#

In that case you might just grab realtime and their server instead of trying to hack PUN. I would ask in the Photon server to see what they suggest.

chilly vapor
#

that's mean more payment, while mirror give it for free

gleaming prawn
#

If you want authority in mirror you also need to pay for hosting unity servers. That won’t be cheap

#

So free is not really free

chilly vapor
#

nop

#

u can do it with relay servers

#

and anyway we need a master server

#

on mirror there isn't any force to use unity servers

#

but on photon, u have to use photon servers

limber holly
#

I really don't understand Why but when my second client instantiate the player, he instantiate the player + the player already in the game

atomic sierra
#

Hey guys, what networking solutions are you using? I don't need a 1:1 unet, infact I would like a more performance-optimized solution. I did have a go at Mirror not long ago, but it's unsatisfactory

#

To be more clear, I don't need RPC functionality, ideally I would like a more direct approach

#

I've had a look at ENet and it seems very promising and I am just mostly wondering if anyone else has had a good experience using it?

#

And also if there are other libraries that can perform like this

restive geode
#

With Mirror, how do you send microphone input over the network to be heard by other players?

limber holly
#

I think I have aproblem with this code:playerObj.GetComponent<PhotonView>().RPC("Initialize", RpcTarget.AllViaServer, PhotonNetwork.LocalPlayer);

chilly vapor
#

@atomic sierrawhat is ur problem with mirror? cuz u are looking for a p2p networking & NAT solution? (trying to avoid dedicated server)

#

or ur problem with mirror is something else?

#

and about Enet, as far as i know, none of unity solution are production ready, and there isn't any guaranteed to work well w/o any bug, and if u found a critical, u can't do anything

stone goblet
#

Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: Joining). Wait for callback: OnJoinedLobby or OnConnectedToMaster.

#

Photon error

robust sandal
#

Its in a empty gameobject in the map scene

limber holly
#

My problem is my public PlayerMain[] playerMain; is added well with my first player, but it doesn't works with the second... someone know why please ?

#

PlayersInGame's value also 1 with 2 clients

olive vessel
#

I don't see anywhere in that code where you add anything to that array

stone goblet
#

Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: Joining). Wait for callback: OnJoinedLobby or OnConnectedToMaster.

#

Help me please

#

Photon error

spring crane
#

Network operations are not instant. As the error says, the client needs to be in certain state to do certain things

spring crane
#

Or wait for those mentioned callbacks

#

Looks up those callback names for PUN documentation

stone goblet
stone goblet
spring crane
#

Either Joined or ConnectedToMaster by the looks of it

stone goblet
#

ok

#

i will try

stone goblet
spring crane
#

You should be able to find the info by looking it up. Could also study the samples provided with PUN

#

They have pretty extensive lobby samples

stone goblet
#

I am using the free version of the pun, the pun version documentation may differ from the free version

spring crane
#

It doesn't

stone goblet
empty lava
#

Hello so i am making a amultiplayer game and trying to show rooms in my find room fuction using prefabs that works but when clicking the room to join it i get this error

https://pastebin.com/6YF4BMgA

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Photon.Realtime;

public class RoomListItem : MonoBehaviour
{
    [SerializeField] TMP_Text text;

    public RoomInfo info;

    public void SetUp(RoomInfo _info)
    {
        info = _info;
        text.text = _info.Name;
    }

    public void OnClick()
    {
        Launcher.Instance.JoinnRoom(info);
    }
}

Got told to post it here

empty lava
#

Can anyone help

olive vessel
#

Do you have a Launcher in the Scene?

#

Is the singleton working correctly?

#

Did you misspell Joinn on purpose?

empty lava
olive vessel
#

Well you use the word Instance which is usually indicative of a Singleton Implementation

#

You'll need to show us the Launcher class

empty lava
olive vessel
#

Ok so you've tried to make a Singleton, but you forgot the most important part

#

You need to assign the static field to something

#

Usually in Awake, you'd run Instance = this; or something, people usually add checks here to ensure that they don't have two of the script in the Scene

empty lava
cobalt python
#

Hi! i am using photon. Why these gameobjects move a little when player that created it leaves? CleanupCacheOnLeave is False. And it only occurs on NonMaster clients

spring crane
#

I would check if something funny is sent through the transform sync

night cargo
#

Can anyone plz give me network movement code because my $tupid script isnt working

mint sundial
#

i need help about photonengine

#

I have such a ball it moves perfectly when the game creator hits it ,but when the others hit it it lags and comes back slightly ahead of the place before hitting it

#

pls help

dusky leaf
mint sundial
#

Are you talking about transform view?

#

im new on photon sorry

#

this ball components

#

this player s components

dusky leaf
#

its a static variable

#

you do this in code, preferrably on an Awake() function of a GameObject that's active from the start

#

PhotonNetwork.sendRate = 30;
PhotonNetwork.sendRateOnSerialize = 30;

mint sundial
#

on ball?

dusky leaf
#

actually

#

make a new gameobject in the scene

#

and make a new script

#

name it something like SetSendRate

#

attach the script to that gameobject

mint sundial
#

i understand

#

like gamemanager

dusky leaf
#

yeah

#

make a public field called sendRate and default it to 30

#

then make an Awake function with

PhotonNetwork.sendRate = 30;
PhotonNetwork.sendRateOnSerialize = 30;

mint sundial
#

i trying thx

#

@dusky leaf there is some improvement but not fixed ):

#

i think relevant lerp

#

transform view

cobalt python
mint sundial
#

yeahh yeah yeah @cobalt python

glacial galleon
#

Does anyone know how to use unet matchmaking in WebGL?

cobalt python
mint sundial
#

how can I do it

cobalt python
#

set owner field in PhotonView component of the ball to Takeover

#

and set in ball script:

void OnCollisionEnter(Collision contact)
    {
        if (!photonView.IsMine)
        {
            Transform collisionObjectRoot = contact.transform.root;
            if (collisionObjectRoot.CompareTag("Player") || collisionObjectRoot.CompareTag("OtherPlayer"))
            {
                //Transfer PhotonView of Rigidbody to our local player
                photonView.TransferOwnership(PhotonNetwork.LocalPlayer);
            }
        }
    }
cobalt python
mint sundial
#

thanks i will try it

cobalt python
mint sundial
#

@cobalt python All characters connected to playerfab, for example, the tag of the 1st player. Player, how can I set the tag of the 2nd player?

cobalt python
mint sundial
mint sundial
cobalt python
#

if you dont need it

mint sundial
#

@cobalt pythonlocalPlayer giving error

#

localPlayer is a gameobject?

cobalt python
mint sundial
#

no i dont have

cobalt python
mint sundial
#

does not accept

cobalt python
# mint sundial

try in Unity edit, preferences, external tools, regenerate project files

mint sundial
#

i do this

#

not worked ):

#

trying

#

@cobalt python not worked :((

cobalt python
mint sundial
#

@cobalt python in here?

cobalt python
mint sundial
#

ha okey

#

sorry i understand

#

@cobalt python

#

i mport this

#

they working but

#

i taking errors so much

#

importing again this

cobalt python
#

try to regenerate project files again

#

use pun2

mint sundial
#

all working

#

okey

#

only this not working

#

@cobalt python

#

is it localplayer?

#

so much errrooooooor

#

i taking photonrealtime errors

robust sandal
#

Why does this script not work

#

But this does

#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.UI;
using TMPro;

namespace Com.OcerGames.AirPVP
{
    public class Launcher : MonoBehaviourPunCallbacks
    {
        public Color loading;
        public Color connected;
        public TextMeshProUGUI connectionState;

        public void Awake()
        {
            PhotonNetwork.AutomaticallySyncScene = true;
            connectionState.color = loading;
            connectionState.text = "Loading...";
            Connect();
        }

        public override void OnConnectedToMaster()
        {
            //Join();
            connectionState.color = connected;
            connectionState.text = "Connected";

            base.OnConnectedToMaster();
        }

        public override void OnJoinedRoom()
        {
            StartGame();

            base.OnJoinedRoom();
        }

        public override void OnJoinRandomFailed(short returnCode, string message)
        {
            //Create();

            connectionState.color = loading;
            connectionState.text = "<b>ERROR:</b> Couldn't find populated room, try creating one yourself";

            base.OnJoinRandomFailed(returnCode, message);
        }

        public void Connect()
        {
            PhotonNetwork.GameVersion = "0.0.0";
            PhotonNetwork.ConnectUsingSettings();
        }

        public void Join()
        {
            PhotonNetwork.JoinRandomRoom();
        }

        public void Create()
        {
            PhotonNetwork.CreateRoom("");
        }

        public void StartGame()
        {
            if(PhotonNetwork.CurrentRoom.PlayerCount == 1)
            {
                PhotonNetwork.LoadLevel(1);
            }
        }
    }
}


#

In the first script, when trying to join a room created by someone else you instead join an empty room

mint sundial
#

i need go i will try thank you so much for everything

robust sandal
#

Im having a problem with this script

#

If i create a room in the Unity Editor and then try to join it throught he built version, i dont see the other player even appear in the editor but they joined their own room

#

Ive tried debugging and when trying to join a room the script doesnt even get to OnJoinedRoom

#

Everything broke when i tried to follow this video tutorial series https://youtu.be/VHdLauXAYZw?list=PL6PsTmPNvw0eZirNDjO8dL0Y6X0ZFGaMt

We learn how to set up our players' profiles in this one broh...

Follow Welton on Instagram: @welton.king.v

Join our Discord: https://discord.gg/vrErfxa

Catch up on Github: https://github.com/Kawaiisun/SimpleHostile

BFXR: https://www.bfxr.net/

Piskel App: https://www.piskelapp.com/

Audacity: https://www.audacityteam.org/

...

▶ Play video
#

It worked before and i didnt test it inbetween

#

Only before and after

#

Please @ me if anyone can help so i see any responses

spring crane
#

Make sure to check you are on the same region

limber holly
#

hello; I try to learn how create a launcher for log in my game but I have a problem: my first scene is the login panel + character selection. I have a login script (when I enter the correct informations, I can select a character) and a NetworkManager script for Connect my player to PUN server. Then with OnJoinedRoom I load My gameScene with GameManager script.

#

my first player can load the scene well with good information; my second client when I login is just a clone of the first, even if In the login scene, I have the second user informations

spring crane
#

How are you storing the info? I assume all players share their info with everyone else in the room

limber holly
#

I have Sql DB, I have a script with Json for translate from PHP to C#

#

this part of the job is ok

#

Scene1 Login Window

#

Scene 1 character selection

#

And when I click enter game ( connect PUN with character information name + ID)

#

Don't understand how collect information to Scene 1 to Scene 2

robust sandal
#

but that doesnt really matter since the person joining doesnt even get to the " OnJoinedRoom "

#

function

spring crane
#

@limber holly So is the server returning wrong info or are you somehow overriding stuff through PUN?

limber holly
#

I think it's Somewhere in my GameManager

robust sandal
#

If anyone can help me, plz DM, Im having a connection issue

cobalt python
#

@mint sundial you forgot bracket

mint sundial
#

really wqdkşjwqfjwq

signal snow
#

hey guys, I'm trying to make an HTTP request from Unity. My code compiles but does nothing. The same request as a curl does what I want it to in Postman. Can someone please help me figure out what the problem is?

using System.Collections.Generic;
using UnityEngine;
using System;
using System.Data;
using System.Deployment;
using System.Drawing;
using System.Management;
using UnityEngine.Networking;
using System.Web;
using System.Net;
using System.IO;

public class JogAxesPostRequest : MonoBehaviour
{
    public void ExecutePOSTJogging()
    {
        var url = "http://localhost/rw/motionsystem?action=jog";

        var httpRequest = (HttpWebRequest)WebRequest.Create(url);
        httpRequest.Method = "POST";

        httpRequest.ContentType = "application/x-www-form-urlencoded";
        httpRequest.Headers["Authorization"] = "Digest RGVmYXVsdCBVc2VyOnJvYm90aWNz";
        httpRequest.Headers["Accept"] = "application/json";
        httpRequest.Headers["Content-Type"] = "application/x-www-form-urlencoded;v=2.0";

        var data = "axis1=9000&axis2=9000&axis3=9000&axis4=9000&axis5=9000&axis6=0&ccount=0&inc-mode=Large";

        using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
        {
            streamWriter.Write(data);
        }

        var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {
            var result = streamReader.ReadToEnd();
        }

        Console.WriteLine(httpResponse.StatusCode);
    }
}

Here's how the working request looks like in Postman

eager dagger
#

hello there everyone

#

i hope everyone is doing great

#

so basically i ran into 2 issues

#

this one

#

and this one

#

could anyone please help me right now i am in desperate healp

#

thanks

#

wait i fixed it thanks to anyone who wanted to help

#

i still ran into an issue

#

the part of script that is getting the error

#

the error im getting

#

so i fixed it

#

but it doesnt teleport me to the next scene

#

it stays on connecting

#

so this is the script please send me a dm on what i got wrong because ill need to sleep rn

hearty dock
#

ha anyone used Photon Bolt?
The damn wizard pops up all the time whenever scripts recompile and always gives an annoying "Are you sure you want to close the wizard" prompt every time I close it. Is there a way to stop it from doing this without digging around in their code?

austere kiln
alpine quiver
#

hi, anyone here use Mirror before?

echo garnet
#

Does anyone know why my phonton create and join room isn't working?
here is the code
```public InputField createInput;
public InputField joinInput;

public void CreateRoom()
{
    PhotonNetwork.CreateRoom(createInput.text);
}
public void JoinRoom()
{
    PhotonNetwork.JoinRoom(joinInput.text);
}


public override void OnJoinedRoom()
{
    PhotonNetwork.LoadLevel("RandomFallingObjects");```
}

I get this error
CreateRoom failed. Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.

river meteor
worthy sinew
#

how to load a scene after I leave a room with photon?

#

nofixed it

pallid yacht
#

Hello guys, I am implementing an online multiplayer Board game with Unity and Photon. I am still hesitating about using either the MVC architecture or the EC architecture. What do you think is the best architecture pattern for these types of games in Unity and Photon ? Should I separate the Visual from the logic ?

spring crane
#

If you don't really foresee a reason for separating logic from the visuals, I would just stick to the Unity way until you have practical reasons to switch.

gleaming prawn
#

I am particularly a fan of decoupling gameplay and view

#

Although PUN/PUN2 were designed around the unity standard coupled/mixed way...

#

But Photon Quantum, for example, enforces a clear separation... And in Fusion we both "encourage" it (with visuals normally being only interpolation targets), and "enforce" it with the special FixedUpdateNetwork method for tick-simulation, etc.

#

So, it's not a wrong decision to try to decouple IMHO. It generally pays off in the long term.

fierce dock
#

(copypasted from #💻┃code-beginner )

So... never worked with networking before, and my Unity knowledge is pretty basic so far, although I can manage C#.

Is there any tutorial for multiplayer over network? What I found so far doesn't suit my needs; I need my players to have a 'cursor' (an object used to navigate a menu) and a menu, but everyone should see their own personal menu, something like an async RPG, that when all the players made their actions/choices, the server would advance the AI.

The point is, I need to show every player a different menu+cursor, they want to navigate their own thing and the send what they want to do, and wait for other players.

Should I go for MLAPI? Mirror? Other? ...

fierce dock
#

Are there any tutorials/how-to's? Couldn't find much by googling around

cunning sluice
#

Is anyone using Pun2 Currently? They made an update a couple days ago that removed the place for Voice ID and I can't find anything on the internet about it

#

Normally it would be under App id Chat

dense snow
#

Hi I`m making a multiplayer car game using Mirror. Every Time Player one chooses his character everything works fine. When Player two chooses his character he gets only the same character like the first player. Any Ideas?

#

Here is my code (The set Active lines are for gui):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using TMPro;


public class CharacterSelecter : MonoBehaviour
{
    public NetworkManager manager;
    public GameObject Player;
    public string Name;
    public TextMeshProUGUI Name_Textbox;
    

    public GameObject Foxy;
    public GameObject Kaktus;
    public GameObject Otter;
    public GameObject Pinguin;
    public GameObject setActive;
    


    void Awake()
    {   
        Foxy.SetActive(false);
        Kaktus.SetActive(false);        
        Otter.SetActive(false);
        Pinguin.SetActive(false);
    }

    public void ChangeCharacter()
    {
        Foxy.SetActive(false);
        Kaktus.SetActive(false);        
        Otter.SetActive(false);
        Pinguin.SetActive(false);
        setActive.SetActive(true);

        manager.playerPrefab = Player;
        Name_Textbox.text = Name;

    }
}
karmic frigate
#

How would I go about declaring a global variable in a jslib file? I tried

mergeInto(LibraryManager.library, 
{
var test = new WebSocket("some url here");
});```
but then the webgl build kept failing and I can't find any info on this besides one link
#

I want to store a global websocket for the webgl application, but I'm not sure how to go about implementing it

alpine pivot
# karmic frigate How would I go about declaring a global variable in a jslib file? I tried ``` m...

The way you declare a global variable in a jslib file is by using this library from this repository and forgetting about all of that JS baloney 😉
https://github.com/endel/NativeWebSocket

GitHub

🔌 WebSocket client for Unity - with no external dependencies (WebGL, Native, Android, iOS, UWP) - GitHub - endel/NativeWebSocket: 🔌 WebSocket client for Unity - with no external dependencies (WebGL...

stiff ridge
#

That naming "NativeWebSocket" is confusing. It's not native (as in C/C++) but managed (as in using .Net ClientWebSocket) for standalone builds.

vast forge
#

I am using Firebase in my unity app, but the app crashes on android when moving from Authentication scene to Main page scene, I installed Firebase Crashlytics, and the error says java.lang.error, what does that mean?

mint ivy
#

hi, is anyone familiar with the new mlapi ? i need some help understanding where my problem comes from

weak plinth
#

What's your problem?

mint ivy
#

fixed it don't worry

ivory cipher
#

@brisk briar have you checked that your firewall isn't blocking?

ivory cipher
#

It appears to be a version mismatch between the ENet versions you are running for server and client.

#

That link suggests building them yourself.

#

Simplest suggestion is to just write both client and server using ENet-csharp

alpine pivot
gentle mirage
#

as someone who failed at unity game netcode for logner than i want to admit, and trying lots of solutions, i would suggest this to anyone starting out, (its pun 2, but it gets you up and running and is actually good code, dont watch the youtubes) https://github.com/wafflehammer/FPS-Game-Tutorial

GitHub

This is the source code for Rugbug Redfern's tutorial series on YouTube - GitHub - wafflehammer/FPS-Game-Tutorial: This is the source code for Rugbug Redfern's tutorial series on YouTube

#

with a lil tweaking, you could even chop it down to just realtime which is what the latest unity mhalpi used as transport

#

just before you raise concerns such as, 'photon isn't server authoratative' first of all that's not really even the right accusation in the first place, as it default has a relay (server-ish) yoou can extend, and most importantly, if you are at this juncture, i think the bigger issue with not having this magical server side authoratative code you dream of is that you don't have a working networked game to be hacked yet lol, and unles your steve wozniak you can't stop it from happening, just mitigate things that are not ESP/passive, but all that is netcode solution agnostic

cunning sluice
#

With PUN2 when I throw an object, it'll look fine locally when it hits a surface, but on other players clients it like slides slightly and then does the physics.
Anyone know a fix for it?

slate haven
#

Yo, is anyone here experienced with photon framework?

weak plinth
#

How to run 2 games at once in editor?

haughty heart
#

You can't. You need to make a build, run that and run the editor.

gleaming prawn
#

Depends on which network tool you are using

#

Both fusion and quantum support running multiple clients (and server in case of fusion) from the same editor

spring crane
gleaming prawn
#

Which can also be achieved@with a simple symlink pointing to the project asset folder (from@another location)

#

Then you can open two editors

weak plinth
#

what network tool will be best? I don't want to just assign elements/variables to be synced, I just want to send Messages, I will do the rest with the scripts

#

and will be great to have external server

gleaming prawn
#

Well, if you just want to send messages you are saying you can do better than the tools that do a lot of features for you

weak plinth
#

I didn't said that, I just want messages

gleaming prawn
#

But in that case anyway, you are looking for a basic transport layer only

weak plinth
#

yeah

gleaming prawn
#

Steam networking, photon realtime, epic game services, etc

#

I mean, there is a ton more to game networking than that

weak plinth
#

but for steam networking I need to buy token for $100 if I'm not wrong

gleaming prawn
#

So unless@you have a very very simple game in mind, you may want more

gleaming prawn
weak plinth
gleaming prawn
#

Ye, that is for steam

#

Requires your game to be registered in steam

weak plinth
#

oh

#

that's sad I can't test it before

weak plinth
#

nvm, I can test it

#

you need to use 480 appid for test

gleaming prawn
#

Great

gentle mirage
gentle mirage
#

the erick guy

#

its like zuckerburg personally adjusting your privacy settings for you i'd listen to him

mint ivy
#

hi, i'm using the new unity mlapi and i have an issue, when i try Hosting a game the host player gets assigned as Host and then as Client to that host as well, now the problem is : when the Host player stops hosting, he gets removed as Host but is still in the connected Player list. I've found someone that had exactly the same problem then me on github but the only answer is that it is a bug and it should be fixed soon, but this was posted nearly 2 years ago! Does anyone knows how i can disconnect the Client side of the host aswell?

spring crane
#

Like on the same frame or does the host stay on the list forever?

mint ivy
#

well in debugging the connected client list count in update and its always 1 after the host started once

#

forever

valid totem
#

Hi, having trouble finding out the best way to do this: Player spawning and respawning. Respawning is easy enough (I think) but I'm having trouble with when the player object gets spawned when they join the server. I can use the OnConnectionApproval delegate, but that only works on clients, not clients AND the server host client player object.

#

Should I handle spawning manually with a script instead of using MLAPI default player object? or is there something else I can override because right now the server host client player object just spawns at 0,0,0

valid totem
#

I figured out that NetworkManager.Singleton.StartHost() takes in the same parameters as the connection approval delegate like position and rotation, but still wondering if someone has insight into this and if there is a better way :)

lyric osprey
#

what is a good method of sending the active keys being pressed to the server?

gentle mirage
#

char

dense hedge
#

a bitmask

gentle mirage
#

find where windows handles the heypresses and hook that so you can get value as its loaded into a register (may not be compatible with windows defender)

gentle mirage
high night
#

When a player joins, it gets spawned automatically. It only gets destroyed when the player leaves.

#

And the actual character is a different object you may spawn and destroy when needed.

spring crane
#

@valid totem Probably just send a message to the server that I would like to spawn now and the server responds by adding the player or by some other message.

valid totem
#

thank you all

#

<3

robust sandal
#

Every player in my game has a public int deaths and theres a manager in the scene that im wondering how i would sort every player by deaths and get the player with the least deaths

#
using ExitGames.Client.Photon.StructWrapping;
using Photon.Pun;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class Manager : MonoBehaviourPunCallbacks
{
    public string player_prefab;
    public Transform spawnPoint;
    public static int deaths = 0;
    private bool hasSpawned = false;
    public float time;
    bool hasDetermined = false;

    List<int> l_deaths = new List<int>();
    List<Transform> l_players = new List<Transform>();

    public void Spawn()
    {
        PhotonNetwork.Instantiate(player_prefab, spawnPoint.position, spawnPoint.rotation);
        hasSpawned = true;
    }

    public void Update()
    {
        if(hasSpawned)
        {
            time += Time.deltaTime;
            if (time >= 10) //just for testing purposes
            {
                DetermineWinner();
            }
        }
    }

    void DetermineWinner()
    {
        if (hasDetermined == false)
        {
            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            foreach (GameObject go in players)
            {
                if (!l_players.Contains(go.transform))
                    l_players.Add(go.transform);
            }

            foreach (Transform t in l_players)
            {
                if (!l_deaths.Contains(t.GetComponent<PlayerMovement>().deaths))
                    l_deaths.Add(t.GetComponent<PlayerMovement>().deaths);
            }

            l_deaths.Sort();
            int winner = l_deaths[0];

            foreach (int i in l_deaths)
                Debug.Log(i.ToString());

            foreach (Transform t in l_players)
            {
                if (t.GetComponent<PlayerMovement>().deaths == winner)
                {
                    t.GetComponent<PlayerMovement>().DisplayWin();
                }
            }
            hasDetermined = true;
        }
    }
}

#
    [PunRPC]
    public void DisplayWin()
    {
        Text winnerText;
        winnerText = GameObject.Find("Canvas/WinnerText").GetComponent<Text>();
        if (photonView.IsMine)
        {
            winnerText.text = "WINNER";
            Launcher.myProfile.xp += 20;
            DataLoader.SaveProfile(Launcher.myProfile);

        }
        else 
        { 
            winnerText.text = "LOSER";
            Launcher.myProfile.xp += 10;
            DataLoader.SaveProfile(Launcher.myProfile);
        }
        StartCoroutine(DisconnectUponWin());
    }
#

please @me with any responses / help :D

tropic star
#

Can someone explain why I am getting this error when using NetworkServer.addplayerforconnection?

Exception in MessageHandler: InvalidCastException Specified cast is not valid.   at Mirror.NetworkIdentity.SetClientOwner (Mirror.NetworkConnection conn)
inland sand
#

What's the difference?

austere kiln
#

If you click on them they have it described

#

But mostly on Unity PUN (Photon Unity Network) is used

inland sand
#

I've use photon on a normal platformer game before

#

It was laggy because I used transform viee instead of rigidbody view

austere kiln
#

Yeah Bolt is better for FPS, PUN is for casual multiplayer

inland sand
#

after doing some research, I am confused.

Should I use mirror or photon?
I want my game to have different rooms and more that 20players in a server. Photon only allows to 20 CCU per server, so should I create a new server? or use mirror?

mirror doesn't have any CCU limit but I'm worried if would be realtime or not

#

I want the server to be created at host's pc so that I don't have to worry about the server and ccu limit

#

Also, what networking solutions do big games like valorant, csgo, pubg, amogus use?

brave perch
#

I asked this question about 4 times and no answer to this day, but in 2021, as a beginner, where should I start for networking?

olive vessel
inland sand
olive vessel
#

Self hosting is what it is, you host dedicated servers or you let players host dedicated servers

#

Peer to peer is to allow players client's to host a game that people can join, the host player would have to port forward or you'd have to implement some form of relay service

olive vessel
#

Not sure, never decompiled their source code

#

Phasmophobia uses Photon PUN I believe

inland sand
#

so, I should use mirror instead of pun?

olive vessel
#

That decision is entirely yours

inland sand
#

Photon also has a service called photon bolt which is made for fps and battle royale games, so I was wondering, would the game be realtime with a little lag in mirror too?

#

Or is mirror just made for classic games?

olive vessel
#

Lag is a result of many factors

inland sand
olive vessel
#

Again, if I run a server on a Pentium and dial-up internet, it'll lag more than a Xeon with fibre internet, I don't know Photon's specifications

#

It would be best for you to go and look into using both of these solutions, watch some videos and see which is right for you

inland sand
#

Alright thanks, ig I'll be using photon pun or bolt for some time and then research about other networking solutions

robust sandal
#

Every player in my game has a 'public int deaths' on them and theres a manager in the scene that im trying to sort every player by how many deaths they have and get the player with the least amount of deaths

#
using ExitGames.Client.Photon.StructWrapping;
using Photon.Pun;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class Manager : MonoBehaviourPunCallbacks
{
    public string player_prefab;
    public Transform spawnPoint;
    public static int deaths = 0;
    private bool hasSpawned = false;
    public float time;
    bool hasDetermined = false;

    List<int> l_deaths = new List<int>();
    List<Transform> l_players = new List<Transform>();

    public void Spawn()
    {
        PhotonNetwork.Instantiate(player_prefab, spawnPoint.position, spawnPoint.rotation);
        hasSpawned = true;
    }

    public void Update()
    {
        if(hasSpawned)
        {
            time += Time.deltaTime;
            if (time >= 10) //just for testing purposes
            {
                DetermineWinner();
            }
        }
    }

    void DetermineWinner()
    {
        if (hasDetermined == false)
        {
            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            foreach (GameObject go in players)
            {
                if (!l_players.Contains(go.transform))
                    l_players.Add(go.transform);
            }

            foreach (Transform t in l_players)
            {
                if (!l_deaths.Contains(t.GetComponent<PlayerMovement>().deaths))
                    l_deaths.Add(t.GetComponent<PlayerMovement>().deaths);
            }

            l_deaths.Sort();
            int winner = l_deaths[0];

            foreach (int i in l_deaths)
                Debug.Log(i.ToString());

            foreach (Transform t in l_players)
            {
                if (t.GetComponent<PlayerMovement>().deaths == winner)
                {
                    t.GetComponent<PlayerMovement>().DisplayWin();
                }
            }
            hasDetermined = true;
        }
    }
}

#

And here is the function of making the player win

#
    [PunRPC]
    public void DisplayWin()
    {
        Text winnerText;
        winnerText = GameObject.Find("Canvas/WinnerText").GetComponent<Text>();
        if (photonView.IsMine)
        {
            winnerText.text = "WINNER";
            Launcher.myProfile.xp += 20;
            DataLoader.SaveProfile(Launcher.myProfile);

        }
        else 
        { 
            winnerText.text = "LOSER";
            Launcher.myProfile.xp += 10;
            DataLoader.SaveProfile(Launcher.myProfile);
        }
        StartCoroutine(DisconnectUponWin());
    }
#

Please @me with any responses so i see them :)

#

Nevermind i got it working haha, the DisplayWin function just got called for everyone but i fixed it :)

prime dawn
#

Uhm, so I have aproblem. Yesterday I had an error in the console that I read I can fix by updating photon. So I did update photon and the error dissapeared. The only problem now is that my in game chat suddenly stopped working. I've entered the correct appid and etc. any ideas?

prime dawn
#

Problem solved, I had to make a new appid for the chat

dry egret
#

Hey guys, just a quick question, how hard is it to get into multiplayer? I just think I might not be ready for it yet... Are there any key concepts that you'd need to know before jumpin in? Thanks

robust sandal
dry egret
#

Yes, I'm a bit experience with Unity, I've been using it since 2019 or so, but I'm unsure what Multiplayer library to use.. PlayFab, Photon, there were some other that got outdated. What do you recommend I start with?

cerulean sorrel
#

I have a maybe silly question, but when using MLAPI, is there some reason to not call a serverRpc on the server itself?
Does this cause it to send another network request?

cerulean sorrel
#

Specifically, in the golden path example, in the move function, it seperates out the server check for setting position and transform from the in the hello world player, but removing that and only calling the serverrpc instead seems to function correctly.

I can't seem to get the network profiler working for it either, so it's hard to tell if any packets are being sent.

olive vessel
cerulean sorrel
#

@olive vessel Perfect, thanks so much.

olive vessel
#

I hope that helps, it says it queues them so I can only assume it does not go out to come back in

cerulean sorrel
#

Yeah, it's not 100% clear on that, but I'm assuming it's an issue with some memory allocation since it looks like the framework injected code would cause it to be sent on the loopback, which makes sense, but also means I do need to keep them seperate I think.

#

I mean, it functions as expected, but yeah, it's gonna queue and be slightly slower as well as spinning up the network writer so, I'll just handle the diff manually. It'd be kinda nice if it just detected that, but I also understand lol.

versed socket
#

In a general multiplayer game scenario where the game contains a library of many RPG items (scriptableobjects), how can I create a runtime database of these items for network references via unique ID?

#

Say I send an RPC to communicate that a player has picked up X item.

#

I am tempted to use resources folders to automate the database generation but it seems to be discouraged

spring crane
#

@versed socket If your item SOs are going to always be in memory anyway, it probably doesn't matter, especially if you then don't reference the prefab directly, but by AssetReference or something equivalent.

spring crane
echo garnet
#

I'm making active 2d ragdolls but when I connect to a server (with photon) the ragdoll just breaks and flies off

#

anyone know whats going on?

#

Do I need a certain component on each ragdoll piece? for photon maybe like the photon transform view classic?

gentle mirage
#

i leveraged photon for my 3d active ragdoll game, and my netcode is fantastic now, after spending a long time on it to the point i lost sight of my games purpose lol

wary gull
#

If I have a server scene, and a client scene in my unity project, using Mirror, how do I call a function from the server scene if the client has no visibility of it?

gentle mirage
#

you talkin bout the concept of a remote procedure call?

wary gull
#

What I want it to be like is;
[Command] CmdDoStuff() {
HeresAnotherFunctionorMethod(stuff to send)
}

#

and then in the server files, that 'HeresAnotherFunctionorMethod' has its own code chunk that's private to the server

gentle mirage
#

but how you gonna run code if you dont have code to be run

#

its not magic, its netcode (smoke and mirrors)

wary gull
#

lol, that's exactly my point. I want the server to understand what that function/method is, and call it, when its told to call it

#

the client doesn't need to know what the code is

gentle mirage
#

if you say server autoratative determinalistic loud enough over here, nobody can tell that everything works more or less the same lag comp is stupid if you raycast cause it solves itself and rollback is 100% retarded and absolutely a terrible idea except for nickeloadean based fighting games (ok fighting games, but you have to live with the consequences)

#

additionally, no matter how many buzzwords your 'server' has, can't stop esp autoaim or you know, all the popular, passive cheats

#

you can add a bunch of latency tho, so thats pretty dope

wary gull
#

I need to contain a password for a mysql account that's reading a local configuration file with the password being encrypted... the encryption needs to be done on the server only.

gentle mirage
#

uhm, you need ssl and possibly leverage some windows api stuff if you REALLY cant have user type it in themselves

wary gull
#

users won't know what the password is

gentle mirage
#

so you have a master password, for all the things, and you need your clients to login with privledges to this and i'm curious what you think the outcome will be

wary gull
#

alas, that side isn't the problem... it is literally just the concept of how do I tell the server, from a client, to run a method that the server knows exists, that the client doesn't know exists

gentle mirage
#

sql injection?

wary gull
#

have you ever played Arma3?

gentle mirage
#

yes

#

battle eye is the gold standard

wary gull
#

ok, there are various mods on arma 3 that allow for mysql data capture, to "save" player progress

gentle mirage
#

why does that have to be a master account for everyone, i'm certain it uses individual users account

wary gull
#

on the server, there is a configuration file, it reads and writes the mysql data

#

it has a single account

gentle mirage
#

and it probably piggybacks off a third party auth

#

for everyone, in the world, with full read write

wary gull
#

the clients, people playing arma3, connect to a server, and they literally just send a single function to the server, and say "run this function"... which is the mysql function... the data is stored

#

that's all I'm trying to emulate

#

server is the only machine that should have access to its own local mysql database

gentle mirage
#

like, a post request?

wary gull
#

it reads, it writes, it just relays the information

#

yeah, sure... but how do I get the client, to tell the server, to run a c# method?

gentle mirage
#

system.www

#

i mean

wary gull
#

why would the game file be hosting a www instance?

#

and how would mirror interact with that?

gentle mirage
#

i thought it was an sql server you wanted to talk to directly

#

as you just stated

#

not a c sharp method

wary gull
#

no, its the game server, which has its mysql instance running on it... I want ONLY the game server to read/write it, on request by the clients

#

so how do I tell the server, to run a method that only it knows, when that code has to be on the client?

gentle mirage
#

so tell the server to run a method that then runs the sql query?

wary gull
#

like the reason I originally left out the mysql stuff is because you've zoned in on that being the solution, it isn't lol...
I need to know how to run a method from the server, when the client makes that initial call

#

like client clicks Save > Save is passed to server > Server runs the save function > Data is saved in mysql > response is returned that data is saved > Save state is passed back to client > client is happy

gentle mirage
#

why not player prefs

wary gull
#

huh?

gentle mirage
#

just store it locally in player prefs

wary gull
#

I can't store it locally... if the game has ultimately enough funding, it's intended to be hosted on a cloud platform without local data

gentle mirage
#

ahah, and here is the most important question in netcode

#

before you try to solve your hacking/scaling problem, your number one priority should be to get the worse possible hacking/scaling problem possible

wary gull
#

which as it stands, is not being able to send a command over the network manager to call a function that the client can't see

#

without that possibility, I can't build the rest of the game

#

so right back to the beginning of my question....
How do I do that? All examples online simply show clientRPC and Command etc with all of the code clearly visible in the same files...
Yet everyone recommends splitting server and client into two separate builds so that you can't see the contents of the server code

#

and thus, my issue

gentle mirage
#

how do you have any working netcode if you cant call methods on other clients/server (no difference really in the means in which you do so right)

#

i mean, do you want to call a method on the server, that doesn't exist on the client? no problem there right?

#

yhou can build a separate server build

#

ask for method by name

wary gull
#

Yeah, I want to do that exactly, but there's absolutely no examples of htat

gentle mirage
#

how do you normally call methods on other computers

wary gull
#

I don't know... I'm learning, hence the blue name

gentle mirage
#

oh i ddin't know they did the racism name struff why am i green, isn't that more less experience than blue lol

#

oh i picked this

wary gull
#

Yeah, I'm just student, because I'm learning

gentle mirage
#

yea i'm not a game dev, its accurate, unity makes me feel like i need a shower

#

i can code tho pretty aite

wary gull
#

I can code normal applications, but I don't write applications that network multiple machines together to constantly exchange data

#

I also have no experience in web dev either

gentle mirage
#

same here, game netcode is very strange, if it makes sense, your probably going down the wrong path

#

i use photon personally, after going through mirror as well as unity mhalapi

wary gull
#

but alas, that's diverging off topic...
When I write a function on my client operations script file, and tell it its a command to be ran on the server, and then reference the function by name, it just gives me a syntax problem saying it doesn't know what that function is

gentle mirage
#

i tried it, ditched it, tried everythign else, ended up back on oit

wary gull
#

but I expect that, the client isn't supposed to know what it is

#

but I can't run it, because it doesn't know what it is, and that's my problem

gentle mirage
#

you should be sending a string and using reflection if i'm not mistaken

#

or like

#

invoke("methodname")

wary gull
#

ah ok, what's reflection?

gentle mirage
#

reflection is like yo u know that variable thats like private? i don't care

wary gull
#

ah ok

gentle mirage
#

now

#

the thing about sending invoke("methodname")

#

across the internet

#

is i really want to play your game

#

for science

#

when it comes out

wary gull
#

tbh, from what I recall actually... "BIS_fnc_MP" that was a method that basically was used to call other methods

#

so it'll be the invoke I need

#

champion... thank you 🙂

wary gull
gentle mirage
#

i spent way too long on netcode, now not to brag here, but my netcode is dope af now, its just like, i completely lost sight of my game and any purpose or direction it had

wary gull
#

well mine will be utterly terrible to begin with, but hopefully it could be optimised later on down the line

gentle mirage
wary gull
#

lol I don't know whether to be impressed or disgusted

gentle mirage
#

typically people say things like wat is this insane fever dream, i'd go with taht

gray pond
still hare
#

Nice!

gentle mirage
# echo garnet Wdym?

my game being active ragdoll didn't like, fall into any tutorials or assets or prefabs or existing stuff out there and i had to do it custom. i learned a lot, my netcode is really really good (33 bytes and a bool to sync 15 rigs) but like, i lost sight of my game and its purpose entirely

gentle mirage
#

yaa

#

one nice thing with photon is you can use it at a low level if desired, and at that point its as efficient as you are you know

#

like, the unity mhalpi thing they put out most recently used photon for transport

echo garnet
#

how did you make your ragdolls not fall apart

#

in multiplayer?

gentle mirage
#

configurable joints

#

and also custom drag/angular drag handlers along with inertial tensor jobbers

wary gull
#

@gentle mirage Invoke doesn't seem to be acknowledged as anything I can call under either monobehaviour or networkbehaviour 🤔

gentle mirage
#

u gotta use an alley ooper method the sme way your currently doing netcode stuffs but have it invoke thje argument

echo garnet
#

but when they connect in a server

#

they like break and fall apart

#

like they work normally

gentle mirage
#

ur usin photon pun 2?

twilit finch
#

I'm using a NetworkAnimator component (Mirror). At the start of my game it throws this error:

Animator is not playing an AnimatorController
UnityEngine.Animator:get_layerCount()

The related game object is deactivated at the start of my game. Will this cause the issue?

inland sand
#

I'm asking this again cuz I'm dumb, I want the server to be created on host pc and no CCU limit, how can I do that?

#

I used photon pun but it has CCU limit of 20 and works as dedicated server

#

But I want my server to be instantiated wehn the host creates room

alpine pivot
inland sand
#

Ight, thanks

gleaming prawn
#

or photon fusion

cedar cloak
#

Question about networking: I need to develop a simple Rock Paper Scissors game where 2 people in que gets paired and play a game, can I do this with p2p?

olive vessel
#

Peer to peer is just a way of connecting people, so yes

cedar cloak
#

Im not an expert on networking, I basically dont want to rent a server since I guess that is not needed for a game that simple, am I right?

spring crane
#

@cedar cloak @inland sand Just note the details when it comes to hosting a server behind a network firewall. Average player will have a hard time with port forwarding.

olive vessel
#

Photon PUN is probably not a bad choice for your Rock Paper Scissors game

#

20 free CCU

#

Rooms etc

cedar cloak
#

I already used him in previous projects and 20 CCU is too few

echo garnet
olive vessel
#

20 CCU is too little? You must be having some good success then

#

Someone once did a breakdown, of how CCU translates to MAU, and you need thousands of MAU before you start hitting even 1k CCU

cobalt python
#

Hi guys, I am using pun! Someone said that using rpc buffered is a very bad idea, is it?

shut topaz
#

Hey all I have been looking around at various networking solutions. As far as multiplayer games go Unity has had the general reputation of not being so good in that regard. Realistically how hard is it to get networking right in Unity vs unreal? I know Rust and Escape from tarkov are multiplayer unity games but each of those has had issues and I believe tarkov atleast made its own custom networking.

river meteor
echo garnet
gray pond
echo garnet
#

When i use photon pun my active ragdolls break like this anyone know why?

#

do I need a certain photon component on the gameobjects of the ragdoll?

echo garnet
#

How do I also make everything in photon server side?

#

Like spawning?

inland sand
echo garnet
#

I knew that

cedar cloak
#

Does photon have dedicated servers? If the master leaves a room, does the master pass to the other player?

lyric osprey
#

how would one go about networking charcontroller height?

limber holly
#

Hello, I working on 2D mmo, I wondering about the most efficient way to build the character or enemies ?
Currently, I instantiate Player prefab with:

  1. main script, controller script, scriptdata for DB character informations)
  2. The UI ( statut windows, skills, maps etc)
    Now I scripting the combat system, then I want to create another GameObject Child of PlayerPrefab with the character skills ( graphic effect, templates etc). I wonder if this way, my player is not to eavy for the server ? Is it better to Instantiate each time the spell from the game folder ?
inland sand
#

Why are there very little tutorial on making fps with unity?
Please suggest some good tutorial/playlist on how to make one with mirror (I've some experience with photon)

olive vessel
olive vessel
#

Doesn't mean no skills are transferable. I bet there are a tonne of tutorials for FPS games, and a tonne for Mirror, so then it's a matter of understanding the content and applying it.

#

Ofc UNet is gone, but you can see how the processes worked with UNet and try and bring that forwards to Mirror

inland sand
#

Ight thanks

weak plinth
#

VERY IMPORTANT QUESTION, in photon unity networking (PUN)
if I make a photonview with a transferable ownership.. would photonview.ismine refer to the new owner????
thank you in advance

inland sand
#

you're welcome in advance

ornate zinc
#

Hey everyone. Can someone help me out with a weird issue in UnityWebRequest, the downloadprogress keeps returning -1, not finding any doc about this behaviour

#

Nvm, it held the webrequest and did not start it before hand...

remote rock
#

Hello, Moving this here as general code might be the wrong spot.
I am curious if anyone has used MLAPI with Steamworks.facepunch and would recommend using the SteamP2P transport or just using the Unet transport?

remote rock
weak plinth
remote rock
#

Pun may be able to work P2P but I did not see an option for it.

weak plinth
remote rock
#

They do. but that only helps for up to 20 players I think.
I want to end up putting my game on steam and the hope is more than 20 people would play. 🙂

weak plinth
remote rock
weak plinth
#

I understood the exact opposite

#

I am almost done with the game

remote rock
#

I could be wrong but thats the reason I went to MLAPI.

#

I used PUN as well for a while and had to restart after reading into it

weak plinth
#

do you have a resource for mlapi? like videos and such

#

if you dont mind sharing of course

remote rock
#

Just youtube and personal trial and error

#

They have a trial game you can download in Unity and read over there code

weak plinth
#

thank you

olive vessel
#

It is 20 CCU

#

Concurrent users

weak plinth
olive vessel
#

People playing at the same time

#

However, to have 20CCU, you need more than 100MAU

remote rock
#

Okay, so I did read it right

olive vessel
#

Because not every player, will play at the same time

weak plinth
#

oh I am reading it now

#

💀

#

@remote rock one last question if you dont mind, since you already have started with mlapi , is it majorly built on events?

turbid tusk
#

How to bypass CORS for unity webgl builds?
We are only getting 2 out of 9 response headers in unity webGL build but all 9 appear in Unity-Editor.

placid oak
# remote rock I could be wrong but thats the reason I went to MLAPI.

the prize of having photon is not a reason why you go out with empty hands... mlapi wasnt designed for rooms ( like 5v5 in league of legends thats what i mean with rooms) ... at its best its good for coop games or games wiith few scenes as the traffic scales exponential with scene management on

remote rock
#

Its very similar to PUN with wording but the NetworkManager needs every networked object manually added to the list.
I would recommend watching a few videos on Starting up with MLAPI - https://www.youtube.com/watch?v=qJMXv5J4wf4

This is the first video in my new series on using MLAPI to make a simple multiplayer game in Unity3d.
Full Playlist here: https://www.youtube.com/playlist?list=PLbxeTux6kwSAseRmJeCyvkANHsI16PoM6

In this video we will setup MLAPI and a tool called UnityProjectCloner so we can more easily test as we develop without having to build the game every...

▶ Play video
olive vessel
#

If you're not hosting servers, your players will need to port forward. Or you'll need a relay service or a punchthrough technique

remote rock
placid oak
remote rock
#

Not in the same game no

gleaming prawn
placid oak
#

so you have at MAX 4 players AND all of them are on the same Scene

weak plinth
olive vessel
placid oak
olive vessel
#

If you've got 8k MAU, well done you

#

You've made it somewhat

gleaming prawn
#

to get 100 ccu, you need around 2000 dau, and 40k mau (50k + downloads)

#

And MLAPI for self host you still need a solution for punch (as port forwarding is only for nerds, really)

weak plinth
placid oak
remote rock
gleaming prawn
#

No, have not... It does work

#

If the game is Steam, sure... It works

#

If the game is steam only it is a valid option for p2p

placid oak
remote rock
weak plinth
verbal lodge
#

Use SteamP2P if you want players to connect directly to a hosting client. Use UNet if you want your own servers.

placid oak
remote rock
#

Its different from the normal facepunch functions as SteamClient.(anything here) does not yield the same results

remote rock
weak plinth
weak plinth
placid oak
#

if so then mlapi is a shot into your foot

#

you can make a giant work around with mlapi but it wasnt designed to have rooms which are independent to each other

remote rock
#

So wait....
In my case there will be 4 players playing all on one scene. However, other people can play the same game but with there own group of 4. Completely independent from the other group of 4.

#

Would this be to much for mlapi

placid oak
remote rock
#

Sh*t

olive vessel
#

Mirror can do that can't it?

#

NetworkRoomManager and NetworkRoomPlayer?

#

Ah, Network Match Checker

placid oak
# olive vessel NetworkRoomManager and NetworkRoomPlayer?

yes but why code it urself instead of using for example photon which patch the room management regurarly ... YES photon will cost you something at some point but you will have a higher cost buying someone who patches your room management

olive vessel
#

Oh no I agree

#

If you've got 50k downloads, you're grand

remote rock
#

What would be the best option then for up to 4 players to connect to a single host. I am not able to pay for a server and my game would be fine with a player being the host.

olive vessel
#

The cost is tuppence

olive vessel
placid oak
weak plinth
olive vessel
#

I really need a good Photon tutorial series actually...

placid oak
# weak plinth I am sorry I dont get what you mean by rooms that are independent to each other

ok lets say you have a scene with a temple in the middle and with 4 players on it trying to capture it

now 4 other players come and want to play also capture the temple ...

now the problem happens the first scene is ful so your server needs to create a new one where the other 4 players can play capture the temple

the first map and the second map now dont know anything from each other

weak plinth
#

@placid oak no that is not possible , in the scene only 4 players are allowed NOTHING MORE there are no multiple maps or anything .... think about it as a cs-go match, there is only a specific number of players allowed... if others want to play the game, they have to create their own match

placid oak
#

"the first map and the second map now dont know anything from each other" this is where mlapi fails as EVERY scene which is in the network is known by everyplayer

placid oak
remote rock
#

Damn I thought I new what I was doing.....
So MLAPI is unable to handle multiple rooms? Even if they are completely independent and running on user machines?

placid oak
# remote rock And this would need PUN?

you can do it yourself with mirror or other network managers ... i use photon as they give me so much for a low prize...

if i would do the room management myself it would cost me mmuch more instead of just buying it from photon ... AND photon is free for 20 ccu

placid oak
weak plinth
#

well damn

placid oak
cedar cloak
#

Question on Photon

#

how can I select a different map(scene) during the room creation?

weak plinth
olive vessel
#

No

#

In Mirror, you can have lots of people in one scene, who can't even see each other

#

So one server can do many games

placid oak
remote rock
placid oak
#

that is what i wanted too for my game and thats it

#

that tutorial series

#

photon has pre implemented functions like "joinOrCreateRoom"

#

like you dont have to handle the rooms by youself

#

photon takes alot of work there

#

mlapi wasnt meant to do that

light ginkgo
#

Hey, I have a problem with the Photon View and the Photon Rigidbody View, I am making a VR game and when I pick up an object, it does not sync to the other players?

placid oak
#

photon has pre implemented functions like "joinOrCreateRoom" => here the user sends a request to the server that they need a new map and the server will create one for them

#

atleast you can implement it like that

weak plinth
#

@placid oak thank you a lot man this has been VERY HELPFUL

#

i deleted and rewrote it cause it wasn't a reply

weak plinth
#

even though it is a different match

placid oak
#

that means your network traffic increases per user exponential

#

which is a catastrophy

remote rock
placid oak
remote rock
#

dang... Is this a temporary thing for MLAPI or is this the goal?

placid oak
#

you can read in many forums that mlapi isnt "the best option"

placid oak
#

idk if thats true... but i only play games with rooms and matches so i dont want mlapi as the room management is like that

remote rock
#

I restarted once because of PUN costs and now I need to go back 😦
How do indie games pay for servers like PUN? I imagine small games only stay alive for a short while and then die.

olive vessel
#

As someone said, 100CCU is a massive amount of MAU

placid oak
#

ye you need 1000 users where 10 pay but you can have 40k per month

#

=> photon prize is more than fair

olive vessel
#

Steam has over a billion accounts, but only around 120 million MAU in 2020

remote rock
#

I am thinking the long term since its a monthly payment and I only plan to make my game a single cost.
There price is fine but im not looking to make bank with this game lol

olive vessel
#

$95 for 12 months

remote rock
#

Oh wait... what

#

I thought it was per month....

olive vessel
#

That wouldn't make sense...

#

Because 500 CCU is $95 per month

remote rock
#

Yea, I guess I looked at the next one and got scared

#

I need new glasses

olive vessel
#

So if 100CCU is 50k downloads, 500CCU is a quarter million downloads

#

50k is fantastic really, 250k is incredible

#

Unless ofc, you make a game that becomes a fad, like Phasmophobia did

remote rock
#

Yea I dont think that will happen. but fingers crossed right 🙂
I like that PUN has a breather so it will let people play even if its over 100 and you pay later

#

Have you used PUN with Steamworks.facepunch?

olive vessel
#

I've never really tried much with PUN, but I'd love to learn how to use it

remote rock
#

Okay, Im sure there are videos or things out there.
Thank you for answering all my questions 🙂

light ginkgo
#

Hey, I have a problem with the Photon View and the Photon Rigidbody View, I am making a VR game and when I pick up an object, it does not sync to the other players?

remote rock
weak plinth
#

seriously people i was terrified .. thank you for answering my questions

weak plinth
remote rock
weak plinth
remote rock
light ginkgo
#

Also, noted thing, no putting Photon View's on Objects with Renderers, because apparently that doesn't work.

turbid tusk
#

How to get all response headers with UnityWebRequest.Post request for Unity WebGL?

jovial pike
#

what is the problem?

raw osprey
#

@jovial pike your class should inherit from MonoBehaviourPunCallbacks, not MonoBehaviour if you want to override pun callbacks

jovial pike
#

thx 😄

jovial pike
#

I changed my Unity Project Version and now this shows up

#

but it doesnt cause errors or so

raw osprey
#

Collaborate is technically a package I think, so see if you can update / remove (if you're not using it) it from the package manager

jovial pike
#

thx ❤️

river meteor
jovial pike
#

Hi, I have a 2D Game with 2 Players which i can controll with "w,a,s,d" and "i,j,k,l". is it possible to make a multiplayer with photon for this game?

#

In all tutorials are just one Player and the other is spawned automatically.

#

but my game is slightly different

jovial pike
river meteor
#

I dont understandy you

jovial pike
#

but idk how i can make that the joined player can controll the right character in the video

placid oak
river meteor
#

just

#

firstly you must have added Photon View for your player

#

then in Awake function getcomponent<photonview>(); to some object

#

and then where you have your code with getting input

#

check if(PV.IsMine)
{
// get my input
}

jovial pike
#

thx :D:D:D:D

river meteor
#

also remember about disabling any other camera when !PV.IsMine

#

in scene

jovial pike
#

i just have one

river meteor
#

yeah but when you have two players on scene you have two cameras 😉

placid oak
jovial pike
#

ouh

river meteor
placid oak
river meteor
#

but I consider that it must be handled same way as legacy one

#

try

jovial pike
#

and he got his Photon View Component

#

both player have their own script

jovial pike
river meteor
#

you tested it?

#

the pv object is already set to pv component?

#

when the game is starting?

river meteor
#

so it should work

jovial pike
#

i will test it now

river meteor
#

okey

jovial pike
#

it connects directly to the game scene

jovial pike
river meteor
#

yeah for debugging purposes why not

jovial pike
#

ok...

#

then it doesnt work

#

it doesnt update on the second window

river meteor
#

what is not updating?

jovial pike
#

both players

river meteor
#

ahh because your players are rigidbodies

#

you also need add to them photon rigidbody view

jovial pike
#

ouhh

#

thx

#

photon view and the photon rigidbody 2d view?

#

or only the rigidbody one?

#

im trying both

#

it doesnt work 😦

#

do i have to check one of these?

#

i think all

#

i will try it

river meteor
#

it strange that your positions are not synced

#

okey so you have only one camera per scene which players are not controlling

#

your players are PREFABS instantiated by PhotonNetwork.Instantiate, right?

jovial pike
#

nope

river meteor
#

So there is your problem

jovial pike
#

that was my problem

river meteor
#

make two spawnpoints

#

and instantiate them on game start

jovial pike
wintry mantle
#

hey everyone! Curious about how difficult it is to create a multiplayer co-op game with cross-play between platforms. Let's say one player is on Windows/Steam and the other is on a Switch or ps5. Is it terribly difficult to allow those players to play together online? I've been doing some research and haven't come across a straight forward answer, so I'm not sure of the feasability or best practices on creating something like this

lyric osprey
#

what is a good method of rotating a bone locally?

wary gull
#

Anyone else had issues with mirror since the update?

jovial pike
#

i cant move my player when he is a prefab

spring crane
wintry mantle
jovial pike
#

but i need that

jovial pike
teal obsidian
#

other than that, I mean it really shouldn't be hard

wintry mantle
#

Thank you! Financing the project won't be much of an issue for me, it's the knowledge that is the tough part

teal obsidian
#

I mean yeah it really shouldn't be that hard at all

#

it's just sending/receiving data over the internet

#

which all of them can do

wintry mantle
#

to actually get them to play together, is that just using a lobby code and then a friends list in the game? (for an example)

teal obsidian
#

all libraries are different

#

so your networking library will need to support consoles

#

if they do, then yeah cross play won't be difficult

wintry mantle
#

okay thanks, that gives me a very clear path of what to research next. I wasn't sure if Mirror would cut it or if I'd need Photon or something

jovial pike
#

Idk what to do

spring crane
#

PhotonViews do work in prefabs assuming you use them after they have been instantiated

#

Make sure to use PhotonNetwork.Instantiate

jovial pike
#

Thx

jovial pike
#

So i just have to put „PhotonNetwork.Instantiate“ in my script

#

Do i have to say in which Player ?

spring crane
#

The client that calls it owns it by default

jovial pike
#

thx

river meteor
# jovial pike

Sorry I went to sleep, just do PhotonNetwork.Instantiate in your network manager script

#

for ex OnJoinRoom callback

cedar cloak
#

Is this how Photon PUN architecture works? Are masters also clients?

spring crane
#

Peer to peer over relay. Client <-> Relay <-> Client

gleaming prawn
#

and any peer can create an object and send data updates for it

#

so technically you can write a game putting some more logic on the "master", but it's not really designed for that

#

If you want a purist client-server netcode, with an accurate tick-logic, client side prediction, lag compensation, etc, go for photon fusion.

inland sand
#

If I watch uNet tutorial then I won't be getting any problem using mirror right?

spring crane
#

By now there should be Mirror specific content. The concepts will likely largely carry over, but Mirror has been in dev for a while since the UNet fork days.

cedar cloak
#

PUN: Is there a way to reach the Player GameObject by using actor number or ID?

gleaming prawn
#

only if you store this mapping yourself

#

an actor can spawn many many objects

cedar cloak
#

How do I store it? Can I use the Player var when OnPlayerEnter method occurs?

gleaming prawn
#

you can add "self" game object to a dictionary you store somewhere from a script Start

#

so every client knows which objects are spanwed by the others via their actor IDs

#

key is id, value is the object

#

anywhere you want

#

This is really about your own code, not something particular to pun, etc

cedar cloak
#

I just need to assign the 2 player gameobjcets to the master and from them I can sync to the client I guess

gleaming prawn
#

you probably don't need tht

#

but do however you feel more comfortable with

cedar cloak
#

I already store actor and ID of players

#

really strange I cant reach the Player go by using one of these two infos through photon

#

but yes, maybe I dont need that, I can compare just the IDs when calling an RPC

gleaming prawn
#

the point is this is not a 1-1 mapping (unless your own game treats it like that)

#

each player can spawn as many GOs as he wants, it's your code...

#

so it is not the role o pun to store that data

cedar cloak
#

ok

cedar cloak
#

So 'im having a little issue: The Player script is trying to call an RPC from the Master's Game manager script (its in the scene not on player), it has the [RPC] tag but I still get the error:
"PhotonView with ID 1001 has no (non-static) method "SubmitChoice" marked with the [PunRPC]"

#
    public void SubmitChoice(string emitterId, Choice choice)
    {
        if(PhotonNetwork.IsMasterClient)
        {
            if (player1_id == emitterId)
            {
                player1_choice = choice;

                player1_ready = true;

                Debug.Log("Player 1 Submitted");
            }
            else if (player2_id == emitterId)
            {
                player2_choice = choice;

                player2_ready = true;

                Debug.Log("Player 2 Submitted");
            }
            else
            {
                Debug.Log("ERROR");
            }
        }       
    }```
#

this is the method

inland sand