#archived-networking

1 messages · Page 84 of 1

jade glacier
#

So if an avatar shoots another avatar, you need to get their owners from their PhotonView.

#

Have you done the Getting Started tutorial?

lunar plinth
#

not yet

jade glacier
#

How are you trying to learn then?

lunar plinth
#

i'm not done with it. I'm still on it

#

i mean i read a lot about it

jade glacier
#

Can't really help you much until you get through it and understand the basics. Otherwise you are just asking people here to walk you through it.

weak plinth
#

ok so i have this problem i want it so it will show an arrow above the local players gameobject and this is my script and i dont get why it doesnt work: ```public class Instantiate : MonoBehaviour
{
public GameObject arrow;
private void Awake()
{
if (PhotonNetwork.LocalPlayer.IsLocal)
{
arrow.SetActive(true);
}

    if (PhotonNetwork.LocalPlayer.IsLocal)
    {
        arrow.SetActive(false);
    }

    PhotonNetwork.Instantiate("PLayer1", new Vector2(Random.Range(-12.84f, 13.2f), 4.9f), Quaternion.identity);
}

}```

jade glacier
#

LocalPlayer.IsLocal will always be true by definition no?

weak plinth
#

ow

#

any idea how i would do this otherwise?

jade glacier
#

Just hide an arrow graphic based on IsMine

weak plinth
#

o

#

w

#

so

#

something like this? using System.Collections;

using UnityEngine;
using Photon.Pun;
using Photon.Realtime;

public class Instantiate : MonoBehaviourPunCallbacks
{
    public GameObject arrow;
    private void Awake()
    {

        if (photonView.IsMine)
        {
            arrow.SetActive(true);
        }

        else
        {
            arrow.SetActive(false);
        }

        PhotonNetwork.Instantiate("PLayer1", new Vector2(Random.Range(-12.84f, 13.2f), 4.9f), Quaternion.identity);
    }
}```
#

cuz that gives me this error NullReferenceException: Object reference not set to an instance of an object Instantiate.Awake () (at Assets/Photon/PhotonUnityNetworking/Resources/Instantiate.cs:13)

prime beacon
#

Umm try moving your code to Start()

#

@weak plinth

weak plinth
#

k

#

nope doesnt fix it

#

o

#

i might have fixed it

#

nvm

#

now it doesnt work anymore

#
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;

public class Instantiate : MonoBehaviourPunCallbacks
{
    public GameObject arrow;
    private PhotonView photonView;
    public GameObject Player;

    private void Start()
    {
        
    }
    private void Awake()
    {
        photonView = Player.GetComponent<PhotonView>();
        if (photonView.IsMine)
        {
            arrow.SetActive(true);
        }

        else
        {
            arrow.SetActive(false);
        }

        PhotonNetwork.Instantiate("PLayer1", new Vector2(Random.Range(-12.84f, 13.2f), 4.9f), Quaternion.identity);
    }
}```
jade glacier
#

Use OnJoinedRoom

somber drum
#

is photon a suitable environment for persistent player shops? Thinking of using playfab to hold players inventories and currency, then transfer between the two but the only google search relevant comes up with an old post from 2014 saying photon being peer-to-peer is not suitable for this, I'm assuming they didn't take playfab into account and were referring to a photon-only solution.

tldr photon + playfab = persistent player-to-player shops ie auctions so on?

#

I'm sure it's possible just making sure photon being peer to peer won't be an issue in this quest

jade glacier
#

Photon products are for the realtime aspects of gaming. Persistent stuff you would use something like Playfab.

abstract flax
#

We are trying to help our friend with this small indie game. He has a single camera 4 person game. Currently local co-op. He wants to add networked multiplayer. He suggested we look into Photon. I have successfully converted his code so we can render and move around networked players. We are struggling to figure out how we can have local co-op players mixed in with networked players. eg: 2 local players + invite a steam friend who has their own 2 local players. Is this even possible? Seems like we'd need to keep track of locally joined players and manage the logic of if the room is "full" on our own? Does anyone know of a server solution that would handle this use case better?

gleaming prawn
#

Is this even possible?
Yes, but you need to code it yourself, assuming that by "photon" you mean PUN (photon unity networking, one of the products in the photon family).

#

Does anyone know of a server solution that would handle this use case better?
Yes, photon quantum has this as a basic feature (multiple local players)

fallen frigate
#

i wanna make a simple lobby using photon pun in unity and , in which player can join by entering room id or can create it ,i am ready with basic ui interface ,please anyone help me

#

and i also installed photon pun into my project

prime beacon
silver steeple
#

lol channel might as well be renamed to photon channel

fallen frigate
#

thanks @prime beacon

silver steeple
ocean abyss
#

Hello! Is there a good resource to make a server inside unity that is fast? I tried TCPSockets but it's very slow for player movement. The player movement jitters

shut yarrow
#

Use UDP

silver steeple
#

Also if it's jittering, you should interpolate between positions

ocean abyss
#

Should TCPSockets be jittering in a local network?

silver steeple
#

no

ocean abyss
#

I'm doing something bad then 😅

silver steeple
#

are you interpolating between positions?

ocean abyss
#

No interpolation at the moment

silver steeple
#

that's ya problem. All games ever do that. Doesn't matter UDP vs TCP

shut yarrow
#

True but TCP is a bad choice for realtime movement

silver steeple
#

If it's always going to be local then no harm no foul. But yeah agreed.

fair cosmos
#

hey guys i want to sync skins between players

#

any approach

#

for syncing of weapons and teams i use enums

silver steeple
#

like, UV maps?

fair cosmos
#

but skins are a lot

#

@silver steeple no

#

sprite

silver steeple
#

Are you modifying it like, every frarme or something?

fair cosmos
#

nope,

#

i am just asking how to sync stuff like that which is in large amount not in limited like teams, squads or weapons

silver steeple
#

Just trying to understand your situation, and why you can't just do what you've been doing with something like weapons and enum solution

fair cosmos
#

nope

#

i have to do that

#

public enum Skin{ green, blue, sooo.. on }

silver steeple
#

oh. So you're already using an enum for skins?

fair cosmos
#

noPe i am not goin to

#

i just wanted to know is there any other approach to sync stuff like skins which is in large amount

silver steeple
#

Enums.. IDs... etc

fair cosmos
#

@silver steeple so how to do it with ids

#

ids can conflict!!!

silver steeple
#

if you let them conflict sure. There's plenty of ways to prevent that. Or the internet as we know it would not exist.

fair cosmos
#

@silver steeple so whats the process of it

gleaming prawn
#

IDs should not conflixt

#

if it's your game and you decided for the game assets database I mean

silver steeple
#

@fair cosmos depends on your situation. It's hard to understand the context and why you're having trouble with anything. Would recomend looking into how to prevent IDs from conflicting in whatever situation you're in.

gleaming prawn
#

In all game clients the same skins would have the same IDs/Indexes respectively, etc

#

It's your game data, etc

#

Say you store your skins as an Array in a scriptable object or any other mean... Then just pass the index of the chosen skin, etc

silver steeple
#

There's no excuse for why they would conflict tho. Things like youtube, a massively distributed asyncrounous realtime system dealing with billions of requests still maintain unique video IDs

gleaming prawn
#

That's it

#

If you are using a player profile database like Playfab, the unique IDs for each individual item/skin would be generated there, etc

#

So there's no conflict

fair cosmos
#

@gleaming prawn thnx

dusk cargo
#

On Photon when I pass a variable via RPC, does it use the local avatars version of that variable or does it pass the one from the networked player

#

If that makes any sense

copper wadi
#
GameObject go = GameObject.FindGameObjectsWithTag("Player").ToList().Find(g => g.GetPhotonView().owner.ID == switcher.ID);
            PlayerGameplay pg = go.GetComponent<PlayerGameplay>();

else if (Weapons[weapon].IsSecondary)
            {
                if (pg.m_Camera.enabled)
                {
                    pg.Weapons[SelectedWeaponIndex].gameObject.SetActive(false);
                    pg.Weapons[weapon].gameObject.SetActive(true);
                    pg.Weapons[weapon].gameObject.GetComponent<OnAnimationWeapon>().PlayerGameplay = this;
                    pg.FPSAnimator = Weapons[weapon].gameObject.GetComponent<Animator>();
                }

                pg.isReloading = false;

                pg.SoldierAnimator.runtimeAnimatorController = SoldierAnimatorSelection[1];

                pg.WeaponHolder[SelectedWeaponIndex].SetActive(false);
                pg.WeaponHolder[weapon].SetActive(true);
            }```

this is a part of code i use for letting the players switch weapons through the network, it's sent with a photon rpc, but i cant get it to work and i have no idea why

i basically copied my script from the not networked weapon switch and i call the networked weapon switch from the not networked weapon switch
jade glacier
#

The values you pass to Invoke arrives on other clients as the argument values for that RPC.

dusk cargo
#

Ah ok cheers

fallen frigate
#

please can anybody here help me with how to make lobby ,rooms and play together using photon and yeah i have read the documentation of photon and i didn't understand much also i don't want to just copy paste either ,i wanna understand ,so please somebody help me who have experience with photon ,you can dm me ,thanks

gleaming prawn
#

Being straight:

  • if you come up with a few directly technical questions, people may answer
  • if you want someone to go step by step and teach+write the code for you, this means hiring/paying someone for their time spent (possible, but not sure this is what you meant).
  • you can always go for youtube and blog tutorials: http://letmegooglethat.com/?q=pun2+tutorial
drifting shale
#

I am using PUN2 . Is there anyone who can help me make the character move smoothly

dusk cargo
#

Hey can anyone let me know if this is wrong

#

Is it possible for the local player to send variables like this via RPC's?

gleaming prawn
#

what is ScriptablePose?

#

Is it a Scriptable Object?

#

If yes, NO, not possible like that

#

You should send something like:

  • the string name of the scriptable object, so it can be loaded from the receiving RPC (slower)
  • an int pointing to the array index of that scriptable object in an array you define in a ListOfPoses main scriptable object that ALL game clients have (cleaner and faster)
#

It's NEVER possible (or sometimes not advisable) to send these as part of RPC params:

  • game object (not possible, send a way to find the same object)
  • scriptable object (same as above)
  • textures, audio, assets in general (too much data, does not make sense - do as above and send an index/name)
jade glacier
#

Whatever scriptablepose is, you will need to define your own serialization and deserialization handling for it. You can't pass arbitrary objects to photon for serialization. Only supported types automatically serialize.

dusk cargo
#

That you for detailed responses guys. I ended up taking the string and send that in the RPC then using Resources.Load on the networked avatar

#

@gleaming prawn I don't want to have to store all different poses at runtime, on an in-scene object but I agree that way if they were in the scene would be much better

#

@jade glacier Thanks for breaking that down for me. I've only been using Photon for week so still getting the jist of how everything works. Doing it for VR as well poses quite a few extra challenges

#

Would either of you have any advice on how to handle the disconnect between held objects and hands on networked players. Both have different PhotonViews so I can set the streams in a way to pass all the data in synce.

Edit: I've just realised that while you can't modify observed comps, you can disable and enable them which opens up a lot of possibilties

lunar plinth
#

i can't understand why is this saying that object reference is not set to an instance of an object

#

Debug.Log(photonView.Owner.ActorNumber);

lunar plinth
#

got it

lunar plinth
#

i have this simple script to show deaths of a player PlayerScoreboards[i].transform.GetChild(1).GetComponent<Text>().text = "Deaths: " + playerScoreDeaths[PhotonNetwork.PlayerList[i].ActorNumber - 1];

#

but if second player joins

#

i get this IndexOutOfRangeException: Index was outside the bounds of the array.

#

public int[] playerScoreDeaths = new int[6];

#

it seems that it gives an error when array is more then 0

#

localPlayer.transform.GetChild(1).GetComponent<PhotonView>().Owner.ActorNumber this gives the same error

#

playerScore[localPlayer.transform.GetChild(1).GetComponent<PhotonView>().Owner.ActorNumber] = 0;

#

even this

lunar plinth
#

anyone?

gleaming prawn
#

maybe you should join Photon's DIscord

lunar plinth
#

this doesn't seem to be a thing

#

is there a way to not use .ActorNumber but still get player id.

#

because that thing seems to be breaking everything

#

ok i did a little bit more tweaking and...

#
        playerScore[playerId] = 0;```
#

only second line gets an error

#

this one playerScore[playerId] = 0;

jade glacier
#

Is PlayerScore a dictionary or an array?

#

This looks like a C# understanding problem at a glance, not actually a networking issue.

sterile ore
#

mirror only updates movment unitl other player joins the server then it leaves the player standnig even if i move on the other client ill be still

jade glacier
#

Likely you aren't disabling your controller code if hasauthority == false. I would try explaining your problem in the mirror discord. @sterile ore

sterile ore
#

ok

#

thx

lunar plinth
#

i fixed it like 10 minutes before you wrote it emotitron

white wedge
#

does anyone know of a good networking library for unity 2020.1? mirror networking doesn't work for me and has errors upon building, photon is expensive to use, and UNET is decprecated and i cant even find it anymore in the actual code

#

telepathy is not resolved in mirror networking so i cant use that :/

jade glacier
#

Mirror should work.
And Pun2 only costs money if your game is successful.
Unet and Mirror both will require hosting or nat punch, but do have a Unity exe for a server. Unet is deprecated, but it would give you about the same set of difficulties as Mirror/MLAPI.

Your requirements for networking seem a bit steep?

#

Just hit the Mirror discord for help resolving that transport issue.

white wedge
#

i just want a working library that doesnt cost because i want to host it myself

#

does mirror work in 2020.1?

#

it says it requires 2018 on their docs so maybe thats the problem?

#

alright well i might have to join yet another discord server just for this :/

jade glacier
#

No idea, hit up their discord and see

#

If you are losing patience with networking just picking a library, I have to warn you that the actual development experience is likely not going to be your bag.

#

Networking games is the most difficult part of game dev.

#

Expect lots of frustration and failure along the way.

shut yarrow
#

And what emotitron says is true, it's a lot of frustration or maybe you don't experience it like that, it's nonetheless a lot of work

#

There is no silver bullet solution however so you need to pick something and get some experience along the way

grizzled narwhal
#

@white wedge mlapi works in 2020.1

somber drum
#

hm so,

DefaultPool failed to load "APrefabInResources". Make sure it's in a "Resources" folder. Or use a custom IPunPrefabPool.
#

this is using a well known kit, which works all until I close out of unity for the night and restart, then it throws the above.

#

"ask the dev for help" he's pretty inactive, and I'd like to solve this myself if possible

#

(photon)

#

oddly enough it was to do with my scene, which makes sense if it's running at a certain- I don't even know. Whatever it works now lol.

jade glacier
#

"APrefabInResources" looks an awful lot like a placeholder

#

like "InsertNameOfYourPrefabHere"

nocturne current
#

Does anyone know if services like Multiplay or AWS Gamelift provide their own networking library, or are they purely hosting platforms, and a library like MLAPI or Mirror is still needed?

somber drum
#

@jade glacier lol yes, but unless me renaming it for the sake of clarify effects it

#

to be clear it is assigned and it is an actual prefab,

#

original name was "AISoldier" if that helps

#

which it doesn't, so anyway.. that's my life

#

@nocturne current From what I understand no they will not providing a network library for your game they are just hosting what you've already made

#

I'm not sure if that's the case for lumberyard with what I can only assume would be a tight integration but for unity it's not the case

#

MLAPI is a great choice, though mirror has a far larger community / examples so on

nocturne current
#

Alright thanks! That is was I was assuming and hoping for so that there is more flexibility when it comes time to actually work on hosting.

#

I've been stuck between MLAPI and Mirror, so I haven't made a decision yet. Are you aware of any "success stories" for games using MLAPI?

somber drum
#

"success" is relative but I would say mirror definitely has the lead in that

sacred grail
#

from looking at Mirror and MLAPI the advantage for the latter seems to be its code seems very concise, clean and performant. It also has some advanced features, in the client prediction department.

#

MLAPI looks like it will be a bit more work to get started, but for more advanced projects will likely save time I suspect.

somber drum
#

If you know what you're doing definitely go with MLAPI, just starting out I'd stick with mirror

#

some pretty decent names in mirrors book, using it myself currently so I'm a bit biased lol. Though MLAPI was my first choice, community support stood out

sacred grail
#

for my project I am trying to decide if I should just go with the new netcode, since I am starting with 2020.2 or if I should use MLAPI.

nocturne current
#

Awesome! I'll take a look at comparisons and go from there. I'm starting to lean more towards MLAPI.

somber drum
#

Good luck to ya!

#

@sacred grail I'm waiting a bit to see it fleshed out myself I think I saw some of it recently looks pretty cool

sacred grail
#

ya I am leaning to using the new netcode, simply because my project wont be done for a couple years lol

somber drum
#

fair enough

sacred grail
#

and I want to be able to support a couple hundred players ideally (Rust supports 300 players).

nocturne current
#

DarkStar, I spent a month or so dealing with the current state of DOTS, and I must say I did not a have a great experience with it. The technology is there, and it is highly capable, but there are countless bugs and quirks associated with it.

somber drum
nocturne current
#

If you have the time and are willing to go through many code changes as DOTS comes out of preview, I would say go for it.

sacred grail
#

Danmw3 ya same. But since my project time horizon is a couple years and I don't need dots for the majority of the game play, just the more complex work and I want to use havok physics it makes sense for me.

nocturne current
#

My final straw was when something panicked, threw a invalid memory address exception, and managed to crash several other programs including my GPU drivers.

#

At that point I just didn't even want to know what other issues there might be.

sacred grail
#

understood, I suspect dots will be pretty stable in 6-9 months. the recent changes have made the code quite a bit easier to use and I suspect that will continue.

nocturne current
#

I sure hope so with Unity's change of pace and focusing more on ironing out all of the "half-baked" features.

sacred grail
#

I want to push some boundaries with my project so I kinda need some of the newer stuff. i.e. latest HDRP + Havok gives me 50,000 meter maps without floating point issues.

weak plinth
#

how would i select a random player in the server?

sterile ore
#

@weak plinth give each player their own number or put them in array then choose one

#

how to make so that rach client has an invididual camera

weak plinth
#

give each player their own number or put them in array then choose one
How? When I use an array currently it’s different for all clients

#

And how would I match the correct number with the corresponding gamepbject

sterile ore
#

wait do you use mirror*

#

@weak plinth

weak plinth
#

Nah pun

sterile ore
#

oof

#

then i cant help you

jade glacier
#

@weak plinth unless you get into making server plugins, you would probably want to have the Master Client do what you are describing. It can "act" like the server as needed.

#

Have the master select a random actorID and RPC that to all others.

weak plinth
#

ActorID?

mossy terrace
grand skiff
#

Does Photon send RPC to only 1 room or all rooms?

jade glacier
#

Players can only be in one room

grand skiff
#

What do you mean

fallen frigate
#

thats the thing i wanna learn ,exactly same

grand skiff
#

i'm making a server matchlist and i want to get all rooms' data.

#

any suggestion?

jade glacier
#

I don't believe you can RPC outside of a room. If you are connected to the master server, that isn't something you can do.

fallen frigate
#

i wanna learn it too , how can i learn this ? pls help me guys

grand skiff
#

so is it impossible?

jade glacier
#

You aren't in a room, so there are no other players

#

Matchmaking and being in a Game Room are very different.

fallen frigate
#

please somebody help me with photon ,please i am really struggling from a week

grand skiff
#

i got what do you mean, but so what should i do? Do you know anything that can help me?

jade glacier
#

Have you completed the Getting Started tutorial? @fallen frigate

fallen frigate
#

yeah i installed photon into my project ,already made an account in photon .com and know how to connect with master server

jade glacier
#

Until you get through the basics, there isn't much anyone will be able to help you with.

fallen frigate
#

i have read that whole article

#

and kinda have idea how multiplayer works

#

rooms or lobby etc

#

but i don't understand how to use it in my unity project

grand skiff
#

Is there a way to RPC to another room?

jade glacier
#

I am not sure what to tell you. The point of the tutorial is to walk you through how to get a working networked project happening. @fallen frigate Be sure to DO the tutorial, not just skim it.

#

@grand skiff no

grand skiff
#

😦

fallen frigate
#

ok but i don't want to make my player randomly join room

grand skiff
#

how can i get list of rooms in PHOTON?

jade glacier
#

If you have a specific question, you can of course ask it @fallen frigate

fallen frigate
#

3 days ago i followed some tutorial from youtube and i made my player radomy join or create a room from that ,in which i attached my launcher script with ui scene and after entering name of player it instantiate it in room after clicking join button

but i want something like among us ,in which we can create a room give a code to friends and they can join it so we can play together

shut yarrow
#

You're trying to go too fast I think

#

First you have to know how to make a room

fallen frigate
#

by creating a scene ?

shut yarrow
#

I mean you need to know a little bit about how PUN works

fallen frigate
#

yeah

#

thats why i wanna learn

#

not just wanna download some projects from github and use them

shut yarrow
#

I haven't played among us so no idea how their code works, but I did something similar where you'd go to a URL and it would connect you to a photon room

fallen frigate
#

yeah yeah something like that

shut yarrow
#

Basically the one who created the room can create a URL and someone else can paste that URL in the game, the name of the room is then obtained through a http request and then you can join

fallen frigate
#

yes

#

host can create and client can only join

shut yarrow
#

That's not a photon question however, you'd have to know a little bit about web requests too and how to create a simple webserver to help with matters like this

fallen frigate
#

yes i know it is pretty complex process without photon thats why i am using photon

shut yarrow
#

Creating the room is as simple as calling PhotonNetwork.CreateRoom, then you (or rather the client who created the room) has to do a http post request, passing the roomname to a webserver which stores the room name and returns a web addres or some code that another client can then use to connect

fallen frigate
#

like there is a demo asteroid scene in photon and i just wanna make something similar to it ,neat and simple

shut yarrow
#

I think that's wiser to just try and do something simple like that first so you have an idea of how PUN works

fallen frigate
#

yes i am aiming for very simple ,just to learn not even a actual project ,how it works ,how i can use but i passed 7 days without much progress bcz ,i only understand

how to install and integrate photon in your scene
how to connect with master server
and thats all with some theoretical stuff

#

i have even read all the documentation page of photon website

prime beacon
#

so you want to create a room and pass room name to other clients right?

fallen frigate
#

yes

prime beacon
#

then call PhotonNetwork.JoinRoom("roomname") on client

fallen frigate
#

with room name right ?

prime beacon
#

yeah

fallen frigate
#

so first i have to make a empty gameobject with photonmanager script attached to it ,in which i will do that stuff and i can trigger any funtion in that script with button on click method right ?

prime beacon
#

photonmanager?

fallen frigate
#

script name @prime beacon and sorry here was a powercut thats why i took so long to respond

prime beacon
#

yes

#

make sure you are connected to master before creating room

#

@fallen frigate

fallen frigate
#

ok ,can i ask you if i face any problem @prime beacon ?

prime beacon
#

well I don't use PUN actively just have general idea about it

#

but sure you can ask

jade glacier
#

Always better to just post simple clear questions to the channel. Whoever knows the answer and is free will try to help.

sterile ore
#

how to have each client have their own camera(camera is a child of a player) in mirror?

jade glacier
#

Disable the camera on your player prefab based on NetworkIdentity.hasAuthority is the most simplistic way.

candid flame
somber drum
#
public struct Item
{
    public string name;
    public int amount;
    public Color32 color;
}

public class Player : NetworkBehaviour
{
    readonly SyncList<Item> inventory = new SyncList<Item>();

    public int coins = 100;

    [Command]
    public void CmdPurchase(string itemName)
    {
        if (coins > 10)
        {
            coins -= 10;
            Item item = new Item
            {
                name = "Sword",
                amount = 3,
                color = new Color32(125, 125, 125, 255)
            };

            // during next synchronization,  all clients will see the item
            inventory.Add(item);
        }
    }
}
#

does anyone know why this would result in:
"Cannot create an instance of the abstract class or interface"?
at line:
🛑 readonly SyncList<Item> inventory = new SyncList<Item>();🛑

weak plinth
#

Assuming mirror; SyncList<T> is an abstract class. You have to derive from it and implement yourself (unless using one of the prebuilt types:

   public class SyncListString : SyncList<string>
   {
       protected override void SerializeItem(NetworkWriter writer, string item) => writer.WriteString(item);
       protected override string DeserializeItem(NetworkReader reader) => reader.ReadString();
   }
somber drum
#

so my network behavior class is fine, I need this in addition to it

jade glacier
#

What is your Item class?

somber drum
#

probably not what it's supposed to be I would assume, given the example provided

jade glacier
#

I mean, can you paste that class?

somber drum
#

in my case item would be player, all I'm trying to do is sync a list of players
public class Player : NetworkBehaviourNonAlloc {

#

it's not something I can paste here no

#

the entire class

jade glacier
#

You are trying to make a List of that and sync it?

somber drum
#

a list of gameobjects that hold the player class, sync that as a list yep

jade glacier
#

yeah, that is going to not end well.

somber drum
#

I know how to offline, why not online with synclist?

jade glacier
#

your class or struct I would expect needs to be restricted to primitives

somber drum
#

whenever a client joins, if not added already add them to the list and sync- that seems simple

jade glacier
#

a MonoB is a whole different animal.

#

The issue is you are asking Mirror to serialize a very complex object

somber drum
#

would you recommend a more simple sync choice then?

#

maybe their id

#

but like eh.. I would like to access them more easily

jade glacier
#

A value or a simple struct/class that only contains items you want synced

somber drum
#

really I would just like their object

jade glacier
#

If you try to sync a MonoB it will 1) Probably puke on that and just say no and 2) End up serializaing a bunch of garbage fields that have no business being serialized.

somber drum
#

understood

#

synclist I take it is for very specific cases then, that makes sense

jade glacier
#

If serialization were that easy, you could just RPC(MyScene) and be done with it... but obviously that can't be done.

somber drum
#

haha right

#

my bad

lunar plinth
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class FragmentsCollision : MonoBehaviourPun
{
    public float damage;
    public int GrenadeOwner;
    void OnCollisionEnter2D(Collision2D collision)
    {
        photonView.RPC("DamagePlayer", RpcTarget.All, collision.transform);
    }

    [PunRPC]
    void DamagePlayer(Transform playerTransf)
    {
        Health hpScript = playerTransf.GetComponent<Health>();
        if (hpScript != null)
        {
            hpScript.damage(damage, GrenadeOwner);
        }
        Destroy(gameObject);
    }
}```
#

why can't i pass transform

#

i did it before

#

but this specific one doesn't want to work

high night
#

@lunar plinth You probably can pass the pun network identity component

#

i think

#

i dont know the exact name of the component

#

i am talking about that one component you have on all networked objects, that enables you to do pun stuff

lunar plinth
#

ah PhotonView

high night
#

yeah i think

#

i think you will have to pass that in param

#

or maybe gameobject @lunar plinth, it could work as well
its been a while and i dont do networking this way

lunar plinth
#

neither of those worked

#

i still don't understand RPC. I changed it to just a function and it works

#

can someone please explain what is an actual RPC use

#

i tried searching tutorials

#

but they don't explain why do i need it over funtion

#

documentation doesn't seem that clear also

jade glacier
#

You can't pass transform to pun2 serialization.

lunar plinth
#

what can i pass through it tho?

jade glacier
#

Vector2, vector3, quaternions

lunar plinth
#

so just numbers?

#

Received RPC "Explode" for viewID 0 but this PhotonView does not exist! Was remote PV. Remote called. By: #02 '643' Maybe GO was destroyed but RPC not cleaned up. what does that even mean

#

grenade has a photonView

#

and it's id is actually 0

jade glacier
#

Pretty sure zero isn't a valid view Id, so not sure how you have one with that number.

lunar plinth
#

ah i was instantiating it not by photonNetwork.instantiate

#

but there is a problem

#

if i instantiate inside RPC. There is 2 grenades appearing. One is the correct one that completely works. And another one just kinda sits there

#

i feel like it's not 2 but 1 per player

weak plinth
#

for some reason PhotonNetwork.AutomaticallySyncScene isn't working, the only person that doesn't go into the new scene is the master client

#

Anyone know what’s going on?

jade glacier
#

The master client should be where scene changes originate from no?

weak plinth
#

i thought that would work but i still had issues

#

just tested it, the masterclient stays in the previous scebe

#

should i change levels in an rpc or a normal void using photon.loadlevel

#

update: even when its not in an rpc the master client doesnt go in the new level

jade glacier
#

I don't really touch that part of Pun2 so I don't know what the correct or best practices are. But I would read the documentation on it and look at some of the sample scenes for guidance. @weak plinth

weak plinth
#

okay

lunar plinth
#

are RPCs like a static function?

prime beacon
#

@weak plinth master client should load scene

#
if (PhotonNetwork.IsMasterClient)
{
   LoadGameScene();
}```
weak plinth
#

oki

#

as well as the photon load?

jade glacier
#

@lunar plinth You really need to complete the Pun2 basics tutorials and read the docs for some of this stuff.

lunar plinth
#

i kinda rode through the documentation

#

and watched some basic tutorial series

prime beacon
#
 if (PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.LoadLevel("Arena");
        }
#

also this -> PhotonNetwork.AutomaticallySyncScene = true;

jade glacier
#

I can tell @lunar plinth

lunar plinth
#

i skipped something. Little things.

#

i probably shouldn't have skipped

jade glacier
#

Networking is VERY difficult. Don't kneecap yourself by trying to skip to the end.

#

You will end up stuck on simple things for weeks.

lunar plinth
#

now when i think about it the only thing i skipped was raise event

#

but here is a question. Again i want to transfer a game object to the RPS. But how can i convert the game object into the number and then back? Is that even possible?

jade glacier
#

The question is more vague than you think, but what you are describing cannot be done. You don't serialize "objects" and have them instantiate on the other end.

#

You instantiate objects using PhotonNetwork.Instantiate, and then you sync up values within those objects.

lunar plinth
#

The reason why i need this is because i instantiate an object in the normal function via PhotonNetwork.Instantiate and then i want to parent it to the player

#

but i parent it via an rpc so it parents to the player on every pc

jade glacier
#

you can serialize reparenting, though you will need to come up with a way of indexing the parent object so that all clients agree on its index.

lunar plinth
#

o o f

#

well time to get stuck on this part for another 5 hours

#

wait if i make an RPC that will fire a normal function will it work?

jade glacier
#

Or just read up on the docs and finish the tutorials so you aren't struggling so much 🙂

lunar plinth
slate sable
#

What is according to you guys the best and the most simple way to make a server which is can be joined from other ip's for a beginner?

shut yarrow
#

There is no best nor there is any simple way

#

And although I understand why you are asking this question and this channel is supposed to be about networking, what have you done so far to find out what options there are that you could choose from?

#

Because if you want to make any type of multiplayer game, it's important to have a good idea of what requirements you have and what options in libraries you have, just telling you what is good in your case is impossible

jade glacier
#

Do tutorials for Mirror and Pun2 at the very least first. Then decide on your game goals... THEN you might be able to start thinking about the right library choice.

#

Any answers you get to your question will look like a meaningless wall of jargon right now.

terse relic
#

What type of game u making

#

Photon is simplest to learn but if u plan to launch a game then think of the best way to monetize it cuz photon will cost a bit. If u have cash on hand then I suggest buying a small dedicated server and using mirror. Again monetize as u will need to expand the server's player capacity. For a beginner photon pun2 is best

shut yarrow
#

Agree emitotron and I also think the meaning of simple can be misleading. I'm using a very simple library, but only in terms of setting it up so it's ready to take connections and receive data. On the flipside there is no handholding with anything. A big portion of the work is in making the actual communication between server/client possible through packet structures that are easy to convert from/to binary, but also keeping their footprint small because you can't be wasting bandwidth while sending data. Another thing I stumbled into just by going through the experience without any formal education in networking is the fact that data can get corrupted while making its way to its destination, so that's another thing not being done by this 'simple' library. And another thing to consider is protecting data so it can't be easily snooped/mangled with by using something like wireshark, so encryption is another important thing. These are just a few of the downsides of using a library that is theoretically very simple (and I personally don't mind this) but I wouldn't recommend this to anyone who is starting or hasn't been programming for a decent amount of years.

terse relic
#

As the person above stated, going full AAA server is not something you will be able to manage without years of exp but a simple server is prone to corruption, lag and hacks. Photon pretty much eliminates corruption and lag is based on whether your code is complex/simple and how heavy your stage is. However, you will face hackers if ur game is online multiplayer and incentives competition. For a starter I recommend making ppl create rooms and play with their friends rather than pvp

#

Btw guys. When using photon for a card game. All I have to do is make logic for one player and photon will handle the enemy side. A simple if(!photon view.mine) should handle the enemy player side right?

shut yarrow
#

In theory yes, that's how you can differentiate between the local player and a remote player

#

Well let me try to rephrase. You need to do logic for both one way or another, but checking whether you own the photonview or not is an important aspect of it

#

I've done this in a very similar manner on my server. The server creates objects and assigns it a unique object ID. This object will also be assigned to a player which has his own unique ID. I then update all clients with which objects exist by passing them some information about what type of object it is, the object ID, and which player owns it. Then on the client side the player has a game object with a NetworkObject component on it, and he can know if he owns it by checking isLocalPlayer on the NetworkObject component

#

So in practice these objects can have any script on them which can handle both local/remote player, depending on whether the local player owns the object or not it either can control it, or just set the object state that the server sends

grand skiff
#

@jade glacier i found solution of the question that i asked yesterday

#

thanks

grizzled narwhal
#

@jade glacier I've tried your HalfUtilities to compress my rotation vectors to float16 but I noticed precision is pretty bad on float16. Even for euler angles the loss is still .22 degrees. Just multiplying my euler angles * 1000 and casting to short gives more accurate results. Is this the wrong use case?

jade glacier
#

half float is pretty terrible for anything not close to origin

#

what kind of values are you putting into it?

#

make sure you normalize rotation into a -180 to 180 range for best resolution

grizzled narwhal
#

I use +pi -pi

jade glacier
#

What are the actual values being given to the compressor?

#

-3.14 to 3.14 ?

#

that should yield pretty reasonable results. Though not sure why you are using that range.

#

To apply it to a transform you need it in degrees.

#

or a quat

#

HalfUtilities aren't mine btw, its a public library that everyone uses. But it does have significantly less resolution that normal floats.

And halffloats are not ideal for rotation, since rotation is range based.

#

@grizzled narwhal

grizzled narwhal
#

Its rotation so -3.14 to 3.14 is the best format

#

it has 2^-9 precision

#

thats fine

#

but for anything else its pretty bad

jade glacier
#

I would have to see your code. Not following what you are doing at all.

#

But regardless, half float isn't ideal for rotation.

#

Typically rotation is done with smallest three quat, or compressing euler floats to ranges.

nimble ermine
#

Hey, I have a problem with photon, whenever I test my game inside the editor the first time it works fine, but the second time I try to test it it crashes, how can I close photon threads? I know it's photon cuase whenever I don't interact with it I have no problems. (using Pun classic)

weak plinth
#

hey guys i tried using photon bolt for the multiplayer in my game it works and all but your controlling the wrong player does anyone know a fix?

jade glacier
#

First question: Why Pun1 ?

#

@nimble ermine

nimble ermine
#

It’a an old project

jade glacier
#

@weak plinth Not a lot of bolt users in this channel, typically better to ask Photon Bolt questions on their discord

weak plinth
#

they have a discord?

jade glacier
#

yeah

weak plinth
#

alr

#

does anyone use pun 2?

jade glacier
#

Lots of people here yeah. And I am one of its developers

#

@weak plinth

weak plinth
#

dude

#

wtf

#

if i knew i wouldnt have switched to bolt

#

i was having movement problems so i gave up

jade glacier
#

They are different animals. I would use the one that fits your games needs

weak plinth
#

a simple fps shooter

#

by chance did u ever have this glitch?

#

when u join another lobby the other player is lagging up and down

jade glacier
#

I've gotten all kinds of glitches in the past. If I have a bug in my code sure.

#

Have you competed tutorials for the various engine options you are considering?

weak plinth
#

wait what

#

i only know pun and bolt

#

theres more?

jade glacier
#

Mirror and MLAPI are also popular. Different architecture and hosting requirements.

weak plinth
#

i just need something to play with friends

#

like 1v1

#

or 2v2s

#

have you heard of welton king?

#

i was following his tutorials and then i got the bug and then i switched

jade glacier
#

nope

weak plinth
#

hes a nice guy

#

but dude went poof

#

like 5 months ago

prime beacon
#

Photon docs are very good

#

follow the doc & tutorial

#

I just started using PUN like 2 weeks ago

weak plinth
#

yeah i added lag compensation using the docs

#

it reduced it by alot

#

but its still bad

jade glacier
#

Lag Compensation similar to what is being described in the Pun2 doc on the topic is mostly only useful for shifting the timeframe of deterministic things, like projectiles.

#

Trying to lag compensate something non-deterministic like a player will produce insane rubberbanding at best.

weak plinth
#

see im kinda retarded

#

i didnt understand a single line from that sentence

jade glacier
#

then you are trying to do advance stuff too soon. Just complete the official tutorials for Pun2, Mirror and anything else you are curious about before even trying to get advanced or make any choices.

weak plinth
#

indeed

#

i only started unity a week ago

jade glacier
#

Definitely don't even think about networking yet then.

#

Learning unity and networking at the same time will lead to months of slow grinding failure.

weak plinth
#

yes

nimble ermine
#

Hey, I have a problem with photon, whenever I test my game inside the editor the first time it works fine, but the second time I try to test it it crashes, how can I close photon threads? I know it's photon cuase whenever I don't interact with it I have no problems. (using Pun classic)

drifting shale
#

Sync view with others devices is different, how can i fix it

weak plinth
#

Hello , i use Photon in Unity. On click button i want to leave from room and disconnect in the same time.

#

I have little problem with disconnect.

weak plinth
#

Operation LeaveRoom (254) not allowed on current server (MasterServer) #1 error

#

NotImplementedException: The method or operation is not implemented. #2 error

frank quiver
#

If I not mistaken, disconnect only allow when u in master server. When u in the room, you're in game server not master server, so you probably need to wait until you reconnected back to master server after you leave room then only call the disconnect

weak plinth
#

You have right.

#

I understood what happend.

#

When i connect with game server i don't open room yet. I have leave from room (#1). About (#2) you explain it 😉

#

But how can i disconnect from game server ?

#

I have another weird situation. If i connect to master server (and game server) and too long stay there i have another errors:

#

NetworkPeer broke! (#1)

#

NullReferenceException: Object reference not set to an instance of an object (#2)

timid cipher
#

what options do we have to make multiplayer in unity thats not p2p?

lusty crow
#

there are headless unity server instances,
you could just write your own backend in any language,
and there are services that allow you to have some authoritative server code, I think (?) photon bolt is one of them?

grizzled narwhal
#

You can use unity headless build or write your own backend (but that can't make of unity physics so you might have problems there)

ocean compass
#

Is there a way to make a server for free and use for unity to an online unity game ?

grizzled narwhal
#

depends. If you are a student you can maybe get azure / aws student credits else nope

lusty crow
#

heroku possibly but.. that is also limited

weak plinth
#

Hello,
If possible, I would like to gather information on how I can create. Opponent draw system (random selection) that will retrieve the names of players to be drawn from Play Google (accounts)

prisma girder
#

The major cloud providers all have free tiers

weak plinth
#

Okay But talking about system of select opponent if you know what i mean 😉

mild reef
#

Ewww PUN

weak plinth
#

hey guys i tried using photon pun 2 for my game but the movement is horrible i tried to use photon transform view and photon transform view classic and i even tried to add lag compensation but none of those worked the players keep glitching everywhere

#

does anyone know how to fix this?

jade glacier
#

Hard to say without any information. But a usual problem is not disabling your controller code if IsMine == false

#

@weak plinth

#

Have you completed the Pun basics tutorial?

weak plinth
#

yes

jade glacier
#

You'll have to give a lot more info then

#

You have disabled all controller code as required for the syncs to work?

nimble ermine
#

can anyone help me? I am upgrading from Pun 1 to Pun 2 (bn is a string[])

nimble ermine
#

@jade glacier you are a developer of pun 2 right?

jade glacier
#

One of them

nimble ermine
#

do you think you can help me?

jade glacier
#

You crossposted that same question in multiple places

#

I responded

nimble ermine
#

where?

urban shadow
#

The photon discord.

nimble ermine
#

found it

jade glacier
#

How many places did you crosspost? (that is a frowned on practice... typically ask in one place and wait)

#

people on one of these channels are in most of them, so you just clutter up everyone's feeds.

urban shadow
#

👆

nimble ermine
#

oh didn't know that sorry

#

I posted on 2 servers

lunar plinth
#

i have a pun 2 function cs [PunRPC] void SetChildLol(int Weaponint, int TransformInt) { Transform WeaponTransf = PhotonView.Find(Weaponint).transform; Transform PlayerTransf = PhotonView.Find(TransformInt).transform; photonView.RPC("ChatMessage", RpcTarget.All); WeaponTransf.parent = PlayerTransf.GetChild(1); WeaponTransf.GetComponent<ShootGun>().SendDFNL(); } but when i'm trying to call it it gives this error

#

this is how i call it cs localPlayer.transform.GetChild(1).GetComponent<PhotonView>().RPC("SetChildLol", RpcTarget.All, Weapon.GetComponent<PhotonView>().ViewID, localPlayer.transform.GetChild(1).GetComponent<PhotonView>().ViewID);

jade glacier
#

yeah, that error message is correct

sacred grail
#

looking for opinions from those who have looked into the most recent dotnets code, if someone was just starting a large scale multiplayer game today would you use the new official netcode or mlapi? If using the new dots networking, does that mean one has to use 100% dots entities for anything that needs to be synced?

hybrid arrow
#

How on earth do you invoke the Instantiate(); function on the main thread..
I need to run the function that continuously listens for incoming connections in a infinite while loop in a separate thread to not deadlock the game.. Why do I feel like the solution to this will require some overly engineered and complex solution with 100 layers of abstraction added to it

lusty crow
#

such things are often handled by a command queue,
you could have a queue or another collection type with locking, in other threads you enqueue tasks that have to be executed on the main thread,
and each frame, the main thread can poll for tasks to execute from that queue, if any are available, and execute them

stray moth
#

Hey guys how does one update UI over the network for like what i am trying to do is set a lobby name so the other player can join it when it sees it on the room listing

lusty crow
#

something common would be to have a central server, for example for match making (if you don't have that, you probably have a client as host, but then connection can be more tricky),

so if a client chooses to open up a lobby, the server receives a request, opens a lobby with a specific name or code, and it would send that code back to the client, then with the received package, you could update an UI element to display the text of the code or name, so that the player can share it with others

stray moth
#

Using Pun btw

#

so I think thats taken care off

lusty crow
#

then there should also be a kind of request to join a lobby, with the data payload being the name or code of the lobby

(oh sorry, not sure about framework specifics, but I think photon should have something for it yeah)

stray moth
#

The create lobby works fine is just seeing the other lobby from the other player is not working

azure crown
#

Would 200 players be possible in a single room with a low poly game?

#

Games like Battlefield 4 have up to 64 players per room, and it's not even low-poly.

jade glacier
#

Poly doesn't matter. Number of objects sending data, and what kind of data matters

#

You aren't sending polygons with networking

proven crypt
#

@azure crown yes as long as your backend infra is capable of handling that and what scale you are looking at, for example, GTA SAMP have server hosting 1000 players in a single world

azure crown
#

Whats SAMP, I know what GTA is obviously.

#

Looked it up, thanks for the info!

fair cosmos
#

And its raknet :) old tech

winter kraken
#

I wrote my server using system.net, and know nothing about dots. How difficult would it be to switch my server to use dots?

grizzled narwhal
#

About as long as a piece of string is

winter kraken
#

Was that a reply to me @grizzled narwhal ?

bright wing
#

Can anyone point me in the right direction for how to do websockets using a webGL build for unity? Is there a standard way of doing this?

#

From what im seeing, using a library like websocket-sharp or using a JavaScript plugin to implement seem to be the two options?

slow monolith
#
        rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
        Camera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
        transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed * Time.deltaTime, 0);```
#

so this seems to fix my camera shakiness

#

by adding time.deltatime

#

however this locks it to one axis

#

if I remove deltatime it allows me to look up and down, but the shakiness comes back

#

how did I get in the networking channel wtf

wind adder
#

Does anybody have any tips for safe multiplayer modding? How can I stop servers from running malicous code on clients? Is there a way to sandbox assetpacks?

wind adder
#

From what I can see, the only way to do this completly safely is force servers to use a sandboxed scripting language, but thats sorta a nuclear option I think. Are there other methods that people have used?

weak plinth
#

Done this with sandboxed lua

#

Does your client need to run user code supplied from the server?

upbeat basalt
#

Is there a specific "best way" to save a json downloaded from an API in Unity?
I've heard everything from just storing it in Resources, storing it in Assets to encrypting it and hiding it among some random asset folder.
I don't need it to be super secure since it's just gonna store a rule set for my biomes that are generated.

weak plinth
#

In the editor or during runtime?

upbeat basalt
#

I do everything in code, so runtime.

grizzled narwhal
#

@winter kraken Yes cause your question is impossible to answer. But I can say the following : dots atm is in beta so its buggy, there are little resources out there, and it will probably change until the release so code you write now will be broken in a few versions

stray moth
#

Anyone here good with photon?

#

If you are i need help getting my players to load the same scene

fallen frigate
#

how to make players gather and join together using pun
currently what i have done
an interface with a button to join
integrated pun into my project
and an script to make room and connect with master server with feedbacks
a 2d player prefab which can move left and right
and 2 scenes one is empty for player to gather together and another is to for ui which i above mentioned
i hope this will help you to understand project situation
please help

prime beacon
#

@stray moth PUN?

stray moth
#

Yes

prime beacon
#

PhotonNetwork.AutomaticallySyncScene = true;

#

Set this

stray moth
#

I have

prime beacon
#

And only master client should load scene

#

If(masterclient)
LoadScene

stray moth
#

I think my rooms are messed up,thats why let me get back to u

#

The room name is exactly the same but it wont start up the scene for both players

#

@prime beacon

lunar plinth
#

i have this script that should add a player to the teams ```

[PunRPC]
void SetUpThings(int teamToAddPlayer)
{
    if (teamToAddPlayer == 0)
    {
        redPlayers++;
    }
    else if (teamToAddPlayer == 1)
    {
        bluePlayers++;
    }
}

// Start is called before the first frame update
void Start()
{
    Vector3 pos = new Vector3(0,0, -25);
    MenuInstantiated.SetActive(true);

    Debug.Log(redPlayers);
    Debug.Log(bluePlayers);

    if (redPlayers == bluePlayers)
    {
        teamBuffered = 1;
        team = 1;
    }
    else if (redPlayers > bluePlayers)
    {
        teamBuffered = 1;
        team = 1;
    }
    else if (redPlayers < bluePlayers)
    {
        teamBuffered = 0;
        team = 0;
    }
    photonView.RPC("SetUpThings", RpcTarget.AllBuffered, teamBuffered);
}``` but it looks like buffered RPC happens a bit to late
#

so first player team is assigned corresponding to the amount of the players in the team

#

and THEN you get a player amount

#

how can i make it so i get the player amount first

fallen frigate
#

how to make players gather and join together using pun
currently what i have done
an interface with a button to join
integrated pun into my project
and an script to make room and connect with master server with feedbacks
a 2d player prefab which can move left and right
and 2 scenes one is empty for player to gather together and another is to for ui which i above mentioned
i hope this will help you to understand project situation
please help
@fallen frigate no one answered after detailed question

fallen frigate
#

i successfully created a room according to script or debug testing

#

but can't able to join using random room

#

and getting this error

tired locust
#

Does anyone know of an in-depth authoritative server architecture books/courses?

crystal galleon
#

mmmmmmm itamar567

#

what are you writing

#

bopob

#

f

wind adder
#

@weak plinth Hi, sorry pulling up yesterdays converstation because I went to bed. Yeah I'd like to get compiled code running on the client if possible. Is that feasible?

grizzled narwhal
#

@crystal galleon Don't ping admins

#

They are admins not support staff

#

And to get help post a specific question

#

Not 'Uwu we need help'

crystal galleon
#

...

#

?

#

bruh

oak flower
#

@tired locust Please don't post off-topic

fallen frigate
fallen frigate
#

😞

hollow pike
jade glacier
#

@fallen frigate have you successfully finished the tutorial? It covers the basics of matchmaking. Your question is a little hard to make sense of though.

ancient iris
#

How do you give a download link to your friends for your multiplayer game without fully building it.

#

I just want to give it to them to see if it works and to test it

upbeat basalt
#

you still need to build it @ancient iris

#

Since it is just a test build, you could select all the files in the build folder, right click, and select "send to zip." Then you would send that file to your friends, either via e-mail or whatever online upload/download option you choose.

wind adder
#

are the new multiplayer tools out yet? I cant seem to find any docs for it

ancient iris
#

How would you test out ur own multiplayer urself?

#

If u don't have any friends

wind adder
#

you could run the server on your own computer and connect using localhost

#

ofcourse you'd want to do major testing with a remote PC before you roll anything out

ancient iris
#

when i was trying to build it

silver steeple
#

I think that's an option you need to select when your installing unity

ancient iris
#

I installed it but then It still says the same error

#

Do I need to make another whole project?

#

If I installed it just now

fallen frigate
#

@fallen frigate have you successfully finished the tutorial? It covers the basics of matchmaking. Your question is a little hard to make sense of though.
@jade glacier which one ?

ancient iris
#

@silver steeple

spring crane
#

@ancient iris No. Projects and Unity versions (and its modules) are separate

jade glacier
fallen frigate
#

i was watching a youtube tutorial on pun2 rooms

#

by info gamer

#

and i followed that

jade glacier
#

If you can't get through the basics tutorial, you may want to hold off on networking until you get more Unity experience. @fallen frigate

fallen frigate
#

@jade glacier

#

like i have experience with unity

#

and made 2d games with it

#

i am trying my best to figure out

#

but

jade glacier
#

That error says exactly what is wrong though

fallen frigate
#

this error i so confusing

#

like i have put a debug statement when i connectedtomaster ()

#

which said i am already connected to master

#

and i can't able to join room after creating it

#

using joinrandomroom()

#

thats the whole situation

#

and i don't know what that error even mean ?

#

and for which callback i should wait?

#

@jade glacier

#

😒

jade glacier
#

You have to do the tutorials to understand the process of matchmaking and then joining a room.

#

No one is going to be able to help you if you can't get through the basics tutorials @fallen frigate

fallen frigate
#

ok

#

thanks

jade glacier
#

your particular error is saying you are connected to a game room already, and you aren't on the master server (matchmaking server)

fallen frigate
#

yes but i already figured that out

#

how can i i know how many joined the room ?

#

like how to monitor those who joined the room

#

is there any method in photon ?

#

to do that ?

copper wadi
#
private void SpawnPlayer()
    {
        GameObject go = PhotonNetwork.Instantiate(Gamehandler.Terrorist.name, Gamehandler.FFASpawns[Random.Range(0, Gamehandler.FFASpawns.Count)].position, Quaternion.identity, 0);
        go.name = PhotonNetwork.player.NickName; // + go.GetComponent<PhotonView>().owner.ID.ToString();

        Gamehandler.gameObject.GetPhotonView().RPC("AddPlayer", PhotonTargets.All, new object[] { go.name });
    }```

[PunRPC]
public void AddPlayer(string Name)
{
GameObject player = GameObject.FindObjectsOfType<PlayerGameplay>().ToList().Find(pg => pg.GetComponent<PhotonView>().owner.NickName == Name).gameObject;
StorePlayers.AddPlayer(player); this part gives a null reference error
}```

NullReferenceException: Object reference not set to an instance of an object
Gamehandler.AddPlayer (System.String Name) (at Assets/Main Assets/Scripts/Gamehandler/Gamehandler.cs:487)

im sending an rpc to all players to add a new instantiated player to their player go list (so i dont have to use getobjectoftype every time i need to access a player) but i have no idea why its giving me a null reference error

#

how can i i know how many joined the room ?
@fallen frigate you could manually count them by just in/decreasing an int whenever someone joins or leaves a room

fallen frigate
#

@fallen frigate you could manually count them by just in/decreasing an int whenever someone joins or leaves a room
@copper wadi k got it now ,thanks 🙂

jade glacier
#

@copper wadi which line shown there is 487? Have you isolated which object is null?

ancient iris
#

@spring crane So what do I do to solve the problem

floral turtle
#

This isn't technically networking related, but I figure y'all would know anything about it if anyone: https://twitter.com/roystanhonks/status/1318677036177784835

Have a replay system that is fully deterministic for same build/different machines, so long as the CPU vendor is the same 😦

Anyone know why determinism would break in #Unity between Intel and AMD CPUs (same build)? Tried both Mono and IL2CPP and get immediate desyncs. Floating point determinism is tricky, but I've had no desyncs with running very long replays on different machines w/ same CPU bran...

empty quiver
#

is this the right place for netcode/ghost system questions?

#

I'm upgrading a project from earlier this year. I'm trying to get the index to my ghost in the ghost collection

#

there used to be a GhostSerializerCollection.FindGhostType<EnvironmentCubeSnapshotData>(); method but it appears to be gone

#

the samples show doing some loop and finding the ghost based on a component that is on it

#

the thing is my ghosts are not uniquely identified by any one component (currently, although obviously I could change that)

#

so I guess I"m looking for the ghost generated type? but there's no generate button anymore so I don't get a type for my ghost anymore?

#

how does this work? do I have to create a component unique to each ghost type?

#

what does this generate?

#

where is Name used?

#

FindGhostType does not appear to be in the changelog

#

basically I want to get a prefab from EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection) using some hard-coded value

#

do I just hard-code the index itself based on the order I added it in the ghost collection?

#

and just be super careful to never insert any, and leave empty placeholders for ones I delete?

#

there's gotta be a better way...

jade glacier
#

I would definitely try Netcode questions in the DOTS channel, not many people in networking have even played with it.

empty quiver
#

ok thanks

dusky gorge
#

Heya, does someone here have experience using Mirror?

#

I started using it some days ago and I've been having a problem syncing objects that are saved with the scene (as in, I can't spawn them)

grizzled narwhal
#

@floral turtle Floating point math just inst deterministic across cpu arc (and os?)

#

There are deterministic physics engines but most are behind a pay wall

floral turtle
#

@grizzled narwhal most modern intel and AMD processors both use the x86-64 architecture, so this would not require cross arch determinism

grizzled narwhal
#

Try it out. It isnt

floral turtle
grizzled narwhal
floral turtle
#

I've read that article, but he only states that determ cannot be expected across different compilers, builds or architectures

grizzled narwhal
#

And even on the same pc across different runs

#

PhysX isnt build for determinism too

floral turtle
#

we actually have a functioning replay system that works on different runs/different machines, provided the CPU vendors are the same: https://twitter.com/roystanhonks/status/1318677036177784835

Anyone know why determinism would break in #Unity between Intel and AMD CPUs (same build)? Tried both Mono and IL2CPP and get immediate desyncs. Floating point determinism is tricky, but I've had no desyncs with running very long replays on different machines w/ same CPU bran...

grizzled narwhal
#

Then im guessing floating point math isnt deterministic across cpu brand?

floral turtle
#

well, the test I did above shows a case where the arithmetic is deterministic with simple .NET apps

grizzled narwhal
#

'Simple'!

floral turtle
#

?

grizzled narwhal
#

PhysX isnt simple

#

And it isnt build for determinism

#

The expert on determisim here is @graceful zephyr

#

But he will tell you roughly the same stuff

floral turtle
#

I'm a bit confused

#

physx and Unity are clearly determ on same build, different machine, same arch same vendor. I am asking if it is possible for it to work across vendors. Are you saying it is not possible?

grizzled narwhal
#

Probably not

floral turtle
#

do you have a source for that? I'm finding it hard to find anything concrete

grizzled narwhal
#

"The PhysX SDK can be described as offering limited determinism. Results can vary between platforms due to differences in hardware maths precision and differences in how the compiler reoders instructions during optimization."

floral turtle
#

yes, I have read that. I am looking for a clear answer on whether it should be deterministic across vendors on the same arch

grizzled narwhal
#

Dont have that

floral turtle
#

okay, thanks anyways @grizzled narwhal

graceful zephyr
#

@floral turtle So as you know it's possible to get physx determinism on the same arch/compiler/etc. thing... if this is usable or not depends on what ur trying to do .

#

If you want this to be deterministic you always have to step the simulation forward, you can never reset any objects, etc.

#

You can't do "predict-rollback" thing with that type of determinism

#

Because the second you reset objects, the determinism promise is gone

#

You also can't have anything from the 'outside' influencing the physics simulation like animation systems, etc.

floral turtle
#

@graceful zephyr yeah, definitely not prediction with rollback...I'm under no illusions at how difficult that is to build :S

Not primarily planning to use it for networking (brought it up in this channel since I figured it would be where the knowledge was). Mainly seeing if it is something that can be solved with compiler flags/configuration to allow users to share replays cross CPU vendor. Using it for deterministic lockstep networking w/ input lag would be an interesting stopgap to moving to a more powerful system (like quantum), but the cost to users is significantly higher when a multiplayer session desyncs versus a replay, so probably not worth the investment

graceful zephyr
#

So using it for like... client side prediction

#

And getting "close enough" to determinism

#

It all works for

#

But like hanging your entire game on physx being 100% deterministic

#

I wouldn't dare

#

At least not without being able to compile physx myself

#

and make changes

#

If you get a year or two down the line in dev, and then realize oh wait there's this specific scenario which breaks the determinism on this arch/setup/etc. whatever

#

I'd never ever dare to hang my game on something

#

I don't have control over

#

When its such a core part

floral turtle
#

👍 that is mostly the kind of opinion I was looking for. It's easy for us to just flag replays if they are captured with intel or amd, and warn users that sharing may lead to desyncs...it's a nice feature, but not critical

wide bolt
#

Hi guys, so I’ve been making some prototypes for some game ideas I’ve had using Unreal. I’ve found the engine really uninspiring (I know that sounds weird) and there’s something about Unity that I really love

The one game I want to make is multiplayer however. Not overly complicated but still multiplayer.

Do you guys find Unity is a big pain for networking using Photo or other plugins? Or is it more so just time consuming but enjoyable?

fallen frigate
#

how to make my photon manager script act like an singleton in unity ,like it should not get affected by changing scenes ?

#

also i am trying to make other player join the room so we can move together in a scene but only host can start the level

#

and i want my lobby to show players name who joined and arrange them in a column

#

please any experienced in pun 2 help me

slow monolith
#

Hey so I'm trying to understand prediction for a multiplayer game. Can I do all of the prediction clientside based off the user's current velocity?

#

How its going to work is just a simple websocket server. Client sends his rotation and position to the server, and the server sends back the same information of all players in the lobby

#

Third day in unity so idk if this will work. Also will it be a problem with users that have low framerates?

#

also how many ms should every request be

jade glacier
#

I would post that in the DOTS channel. Very few to no Netcode users in this chan usually @patent magnet

somber drum
#

@wide bolt photon is said to be the easiest way to get connected and playing.. Though it has limitations in terms of scaling, the easy is weighed vs the cost of leaving the "educational" tier of players allowed online at once. Unitys networking itself is a mess to be honest, its not happening as far as I'm aware so you would be relying on a third party like photon or community extensions reviving collapsed systems like unitys old networking "unet". "mirror". Which to be fair is easy enough, has a great community behind it. (With no ccu paywall)

#

If its a small uncomplicated game with a small lobby definitely go with photon

jade glacier
#

depends on how scaling is defined

#

Phasmophobia is doing like 100K+ CCUs

somber drum
#

Sure, everything is possible and of course we're only biased to our experience and opinion

jade glacier
#

Rooms in photon products are limited by the same factors as any other platform. How much data each user is pushing the main factor.

somber drum
#

Right but its known with photon or any cloud service data is expensive

jade glacier
#

Mirror and Pun2's limits to users per "game" are largely tied to how efficiently the dev is serializing and sending.

#

They charge based on usage of course. The alternative is either hosting instances, or doing a Nat Punch system and having clients host.

somber drum
#

We're talking best case really though here

gleaming prawn
#

Servers are expensive with the "free" products as well

#

Except for the "free" steam thingy...

#

after you gave them 30% of your rev

somber drum
#

True, and I think with all the heavy lifting photon does for you its worth the cost

gleaming prawn
#

So classifying a product as expensive is relative...

jade glacier
#

You can do player hosted, and skip the relay backup, and rely on just natpumch for the cheapest route. But that will leave a lot of players in the cold. But it is an option.

#

Not really a winning business plan, but an option

gleaming prawn
#

And that's why nobody does that

#

That's what Unity originally shipped with, the old defunct UN (Unity Networking), with a master server to run punch (raknet underneath)

jade glacier
#

Mirror and Pun2 and most other products get increasingly difficult to develop once you pass 16 players per game session

#

around the 64 player count point, you need to be an experienced dev. Regardless of netlib.

somber drum
#

I can't even blame it entirely on my own ignorance, nearly everyone if not everyone I've spoken to about photon says its great for smaller gigs but be warned you'd get more bang for your buck going with mirror, maybe they dont know what they're talking about or maybe its just a matter of optimising

gleaming prawn
#

If they have finsihed their game and have the numbers to show, then sure

jade glacier
#

I haven't seen any Mirror releases, or their revenue numbers so can't comment.

gleaming prawn
#

Among Us runs their own thing (funny enough, very similar in approach to photon), so he could run down the costs well

#

Fully relayed, client authoritative, etc

jade glacier
#

Phasmophobia is on Pun2, and the consume insane quantities of data

gleaming prawn
#

Phasmaphobia is photon (and I'm sure their bank account would not even get scratched by what they pay us...:)

jade glacier
#

I have been talking to one of their net devs about helping them implement bitpacking and other compression.

gleaming prawn
#

can't disclose anything, of course... except it is PUN2, as lots of people know.

somber drum
#

Fair enough, average dev probably wont need to worry about hitting any ceilings either

jade glacier
#

I don't know their numbers, and couldn't share if I did yeah.

#

All cloud models are designed to scale endlessly, that is the appeal of hosting that way.

#

When people say Pun2 or Mirror can't scale, they typically mean the number of users in a game... which is all libraries.

gleaming prawn
#

And it also gets cheaper as you move up the ladder

#

So...

somber drum
#

If you've got a good consistent revenue model ofc, I guess that goes without saying

gleaming prawn
#

Ye, SCALE normally means:

  • you can host 1 million or more CCU without effort?
jade glacier
#

it scales down as well. If your users drop off, your costs drop of.

#

The appeal is it is a fixed operating cost, that is directly tied to usage.

gleaming prawn
#

Honestly David, its a fair model for the customer more than us... Other industry sectors have more "hungry" models... But that may be subjective, of course...:)

jade glacier
#

Unlike buying 20 servers and hosting them yourself.

#

CCUs just scare hobbyists. But to anyone running a business, the predictability of the costs involved are a positive.

somber drum
#

I must be talking to the wrong folks I guess, clears photon up for me at least

gleaming prawn
#

photon is also a lot more than PUN

somber drum
#

I know as a game dev id rather worry about that, than managing my own server fleet or whatever lol

jade glacier
#

Hobbyists tend to gravitate toward Mirror because of the allure of "unlimited free", but obviously it never is. Someone wants to get paid for using their bandwidth.

gleaming prawn
#

Ask the Among Us developer his opinion on Photon...:)

#

He's not our customer (anymore), but he normally recommends photon

somber drum
#

Cheers guys, ill do more research, currently invested in mirror but may change I think it may fit my needs more

jade glacier
#

The reason to use Mirror should be because you want a Unity based server... not for money reasons.

gleaming prawn
#

Mirror is also popular...

#

Not saying bad things about it

jade glacier
#

Pun2 vs Mirror should be a choice based on architecture.. not trying to get away with "Free"... because neither are.

#

GL @somber drum

gleaming prawn
#

If you are comfortable with its API, and trust it can do the job you need, and you understand what will still be needed "outside", done

weak plinth
#

Hello, i am not sure i have this error "JoinOrCreateRoom failed. Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: Joining). Wait for callback: OnJoinedLobby or OnConnectedToMaster." ?

stiff ridge
#

Wait for callback: OnJoinedLobby or OnConnectedToMaster.

weak plinth
#

I know what it means

#

But why i have error when i want to create room

wide bolt
#

@gleaming prawn @jade glacier @somber drum

Thank you guys for all the awesome information! I had no idea Phasmophobia was running on Photon

Very cool! I’m really excited to jump back into Unity development 😊

weak plinth
#

I fixed everything, but i have another problem when i "joined" (i am not sure i did it ) and try to leave from room i have next error

#

"Operation LeaveLobby (228) not called because client is not connected or not ready yet, client state: ConnectedToMasterServer
UnityEngine.Debug:LogError(Object)"

#

"Operation LeaveRoom (254) not allowed on current server (MasterServer)
UnityEngine.Debug:LogError(Object)"

jade glacier
#

When you joined which?

weak plinth
#

System is :

#
  1. connect to server 2. Choose create or join 3. if i create everything is okay if i choose join (joinrandomroom) it is little problem i don't know why
jade glacier
#

Might want to paste your code, not sure from what I seeing so far.

#

In a bin preferably, since its likely your entire conntection cs file.

#

Not seeing anything in your order of events there that suggests the need for lobbies?

#

So it should be pretty boilerplate code to get a room started.

weak plinth
#

I will read this docs but i tried with Lobby

#

I connected in the same time like to connect to server

weak plinth
#

i think it's works 😄

#

Thanks 😉

#

What kind of problem is with Disconnect(). I made a button to leave a room and also server but disconnect doesn't work i read lots of this topic but i do not know how to fix it .. Could somebody tell me something about disconnect from photon server ?

placid trail
#

With a plugin (Phaton Networking) I always get this error!
Why is that?

jade glacier
#

Just the usual Unity noise as far as I know.

shut yarrow
#

I'm trying to find a way to get rid of jitter in my movement. The client sends 10 packet/sec to the server and the server sends 10 packets/sec to clients and attaches a timestamp (similar to Time.time which is just an incrementing counter) to the packet. Upon receiving of the packet on the clientside I'm using the timestamp to interpolate the position and rotation but I still experience serious jitter. How can I resolve this? Here is a general breakdown of how it works on the client

float timestampprev = 0;
float timestamp = 0;

void OnNetworkUpdate(Packet packet)
{
    BinaryStream stream = new BinaryStream(packet.data);

    timestampprev = timestamp;
    timestamp = packet.timestamp;

    for(int i = 0; i < m_networkObjects.Lenght; i++
    {
        Vector3 position = m_networkObjects[i].gameObject.transform.position;
        Quaternion rotation = m_networkObjects[i].gameObject.transform.rotation;

        NetworkObjectState nos = new NetworkObjectState();
        nos.position = stream.ReadVector3();
        nos.rotation = stream.ReadQuaternion();
        
        m_networkObjects[i].gameObject.transform.position = Vector3.Lerp(position, nos.position, (float)timestampprev * 10);
        m_networkObjects[i].gameObject.transform.rotation = Quaternion.Lerp(rotation, nos.rotation, (float)timestampprev * 10);
    }
}
#

The jitter is both on translation and rotation

#

I feel like maybe I should interpolate between previous position that server sent, and the new position I just received, instead of interpolating between whatever the position the object is at and the received position

#

Or maybe it has something to do with my timestamp which isn't between 0 and 1?

jade glacier
#

OnNetworkUpdate is the same timing segment as Update?

shut yarrow
#

I'll have to check actually give me a sec

jade glacier
#

Typically you would see interpolation inside of Update()

#

OnNetworkUpdate looks like either a fixed timing, or some kind of arbitrary timing based on your networking.

shut yarrow
#

No actually it only runs whenever a new NetworkObjectState is received

jade glacier
#

Then you are baking in jitter

shut yarrow
#

So yeah possibly kind of arbitrary although in theory it runs 10 times a second

jade glacier
#

In theory, it happens whenever your packet arrives.

#

which is internet noise.

#

Interpolation is the act of translating frames into the screen refresh updates.

shut yarrow
#

Yes I see your point, so I should have it run on a fixed rate and what if there's no data to update with?

jade glacier
#

So you always lerp in Update

#

No data = time to extrapolate

#

or let things hang

shut yarrow
#

With extrapolate you mean like prediction?

jade glacier
#

This is why networking uses buffers

#

Not really the term I would use, since prediction has other meanings in networking

#

just extrapolation

shut yarrow
#

Never have done that before, I know interpolation between 2 points, but extrapolation is the opposite right?

#

So you keep moving an object at same speed/direction it did with last data point?

jade glacier
#

Just use an Unclamped lerp

#

value > 1 = extrapolation

shut yarrow
#

Do I still have to change the function so it runs on fixed rate or is that just something you recommend doing?

jade glacier
#

How you implement it is up to you. But if your buffer is dry, you have to either hold the last value, or extrapolate something

#

you get the concept, I can't really give you much more without actually writing your protocol with you.

shut yarrow
#

I understand, just trying to do this without having to rewrite much although I feel like that would be the better way

slim ridge
#

i found that to be the case when i was working through this... still am

shut yarrow
#

Wouldn't even be that much work probably, just have to rethink the strategy on it because I did it a little too straightforward without thinking about the implications

#

I did it similar as I did with PUN in the OnPhotonSerializeView, but I don't know anything about the implementation of that function, just that it runs whenever there's data

slim ridge
#

dont trust timestamps btw

shut yarrow
#

Yeah kind of naive I know

jade glacier
#

You can't lerp unless you have a tick defined and some kind of buffer

#

If you want to avoid making that system, try using MoveTo and RotateTo rather than lerping

#

Those let you set the rate of change as a way of damping changes. Won't be perfect. But you can't get perfect without proper lerping in Update.

#

And you can't lerp without a proper buffer.

shut yarrow
#

Thanks I'll give it some more thought instead of trying to rush it, you've given me multiple possible solutions so I have to see what works best given circumstances

jade glacier
#

Proper transform syncs are hard. There is a reason all of the networking libraries have terrible implementations. They require a proper tick engine to do right.

shut yarrow
#

I feel you and I'm guilty too haha

jade glacier
#

Which library are you using?

shut yarrow
#

I've seen you talk about tickbased simulations before but haven't tried yet to implement that

#

For networking you mean?

#

ENet

jade glacier
#

Everyone makes a bad transform sync to start. You have to try the shortcuts to find out why the shortcuts don't work.

shut yarrow
#

Yeah this is more like a practice project for me to see what problems I have to deal with if I want to make something serious

slim ridge
#

here's how i did it for input + prediction strategy

- server sends current tick to client upon succesful connection
- client caches this value as offset
- client begins counting ticks at same rate as server.
- client subtracts offset from received input.
- client adds offset to outgoing input.
shut yarrow
#

I either find no useful information at all, or it's some long boring essay and I lose focus quick to absorb all the information

#

Thanks @slim ridge that doesn't seem too complicated to keep some kind of timesync that's not floatingpoint based

jade glacier
#

Most of us just use FixedUpdate as the tick, since its the same tick engine that runs physX and most of Unity internals.

slim ridge
#

ya, count ticks as int or long or even short

shut yarrow
#

But that would mean I definitely need to have a buffer right

jade glacier
#

byte is plenty

shut yarrow
#

There's no buffer currently

jade glacier
#

unless your tick rate is super high

slim ridge
#

i'm too scared to try byte lol

#

i'm using ushort right now

jade glacier
#

its 4 seconds of buffer at 60 ticks per sec

#

Any packets that late, aren't worth trying to resimulate.

shut yarrow
#

I'm doing 10 per second so not very extreme

#

Not doing any prediction either and if packets get lost so be it

#

I don't want to overcomplicate a project like this, if it looks good (and no obvious jitter is visible) I think it's good enough

jade glacier
#

Try MoveTo and RotateTo rather than lerping then

#

That is what the Pun2 vanilla sync does and most people are fine with it.

shut yarrow
#

That works without buffering values?

jade glacier
#

It is always rotating or moving toward the latest value at a fixed velocity/ang vel

#

About the best you will pull off without a proper buffer.

#

Just moving your stuff to Update for interpolation is a start no matter what.

#

you can't interpolate outside of Update()... by definition.

shut yarrow
#

I might give that a try. Got another question related to this jitter however. My server is in Germany and I live in Suriname (South America). When I connect with 2 clients to it (both on my computer) I don't see jitter, but when a friend from America joins I see him jitter around and he sees the same, so kind of curious how that works

slim ridge
#

prolly the timestamp

jade glacier
#

You can do crafty things having a timestamp

#

they are expensive and clumsy, but as long as you have it you can use it.

shut yarrow
#

That makes it more difficult to test it because it seems to look fine untill someone from another location joins

#

So not sure why it doesn't jitter because both my clients need to send data to a server that doesn't run on my local machine

#

In a way I expect to see the same problem

#

Eitherway I guess this method I'm using isn't really bulletproof

jade glacier
#

You aren't buffering properly, so you are going to see the internet jitter and framerate jitter in your rendering.

shut yarrow
#

Yeah gonna try the MoveTo/RotateTo method and see how that plays out

sacred marsh
#

Yo networkers

#

What up bros 😎😎

#

#TCP&UDPareUnderrated

winter smelt
#

So I’m working on a game, and I plan on implementing some sort of multiplayer further down the road (like 8-12 months down the road), but I know little to nothing about networking. Does anyone know any good tutorials out there that covers this topic pretty good in depth?

somber drum
#

it's a good idea to start building with multiplayer in mind, it's not going to be something you'll want to start with 8-12 months of offline code made, pretty much from the ground up

#

Dapper Dino has some good stuff

#

depending on your needs, different channels tend to teach in depth for what they use, I watched this guy for mirror he does a great job explaining the general idea
https://www.youtube.com/watch?v=77vYKsXC4IE

Join our Discord: http://discord.shrinewars.com
Patreon: https://www.patreon.com/shrinewars

In this Unity multiplayer tutorial, we cover the building blocks of multiplayer Unity games, go over various network topologies, and design the architecture for a sample game based on ...

▶ Play video
#

@winter smelt

azure crown
#

Does steam host servers? Planning on releasing a game in steam so I would like to know for my games multiplayer.

#

If not, I will just use Photon PUN

gleaming prawn
#

@slim ridge

#

Not sure I'm saying something you already know, but this:

- client begins counting ticks at same rate as server.

Caught my attention

#

You know that hardware clocks DRIFT, and that stopwatches will not keep aligned... Besides the network "jitter" may make your original alignment bad in the first place...

#

You need to keep CONSTANTLY fixing/correcting the local clock using the server clock as reference (needs to be send down frequently)

#

If you do not do this, you will get very bad "rifting" in any slightly longer game/match

slim ridge
#

thanks @gleaming prawn

weak plinth
#

What kind of problem is with Disconnect(). I made a button to leave a room and also server but disconnect doesn't work i read lots of this topic but i do not know how to fix it .. Could somebody tell me something about disconnect from photon server ?

fair cosmos
#

hey guys i am asking this again

#

to sync skins, what i have to do

grizzled narwhal
#

You need to ask a SPECIFIC question to get help.

fair cosmos
#

i mean by ids

#

i have to make an array of skins with ints(ids) on server and then compare stuff with that?

#

i got some anwsers before forget to take ss

jade glacier
#

Which library? @fair cosmos

#

Every library has different means of sending messages.

fair cosmos
#

Need a general answer

#

What is needed on server and what to client and what to do when changes happen

#

Photon or Mirror both works

grizzled narwhal
#

Yes but this is for specific questions

#

Its pretty easy to do with rpcs and you should be able to do that if you want to do multiplayer!

jade glacier
#

SyncVar, RPC, RaiseEvent, MessageBase

fair cosmos
#

Well sorry for fucking noob English, i want to know is i make an array of skins and assign them a id this wiill do the server, on the client it will pass command N get data back

#

Somethingg like the actual process what games do to sync large amount of stuff

#

By iDs

floral turtle
#

@fair cosmos there's a lot of ways to do this, but as a simple way it's fine to just send an ID then have the client load the correct skin

slim ridge
#

yes, the basic strategy is to keep this information in a database. only the server accesses this database and serve the data to clients

#

then in your client build, you include the map of skin id -> skin asset
server tells client which skin id he can use

left knoll
#

I wonder when you want to test multiple clients, is there a way to launch multiple clients through the Unity Editor or you have to build an .exe and run that multiple times?

jade glacier
#

It is a pretty common practice to do a project mirror and have two editors open. I don't recall the software used for that though.

#

I typically keep all networking development separate from the complete game though. leaving out all graphics and textures makes a huge difference.

silver steeple
slim ridge
#

as a properly documented module in the language i happen to be using to consume it or as a deployed swagger-like documentation

dawn laurel
#

Unity goes radio silent on their Networking these past few months

#

:/

#

A lot of non-engine and non-game related news on their blogs too after the IPO

#

Very worrying

somber drum
#

@dawn laurel How long have you been using unity? I don't think anyone would be wise to rely on unity's native stuff

#

from UI to 2d tiles and 3d terrain, networking and so on

gleaming prawn
#

Very worrying
Not really if you know the mature tools out there...

weak plinth
gleaming prawn
#

As people in this channel is well aware, do not wait for a built-in solution

#

The new built in attempt will come eventually, but does not seem close to completion, and there's no word if it will ever target the mature GameObject Unity (currently it seems to target the DOTS pipeline, which is also not ready)

#

Their blog posts reflect whatever was their mind (and PR communication) at THAT time...

weak plinth
#

I'm having a particularly weird problem and hoping someone can help me out.
I am doing a Webrequest on some of my android devices. They both run Android 10.
Same apk is build on 2 of my devices.

On 1 the webrequest completes just fine and everything is dandy (OnePlus 5T)
On the other however, the webrequest just keeps going. Never returns an error or finishes the webrequest (Samsung Galaxy Tab S7+)

The webrequest itself is called in a coroutine "yield return wr.SendWebRequest"

What could be causing this?
Please @me if you reply to this, thank you!

dawn laurel
#

The new built in attempt will come eventually, but does not seem close to completion, and there's no word if it will ever target the mature GameObject Unity (currently it seems to target the DOTS pipeline, which is also not ready)
@gleaming prawn Yes, but there is no other solution with server authoritative + lag compensation and client prediction as easy to implement out there like Unity's solution

#

And I can't really pull off in-house networking solution on my own

#

Realistically

gleaming prawn
#

There is

#

Bolt does exactly that since launched in 2015

#

if THAT is really what you need, you should give it a try

#

The other solutions are still in pre-2015 era, in that all they care about is Data-Transfering (which is a topic some people here discuss a lot: the key to a netcode solution is not how to transfer data, is how to control the simulation)

#

AFAIK, the netcode solutions that work on that (simulation, not only transfering data) are:

  • SpatialOS
  • Photon Quantum
  • Photon Bolt
  • Unreal Networking, Source Engine networking, etc (not Unity)
  • Unity's NEW netcode (not ready)
#

AFAIK all others are lower-level (in that they offer you a few was to sync data, but nothing in terms how that helps you build a tight networked gameplay.

#

I might be wrong, of course.

silver steeple
#

If it makes yall feel anybetter, they hiring a buncha networking people. It's atleaast a priority

floral turtle
#

but getting an initial release out and having it being mature and battle tested are different things

weak plinth
#

I have a question about Photon! How can I give a random player a tag, example: 5 players are in the lobby, when the game starts, one player has the tag "1" and the others have the tag "other"

jade glacier
#

You can just make use of IsMine instead for nearly every case where that would make sense.

#

@weak plinth

west pine
#

how do you even do multiplayer

#

for a school project, can I just make it peer to peer

jade glacier
#

Do tutorials for Pun2 and Mirror is a good starting point for most first timers. @west pine

#

@weak plinth If you haven't done the Getting Started tutorial for Pun2, you won't have a clue about any of this.

weak plinth
#

which tutorial is that ?

#

@jade glacier

jade glacier
#

You really will want to start on the PhotonEngine.com site and read docs. You won't guess how to network using any of the available libraries. They all require you to read their docs.

west pine
#

@jade glacier what about unity's multiplayer

jade glacier
#

They don't really have one atm

#

@west pine

weak plinth
jade glacier
#

How are you changing scenes? Typically you do that though PhotonNetwork, and you initiate it on the Master Client, and that replicates out.

weak plinth
jade glacier
#

That seems like the right code, so probably more an issue of the timing of when that gets called. Not sure. I don't have much personal experience with scene changes in networking or Photon. I typically avoid them.

weak plinth
#

is there anyother way just to restart the same scene btw?

jade glacier
#

I honestly don't use scenes in Unity enough to really suggest a best practice. Hopefully someone else here does.

somber drum
#

@weak plinth
Did you already figure it out?

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex)
thin cloud
#

Good morning folks! Intermediate-level programmer looking to make my first networked game. I have a "digital tcg" idea in mind and I think that is probably some simpler networked code since it is turn based. I actually found a series from the develoeprs of "Socket Weaver" of doing a GoFish style card game over network. Do any pros out there think that is overkill or have even eard of SW? Or is it better to just do my own API calls to a C# library running on cloud or something to control the state of game?

I liked the fact that this SW SDK helps manage lobby and matchmaking logic.

weak plinth
#

@somber drum Only MasterClient is restarting :/ not all other clients

somber drum
#

Is that not something you can rpc to the clients? @weak plinth

#

I'm not aware of a built in function to reload scenes for all clients, you're using photon? Maybe there is something in the doc

silent zinc
#

@thin cloud I found myself really good with python asyncio on server side, and C# .NET libraries for Sockets (for any kind of projects )

wind adder
#

Im trying to make a networking engine that loads assetpacks from a server so that each server can basically run their own game. The problem is I need to sandbox client side code to prevent servers from being malicious. Is there any way to sandbox C# code in assetpacks? Or am I stuck with forcing everybody into an interpreted scripting language?

somber drum
wind adder
#

Ok, thanks

weak plinth
#

Could look into AppDomains but this sounds very complicated and is largely solved out-of-the-box with scripting languages running in VMs such as lua

weak plinth
#

hey guys im using photon bolt for my multiplayer fps game but when I rotate my gun the other players gun moves too is there anyway to fix this?

grizzled narwhal
#

4 sure but not without code lmao

weak plinth
#

@grizzled narwhal so u wanna go on a call?

#

or what exactly do u want me to send u?

high night
#

@weak plinth You are probably not checking if the one recieving the input is the local player or not

#

Only the local player should recieve the input

weak plinth
#

i tried that but it just broke the script

high night
#

wdym broke it

#

what went wrong

weak plinth
#

it just stopped working

#

i used if (!entity.IsOwner) return;

#

and it just stopped working

high night
#

then maybe you didnt give it ownership

weak plinth
#

how do i do that?

high night
#

does it say in its network identity that its owned by local player or something?

weak plinth
#

it says id is not set

high night
#

@weak plinth i really dont know i used different netwroking tools

weak plinth
#

compile to fix it

#

and i did

#

and it still says the same thing

#

what did u use?

high night
#

i dont know really, but first you must make sure entity.IsOwner is true only for local players entity/character

weak plinth
#

alr

#

thanks

high night
#

some unet, photon pun and mirror
but i dont remember what i did on those neither, only the general idea stayed with me, not the api

weak plinth
#

oh ok