#archived-networking

1 messages · Page 87 of 1

jade glacier
#

Your goal is to send a message to the Master, and have the master trigger the door. @random crown

weak plinth
#

@opaque dew my serializationrate by default was 10

#

so i set it to 20 on awake

#

and now it's smooth

#

thx

weak plinth
#

I am getting the following error "PhotonNetwork.Instantiate() can only instantiate objects with a PhotonView component. This prefab does not have one: Player" on my multiplayer game. Any ideas?

jade glacier
#

Does the object this is on have a PhotonView?

#

What components are on your Player prefab in your resource folder?

weak plinth
weak plinth
#

Nvm I fixed it

weak plinth
#

On the multiplayer game I am building, I am able to move the characters separately but if I shoot with one of them, the other shoots. I made a player networking script and had it ignore the scripts that were on the Player, but the gun is under the player and it won't let me add that script to the ones that are ignored. Any tips?

#

Nvm I figured it out

grim goblet
#

@stiff ridge because my pc is crap which can't handle heavy tasks in it. So I decided to use an older version of unity instead.

#

@opaque dew and @lusty crow thanks for giving me advice. I will look after it

somber drum
#

Is there a networking version of profiler or do I have all the details I need there?

#

I guess it would depend on the solution being used? Ie mirror

stiff ridge
#

@grim goblet, ah, ok!
My impression so far was that performance got better in Unity. So if you build a game suitable for your machine, a newer Editor version may actually be better. But that probably depends on the use case.
The bad new is: We are about to phase out support for 2017 for PUN and other packages. Well. At least, we're going to submit updates with 2018 sooner or later.

#

That said: Once you got a package, you can use it in that version for a long time...

#

@weak plinth, while you can up the serializationRate, this will send more messages/sec. In a room with more players, this can become a burden. And you will still have to hide lag, should players run into temporary loss (on the connection).
Meaning: Maybe you revisit the topic of smoothing lag when you can and then lower the sendrate again.

tiny edge
#

If you spawn a unity build from another process, is there a way you can access stdin within that unity build? All I could find is using Debug.unityLogger to send things to stdout

azure crown
#

What would be the best cloud provider for Unity Mirror?

#

For servers?

gleaming prawn
#

Amazon Gamelift or Unity's own Multiplay, as they will give you some extra services that are necessary, like orchestration, etc

#

This is neither simple nor cheap to run... But that's it for production-quality with the authoritative server model you are using...

#

If you want the cheapest option, then I do not know (maybe someone else does)

sterile garden
#

Hi everyone!

Do you know what would be the best option if I wan to connect my Unity WebGl game to a database? I tried MongoDB but apparently it doesn't work for Unity WebGL.

lusty crow
#

Usually, the client frontend app is executed in any browser, and the database is not on the same machine,
I mean you could use localstorage for example or the index db of the browser (I think this is already what's used with PlayerPrefs),

but if you want a centralized database for multiple game instances, there should be a backend server with which the frontend apps communicate, over http requests for example,
the backend server is hosted on a platform like heroku/digitalocean/aws or whatever, and has a database setup. then the client will request a resource on the backend server, and the server will query the database for the resource and serves it

sterile garden
#

Okay, do you know any tutorials that teach how to connect the Unity WebGl front end with a back end? Cause I honestly have no idea on how to do it ^^"

lusty crow
#

´so you need a global database that multiple app instances can access? that has the same data?

sterile garden
#

Yeah

lusty crow
#

if so, this is really not different than making a regular full stack app,
you could try to learn how to make a simple REST app, or anything with a backend including a database,

the difference will be that your frontend is your unity code, that's it. http requests etc. should still work the same

tiny edge
#

you can use Application.ExternalCall to call a javascript method from unity, and you can use unityInstance.SendMessage to call a unity method from javascript. In your js you could have code for interfacing with a database directly

sterile garden
#

Okay

#

I will give it a go

lusty crow
sterile garden
#

Thanks!

weak plinth
#

best way to set multiplayer up for free?

#

like whats recommended I heard of mirror

high night
#

@weak plinth Yeah use mirror
Photon is paid after 20 ccu

#

You can get 100ccu if you set up your own server

weak plinth
#

not going for anything powerful so mirror should be fine then, wasnt sure if there was something better

high night
#

@weak plinth If you use mirror and hook up steam transport for mirror later on
You can use "Space War" steamapp id for steam to handle your networking

#

Steam will network your game for free

weak plinth
#

like host the servers?

high night
#

No

weak plinth
#

(artist brain here)

high night
#

Its relay only

#

Like you host a game in steam

#

And then your steam friend joins you

#

Thats it

weak plinth
#

ooh

#

"Space War" and this is a game?

high night
#

If you dont have relay, you need static ip, or something like hamachi

#

@weak plinth steamapp id 480 is free for anyone to use
Its for test purposes
For you to develop your game without paying steam

weak plinth
#

ooh yeah, i get that

high night
#

But looks like there are no defined limits how much you can use it

weak plinth
#

how do i access it?

high night
#

You'd release your game to steam if you got something nice

weak plinth
#

hopefully i will

high night
#

You should be able to find an example project that does mirror with steam

#

You can ask further in mirror discord

#

But i wouldnt worry about all that right now

#

Just get the mirror asset, and start developing your game

#

When you wanna playtest with friends

#

Use either use hamachi (virtually puts you in a lan)
Or you use some port forwarding stuff i dont know yet

#

And then type the friends ip to connect

#

For testing, none of these are necessary

#

You'll be making two windows and connect with localhost

#

You'll see, its easy

#

Follow along a tut and you'll be fine

weak plinth
#

i know hamachi a bit

high night
#

Dont worry about steam now

weak plinth
#

PanHeart thank you

high night
#

If you ever played a game over hamachi, its going to be the same

#

np

weak plinth
#

appreciate it

#

haven't used hamachi(was gonna for subnautica then i realized i dont have friends :l)

weak plinth
#

Object reference not set to an instance of an object. I have always this error if i try to implement a int variables PhotonNetwork.LocalPlayer.CustomProperties("").

#

int gameUser = 0;
void Start() => gameUser = (int)PhotonNetwork.LocalPlayer.CustomProperties["Score"];

high night
#

What math library do we use for deterministic fixed point math?
Can i have something with Vector3's cross, dot, abs, clamp like in UnityEngine.Math?

gleaming prawn
#

@high night we wrote our own for quantum, on top of fixed point q48.16

#

Q48.16 c# implementations are easy to find... A full math library that is hi perf I'm not so sure.

#

We use variable density look up tables for trigonometric and sweet functions, etc

high night
#

I think i can guarantee floating determinism via rounding to 0.001's no?
(after each operation)
And use them within like -10 000 to 10 000 or something

#

Id just be loosing some precision which is fine i think

graceful zephyr
#

no u cant

high night
#

Do the operation get result R
B = R + 0.0001
A = R - 0.0001

Round A to 0.001s
Round B to 0.001s

result = max(A, B)

This should be deterministic?

#

This should avoid the differences might happen if R was right on the rounding limit and some devices had different digits after 10^(-3)s?

grizzled narwhal
#

I think using fixed point float is faster, more accurate and safer

gleaming prawn
#

You can't Bargos

#

What you are describing is a Fixed Point operation

#

You can only do that if you use, Fixed Point

#

Internally, floating point math is not handled like an accurate Decimal like you described (that is a Fixed Point)

#

I mean, maybe you know this already. I apologize if this is the case

#

The point is, you can NOT make floats deterministic like that... It's a lot more (a LOT) complicated.

#

I think using fixed point float is faster, more accurate and safer

  • Not faster in all ops, no (specially in SIMD operations, not all hardware has simd for Int64, which is the basis for most FP implementations).
  • Also NOT more accurate (it's different, it has less accuracy and often accumulates more error in multiplications, for example)
  • It IS "safer" in the sense that it is (cross platform even) deterministic, and you can rely on the results.... But it's NOT safer in the general sense, as there are some degenerate cases that are nasty...:)
#

But in general it IS the way to go for cross platform determinism... You just design everything around its shortcomings, and enjoy not having to worry (much) anymore...

graceful zephyr
#

@high night ur wrong

high night
#

Allright, i see. Thanks for info. I will not be trying hacky things as i suggested.

weak plinth
#

So I need to create a health system which I know how to do, but I need to do it in a multiplayer game but also I need to make the bullet do damage when it is a rigidbody and not a raycast

#

Any help is appreaciated

#

I've watched a few tutorials and they have not helped yet

weak plinth
#

If someone can help me, I would be willing to pay them via venmo. Since it is a question that would require a lot of information

weak plinth
jade glacier
#

I would avoid VS Code

#

Use VS 2017 or 2019

#

@weak plinth

robust egret
#

not that compile errors would come from VSCode

#

@weak plinth MasterClientId, not ID

#

But yes, if your VSCode isn't set up properly it won't autocomplete and you'll make typos like that

#

And you may be lacking ausing for that second error, not sure since can't see that part

weak plinth
#

hello. I am using IBM Watson speech to text in Unity.

I am trying to call "FX_ListScript.cs" from "ExampleStreaming.cs" (ExampleStreaming.cs is the IBM script for speech to text).

The problem is when I call FX_ListScript from ExampleStreaming
https://prnt.sc/vhd1ye

I cannot acces to the switch value of FX_ListScript
https://prnt.sc/vhd4cs
https://prnt.sc/vhd53x

Lightshot

Captured with Lightshot

Lightshot

Captured with Lightshot

Lightshot

Captured with Lightshot

#

WhyI cannot access and how can I access to that switch value?

gleaming prawn
#

sorry @weak plinth I'm not sure this is the right channel. We normally discuss on the topics of online multiplayer/netcode/networking APIs.

robust egret
#

@weak plinth Uhh, have RandomObj be a public variable rather than a local one?

weak plinth
#

oh.. you are correct.

I've just declare RandomObj as a public variable instead of a local one but i is still cannot access.

robust egret
weak plinth
#

I am thinking I will not use IBM anymore I have found a plugin that does the same speech thing.

thank you @robust egret

weak plinth
#

using .net sockets with il2cpp

#

it doesn't seem to work after I changed to that build system

#

anything I need to do?

weak plinth
#

I am following this tutorial https://prnt.sc/vhkbyu
https://www.youtube.com/watch?v=29vyEOgsW8s

I am in the minute 8:07 of the video but it seems like I cannot use "OnPhraseRecognized" for some reason. https://prnt.sc/vhked2

why?

Lightshot

Captured with Lightshot

Lightshot

Captured with Lightshot

robust egret
#

@weak plinth lowercase k

#

Uppercase would be the type, not your instance of it

weak plinth
#

ohhh thank you you saved my life @robust egret I owe you one

crimson nymph
#

Hello there! I'm new new to this and I need help..

I'm using photon pun and it all works good untill I go away from my house location. It just cannot connect to master. Idk why I've tried everything but with no luck.. it would be amazing if I could get this solved

jade glacier
#

Other online games connect without any issue? What is Photon reporting in your log?

weak plinth
#

Any help?

weak plinth
#

can i have some help when i import mirror i get over 100 errors i am using unity 2019.4 and i have been serching youtube and google for days

severe owl
#

Go to mirror discord and ask there it's super active

#

"NOTE You should skip any Unity Package updates if prompted, but if you already updated Mirror and get a flood of package manager errors, update Package Manager UI package to latest and restart Unity! "

crimson nymph
#

No I'm not getting any erros

#

It just keeps saying connecting to master

#

@weak plinth it happened when I used mirror too switch to 2020 version and it should be OK

frank quiver
weak plinth
#

@weak plinth it happened when I used mirror too switch to 2020 version and it should be OK
@crimson nymph thnks

weak plinth
#

Hey guys im using Pun 2 for my multiplayer fps game and everything is working fine except for the bullet its a prefab and sometimes it wont collide with player and from what I could tell it seems like on the other players screen the gun doesnt shoot at him instead it shoots to his side and other times it actually does hit him can anyone help with this one?

#

the gun also has a photon view on it

jade glacier
#

That at a glance sounds more like the usual issues unity has with high velocity RBs tunneling. @weak plinth

#

The disagreement on position though sounds like you have some bugs in your code.

weak plinth
#

hmm ill check thanks

tiny edge
#

If you spawn a unity build from another process, is there a way you can access stdin within that unity build? All I could find is using Debug.unityLogger to send things to stdout

weak plinth
frank quiver
#

mean u dont have this PhotonView component on the gameojbect

fallen cave
#

What is the best free way to start adding an online multiplayer mode to an local multiplayer (offline) turn based game for 2?

high night
#

@fallen cave you can use hamachi for quick try out

#

puts you and your friend in virtual lan

fallen cave
#

No, i mean i didn't have even added networking code

#

I'm literally new to this, trying to add multiplayer to a game

high night
#

it can be played over lan you said?
which means you got networking code done

#

your game is single player then?

#

or like hotseat?

fallen cave
#

Sorry, i write it down wrong so, i mean my game can be played by 2 players on the same device

#

Yes

#

Hotseat

high night
#

i see

#

you get a networking asset
and follow a beginner tutorial

learn about RPC and Command
and learn about getting two players up and running one as host and one as client

#

.
client will call Command with inputs(move pawn forward etc etc)

host player will execute all logic
and host will sync the objects of clients scene with rpc

#

@fallen cave

#

Command and RPC are methods that you call remotely on other devices with same parameters
Thats your access point for multiplayer communication

fallen cave
#

Ohh i see, thanks for explaining me the basic concepts

#

Any suggestion about where i can start learning all of these?

somber drum
#

@fallen cave pick your networking solution by googling unity + multiplayer options and then taking that entered lots of tutorials can come up

#

Essentially rpc is server to client, command is client to server

#

If I understand that right lol

#

If you want turn based I suggest photon

fallen cave
#

Photon is free?

somber drum
#

Up to 20 players online at once, then you can have I think $99 a year for 500?

#

Easiest with the most tutorials I'd say

fallen cave
#

And can i sell my game for free if i have 20 or less players online?

somber drum
#

You can sell it its just after 20 they won't be able to connect or something like that, legally you'd be fine but I'd double check that

#

Pretty sure

#

The work they do behind the scenes to get your players seamlessly connected is great though, totally recommend

fallen cave
#

Uhm okay, i will check it out

#

I just have to be sure it's free

#

Thank you @somber drum and @high night

#

🙂

high night
#

@fallen cave With mirror
You connect by ip
Anyone can host if they know how to host any game like counter strike, minecraft etc

#

You can also have steamworks work with mirror

#

you can join friends through steam and stuff

#

There are example projects that use steam

fair cosmos
#

Mirror also have a relay server transport: darkreflectivemirror

#

you can use it to make rooms as u did it in photon

high night
#

cool

jade glacier
#

Relay and Server Auth aren't a great pairing, so be sure to run some tests of a basic proof of concept.

#

I am not sure if Mirror with steamworks actually allows you to route from one client directly to another through the relay, but its architecture isn't naturally designed for that. I would expect all traffic has to go to through a server exe.

#

client 1 > relay > server > relay > client 2
rather than
client 1 > relay > client 2

Though they may have changed some of Mirror's internals to give clients a way to directly address other clients.

#

Does steamworks attempt nat punch and only falls back to relay if that fails?

fair cosmos
#

@jade glacier u are right,

#

its like

#

client 1 > relay > server > relay > client 2

jade glacier
#

That is acceptable as a fallback, but typically that will double pings and increase loss rates and such. Does it attempt nat punch? @fair cosmos

fair cosmos
#

right now not, but in some days nat punch is coming too

#

@sonic echo this guy is the developer

jade glacier
#

nat punch would make that more viable for Mirror

#

for server auth, relay should really just be a fallback - and even then, any users who end up using the relay are going to suffer.

#

Though not nearly as much, if the rest of the players are all directly connected to the server.

wooden swan
#

My game is a 2d game, constant round restarts, and different colored players, whats the best network asset to use? Photon? Mirror? unity's?

jade glacier
#

Don't make a game as your starting point. Do tutorials for Pun2 and Mirror before even thinking about trying to make a game you care about.

#

First attempts typically produce garbage and are just for learning the pitfalls.

somber drum
#

Using fizzysteam to relay to another client, no server inbetween (unless you count the self hosted)

#

No downside yet as far as I can tell, its a tiny coop game so I'm not too worried about it

#

By suffering though if you were to expand I've heard people say that, mr gadget for one if you know him.
I'm trying to weigh the downside of connecting friends directly rather a server for each lobby.. Ie among us with dedicated servers ? How does that work, seems easier for everyone to just use steams relay

somber drum
#

I just said something like "is performance the cost of using relays" to which he responded;

At some point you figure out that hosting a server is cheaper```
when he says "support burdon",    is this referring to player support,  setting up a server ?  because with the relay that's done automatically, I would think making support easier..? 🤔
#

if anyone wants to clarify the negatives of relay in this situation would be great, trying to get all angles

#

so far seeing dedicated servers as a hassle for players more than a positive for what steam already provides

jade glacier
#

@somber drum

Using fizzysteam to relay to another client, no server inbetween (unless you count the self hosted)
Are you sure that is the case? Mirror's messaging is not set up to identify target connections (clients have no actual concept of other players connections) - unless that is a recent change. Only the server is aware of other clients.

It is possible that Mirror's core message handling has been modified to allow that, I just am not aware of that.

somber drum
#

I've not done anything special maybe it's not even working but, I've tested non locally using steams matchmaking and it seems to work- they're running around and interacting with each other at least that's probably not what you meant though

#

this has been very trial and error for me 😛

jade glacier
#

It will work. I just have to assume all traffic follows the standard server/client architecture because Mirror is built from the ground up around that.

somber drum
#

I would assume so yes

jade glacier
#

My asset supports both Relay (Pun2) and Server-based (Mirror/UNET/MLAPI)... and nothing in that experience has indicated that the server-based libs could easily be converted to true relay.

#

So replication with relay should look like player 2 -> relay -> host player 1 -> relay -> player 3 unless there is nat punch happening.

#

Which may be fine for some game types, but people using it should be aware of the inherent added latency.

somber drum
#

it's handling nat punching yes

jade glacier
#

If it does punch, then it is not relay

somber drum
#

ah ok, so there the added latency

jade glacier
#

that is relay fallback

#

player 2 -> relay -> host player 1 -> relay -> player 3 that is more a reflection of what is going on without punch.

#

with successful punch that would just become the usual
player 2 -> host player 1 -> player 3

#

and true relay would be player 2 -> relay -> player 3

somber drum
#

ok interesting

#

thanks for clearing that up! I'll be doing some googling

wooden swan
#

I keep changing photon animator view to Discrete

#

they keep going back to disabled when i play

#

or build

rugged rose
#

hi. i hope any of you can help me with this

#

i want to create my first multiplayer unity game

#

wich is the most standard way to do this?

#

i would like to create the tipical client server netplay from the 90s like half life 1 so players can create a server and join by ip

rugged rose
#

i just dont want to install external add-ons

serene fern
#

using Tom Weiland's networking solution, I can't figure out how to set all players to one specific rotation in a script

#

How my game works atm is everyone can run around a lobby but then when the host starts the game they all are spawned to the game map and face a certain way

#

but nothing I'm doing is working in regards to changing their rotations

fair cosmos
#

@serene fern He has a specific discord for custom networking help join it!!!

serene fern
#

I have

#

but there's barely anyone there

#

and they never respond

weak plinth
#

How do I load a level in photon without destroying a gameobject

glacial sinew
#

I'm creating a dedicated server / client system using DarkRift 2. I've got most of the basics worked out, but I've run into a problem where on the server the GameObject is always rendered at the origin, but if I print out the transform it's very clearly moving and the updated position gets correctly sent to the clients. Even weirder, when the player spawns in at a designated point, the server renders the player there then quickly moves it to the origin. Any suggestions on how I can troubleshoot why it's rendering in the wrong location? The inspector doesn't show the transform moving at all.

slim ridge
#

Why is the server rendering anything at all? that's not it's job.

glacial sinew
#

The rendering is temporary while I work out some issues with client reconciliation. Server will be headless in the end, though I may explore adding functionality for a client to also act as a server.

slim ridge
#

i'd guess it's trying to be in two places at once

alpine pivot
#

i would like to create the tipical client server netplay from the 90s like half life 1 so players can create a server and join by ip
@rugged rose
Installing add-ons is basically a must as Unity doesn't have any standard networking solution at the moment.
With that said, mirror would probably fit your needs nicely.
https://github.com/vis2k/Mirror
If you end up wanting to use it, they have a very active discord server that you can join and ask questions in.

wooden swan
#

why is flip getting called after the rpc function?

neat kelp
#

Hello, what can cause that Android build doesn't grant permissions for anything? I debugged the APK, the Manifest file is requesting internet access, but installing on phone and nothing happens.

#

2019.4.13 and API level 29

rugged rose
#

@alpine pivot what about the multiplayer high level api?

#

i was thinking of using that

#

oh aparently that is the thing that is going to be deprecated

alpine pivot
#

oh aparently that is the thing that is going to be deprecated
@rugged rose
Yep, Mirror is actually a fixed fork of the HLAPI (UNET)

rugged rose
#

will it work fine if i use it for actual gen consoles?

#

i mean switch ps4/5 xbox etc

#

i would like to to expand my platforms

alpine pivot
#

I don't know, haven't used it in those situations, I think there are a few restrictions but it should all work

rugged rose
#

at the moment im developing for android linux and windows

#

but i would like to develop for consoles too

opaque dew
robust egret
#

How does Unity perform if you run it headless? Or maybe better asked, is it better to code a separate server without Unity, or just run Unity headless as a server.

alpine pivot
#

How does Unity perform if you run it headless? Or maybe better asked, is it better to code a separate server without Unity, or just run Unity headless as a server.
@robust egret
A 'Unity-less' server is always going to be faster, but, Unity's headless builds are not that bad really, 30MB RAM and pretty much 0 CPU time on a clean build.
I think It's a good idea if your game is gonna be mostly player-hosted and relies a lot on physics and navigation so you can just use Unity directly for that on both ends.

robust egret
#

Yeah, thats the main thing, would have to probably do a custom physics implementation for a non-Unity server.
But yeah, doesn't sound like /that/ much overhead then at least

alpine pivot
#

Yep, but be wary, the memory will collect up pretty quickly as Unity's server builds will still package textures, audio, 3d models and all that jazz, which will all be loaded depending on the assets used in the loaded scenes.
You'll have to find a solution for that, I think there is an asset on the store that replaces any un-necessary assets with dummy ones.
I also think asset bundles can help with this somehow but I'm not sure.

robust egret
#

Will have to look into that, thanks

rugged rose
#

thanks @opaque dew

final skiff
#

Hello,
I'm looking into hosting my game on a free-tier AWS server but im not quite sure which type to roll with.
It's a server authoritative game using Mirror, the headless build runs great and I have an authentication server to go with it.

Any ideas whether i should choose an EC2 instance, use amazon Lightsail, or something else?

jade glacier
#

Does AWS have a free tier for spinning up Unity instances?

#

Is that like GameLift?

final skiff
#

Gamelift is through amazon i believe,
I found some mirror documentation about using EC2 to run a dev server on it

jade glacier
#

Yeah, I would pin the Mirror channel about this. They might have some people who have dealt with it.

terse relic
#

mirror or pun

#

which is less laggy

#

ignore the fact that mirror requires a server which i will not be getting for a few years

gray pond
#

Neither will induce lag...the internet is where lag comes from. If you don't have a server on good infrastructure, and instead rely on a home user's unknown upload speed on their DSL line, then you can expect it will be "laggy"

#

Pun is a relay, so that's extra hops for the data, and the host is still on a residential internet.

stuck moth
#

Isn't Mirror built on the deprecated UNet? That and the need for one's own server is enough to deter me.

sacred grail
#

Yes, but not sure how much that matters considering that unity doesn't yet have a offically supported networking solution yet 🙂

#

in other words you are stuck with going to a third party "supported solution" or picking up one of the community solutions and making it work for your needs.

stuck moth
#

Yeah I just mean when PUN2 is an option, Mirror just seems super offputting

jade glacier
#

The choice between Pun2 and Mirror should really be based on the architecture you are after. They have very different hosting and authority models.

stuck moth
#

mm yeah true, I was centering my entire focus around Mirrors need for a server, which Gurem DID say to ignore lol

gray pond
#

@stuck moth You can have player-run servers, like PUN, with all the caveats like port forwarding, firewall rules, and flakey internet. There is a relay available for Mirror but you have to host that someplace public. There are free tiers for servers during development available.

#

As for UNet - we've evolved over the years (yes years) so far from UNet, that it's totally unfair to punish Mirror for all the sins and failings of UNet

stuck moth
#

yeah that's fair lol

gray pond
#

we've worked way too hard to take that beating

stuck moth
#

I see, my bad, I'm sorry for that

gray pond
#

come take Mirror for a spin through our QuickStart, visit our discord, and tell us about your game, and we'll try to help you get there, or we'll straight up tell you we can't.

stiff ridge
#

You can have player-run servers, like PUN, with all the caveats like port forwarding, firewall rules, and flakey internet.
PUN does not have player-run servers. It always uses a Photon Server as "relay" per room. The room logic also has a few extras, like optional event caching and properties per player and for the room.

agile garden
#

hey guys should i use photon for a multiplayer racing game

#

??

#

is the free version enough??

stiff ridge
#

PUN might have a hard time, when you want collisions between cars. Networking those situations is tricky when using "state transfer" and authoritative clients (where clients control their own car in their own physics simulation).

#

Photon Bolt has a quite good tick engine to help handle those issues. I would look into that.

#

I can't say much about Mirror, Forge and the other options. Maybe check out the Unity Forum "Connected Games".

high night
#

unitys default physics stores more dynamic information on top of velocity,position, rotation, angvel

you have to somehow get all that info and serialize with your states, otherwise especially collisions will be very tricky to reproduce, or you try to find a stateless physics engine

#

But if you make your own rigidbody system and use trigger colliders for collision checking, it should be fine i think

jade glacier
#

You should ALWAYS start your networking journey by making tutorials for some of the various libraries. DO NOT start with your actual dream game project. The first dozen networking attempts will be painful failures, and that is part of learning why networking is hard and what the limitations of the libraries are.

#

Once you complete some tutorials for Pun2, Mirror and/or Bolt you will be able to understand the different architectures of those three - and what it means for your authority model, and what it means for hosting/deployment.

fierce wind
#

Since Unity announced that they will be switching out their networking system for something better, what is the concensus on what should be used for network or multiplayer segment of the project? Sticking with a solution that will soon be replaced is not a sound long term idea.

jade glacier
#

Unity has a track record with networking of "announcing" but not really delivering on the networking side of things. I would build with that is available.

They might surprise us this time, but I wouldn't develop a project based on expectations of anything from them until you see it.

random crown
#

So i have a question for photon users. I'm new to photon and still learning, but does anyone know how do i define who the owner is of each object? Let's say i have a object, and i want only player 2 to use it. How do i say that the player 1 cannot interact with it (if the player1 is the master)

jade glacier
#

The owner by default is whoever created it.

#

Scene Objects are unowned, and by default Master controls them

jade glacier
#

If you have some custom rules for who can interact, the current controller would be the one to enforce that.

tawdry temple
#

i'm using the networkmanager component from the HLAPI but it says that it's deprecated

#

and that it's getting removed in the future

#

i'll try using MLAPI

gleaming prawn
#

UNet is dead since a LONG time

#

Consider MLAPI or Mirror if you like the general approach

tawdry temple
#

i was watching a Brackeys tutorial

#

and he was using HLAPI

gleaming prawn
#

no comment...:)

#

suggestion: look for tutorials from people who actually work on released games, etc (in your case online multiplayer games)

tawdry temple
#

i wish Brackeys didn’t stop uploading :(

robust egret
#

I mean, at the time he made that video, HLAPI was probably not yet deprecated

fervent bluff
#

Anyone familiar with Mirror Networking and can help me figure out why child of child of a gameobject wont update over the network?

somber drum
#

@fervent bluff does the parent object have authority?

gray pond
#

@fervent bluff Please join Mirror's Discord for direct support. Link is in the Asset Store page.

fervent bluff
#

@gray pond Thank you. @somber drum yes it does but the hierarchy looks like this. Player>>Mesh>>Items>>Target obj

#

I have a child transform with the target of target obv however it does not work

tawdry temple
#

if i move around in play mode, both players get the input and move while only 1 of them should move for every client (using MLAPI)

#

and the host can't see the other play and has a lot of lag

somber drum
#

@tawdry temple are you following a tutorial or just throwing code at the screen? sounds like you should be checking if localPlayer

#

they also have a dedicated discord btw

tawdry temple
#

i can’t really find a tutorial

somber drum
#

ay why I switched to mirror lol

#

should be similar though in that local authority can be checked

#

must be in the docs

tawdry temple
#

thanks

#

i’m using MLAPI because it apparently has better performance

#

i just followed the flowchart on the website to choose

somber drum
#

oh definitely better in x ways

#

still too early for my taste

inland stag
#

You likely have a controller on both players.
The if local authority check is so that you can make sure the controller only runs on the local player.

tawdry temple
#

thanks!

#

yea both my players are exactly the same

#

with all the same scripts

#

if you guys have a tutorial for MLAPI pls lmk

slow monolith
#

So for a multiplayer game, when dealing with cars

#

I have a client in the car, who is actively using the wheelCollider, to move the vehicle

#

is it safe to just sync the transform position of the car to the rest of the clients and not have them use the wheel colliders?

#

Or is that gonna make it look laggy?

slow monolith
#

And is there a specific time-frame that I should have clients send out their update packets? Like every millisecond or something?

gray pond
#

i just followed the flowchart on the website to choose
@tawdry temple That flowchart shouldn't be taken as any sort of gospel

gleaming prawn
#

@slow monolith cars are some of the most difficult things to sync...

#

In short:

  • sync position + the inputs (accell? steering?), so you can also locally extrapolate based on the inputs
#

Ideally this should be done with a tick based system (on a synced clock), so you could predict and reconciliate, etc

slow monolith
#

@gleaming prawn I'm pretty new to unity to I like to start simple on my modules. What will the outcome look like if I ONLY make the clients see the transform.position and rotation changes without any prediction or physics done on the CLIENT's end?

gleaming prawn
#

it will look very laggy

#

and specially in cars, it will lead to wrong assumptions. For example:

  • in a race, in your machine you'll be in front...
  • on the other machine, the opponent would be in front
  • which is right?
#

It's a super complicated problem, specially because the high speeds (compared to a walking/running character) exacerbate the problem

slow monolith
#

Well the client would be telling the server his exact place in the world, so it wouldn't really be a wrong assumption right?

gleaming prawn
#

Btw, I've been writing online/multiplayer car physics for more than 7 years

slow monolith
#

alright

gleaming prawn
#

Well the client would be telling the server his exact place in the world, so it wouldn't really be a wrong assumption right?
The assumption that you are IN FRONT is totally not accurate

#

And you are implying there is a server... This also depends on which networking tool you are using

slow monolith
#

Btw I'm not making a really faced paced racing game, just a simple RP game

gleaming prawn
#

And it will NOT help anyway...:) having a server

slow monolith
#

I'm also making my own networking tool with websockets

gleaming prawn
#

Well, I told you what you'll see

slow monolith
#

alright

gleaming prawn
#

Syncing position is fine IF this is not a racing game

#

And you do not care much

#

Collisions will also be super complicated to "solve"

slow monolith
#

What about syncing characters walking?

#

is that simpler?

gleaming prawn
#

You'll have to make remote cars act as "kinematics" locally, etc

#

The thing with characters is that they are NOT driven by physics, they normally use a cast-based KCC

#

And speeds are an order of magnitue slower (even when compared to slow cars)

#

And there ARE issues with characters, mostly when there is shooting involved (this is the most discussed topic here, period)

#

FYI, the best solution for car physics is determinism (this is what I use now)

#

But it is probably out of your scope as you said you are new to all this

slow monolith
#

yeah

#

I guess I'll just start simple

#

with position updates and such

#

and see where that takes me

#

if I lerp between the tick updates of the car position, will that smooth things out?

gleaming prawn
#

it will smooth... but

#

remember interpolation = MORE lag

#

you have the internet lag (the actual time for the data to be transferred) + the interpolation

slow monolith
#

hmmmmmmm

#

this is one big brain fuck lol

gleaming prawn
#

But yes, you NEED interpolation
what I suggest is that you use extrapolation as well

#

to somehow compensate the interpolation

slow monolith
#

how often should I be sending out position updates

gleaming prawn
#

we're back to my original suggestion

#

That's the point, with extrapolation, send frequency will just "correct less", but it does not matter much for the "lag". anything between 10 and 30hz would WORK...

#

But that assumes you know what you are doing, and you create a tick based extrapolation

#

Without it, send at around 20Hz and interpolate so it looks smooth

#

BUT it will NOT be the right way to do

slow monolith
#

alright

gleaming prawn
#

FYI: I send at 60Hz (but this does not work well with state transfer based approaches

#

Because I use predict/rollback determinism, I don't need to worry

slow monolith
#

so I could have the other client's perform physics on the wheelcolliders as well?

#

and just correct the positions as needed?

#

Still a tiny bit confused

gleaming prawn
#

The other will NOT perform physics operations on your car

#

As I already said, the "remote" cars would be kinematic physics bodies

#

interpolating/extrapolating the positions/rotations (extrapolation for driver intentions)

slow monolith
#

Alright yeah that makes sense

gleaming prawn
#

But I'll say it AGAIN:

  • it will NOT look realistic/correct
#

It's a hack...

#

Try it

slow monolith
#

Have you ever played GTA V? The car networking is awful in that game but it looks alright

gleaming prawn
#

But technically you need to understand more

slow monolith
#

thats sort of what im aiming for

gleaming prawn
#

Even THAT is using extrapolation

slow monolith
#

okay

gleaming prawn
#

the stuff I work on is miles better than that currently, but even that is using extrapolation

#

networking is NEVER simple

#

Unless you are talking about very very simple turn/command based games, like cards

#

And even that you have a few challenges, etc

slow monolith
#

So extrapolation is essentially just prediction

gleaming prawn
#

Any topic, if you need it to look correct, play nice, you need a lot of work

#

yes.. it is prediction

#

For car physics it works wonders

slow monolith
#

alright cool

gleaming prawn
#

there are several levels of this (I'm not even touching the details)

#

I suggested a very basic extrapolation:

  • assuming you have tick based sim + clock
  • you can extrapolate locally based on if remote player seems to be braking, accelerating, turning (simulating his cars locally forward)
  • when you receive a state, you compare that with his locally stored values for that one on prediction, compute the error, interpolate it, etc
#

This is the most basic you can do...

#

Depending on the physics engine (Unity's is not really designed for this), this in itself might be complicated to perform

slow monolith
#

complicated but do-able?

#

also the faster a car is going, the more unpredictable it will be?

gleaming prawn
#

the faster it will go, the worst it will look if you do NOT use extrapolation

slow monolith
#

Does unity have extrapolation built in?

gleaming prawn
#

prediction works really really well for cars

#

Does unity have extrapolation built in?
Not for what we are talking about

#

Unity does not have ANYTHING properly designed for multiplayer

#

they have an extrapolation option for the rigidbodies, but it has nothing to do with this

#

It has to do with the aliasing between FixedUpdate (physics) and Update (rendering)

#

What do you do with physics bodies in between two FixedUpdate calls (when there's a rendering one).
You either do nothing, interpolate of extrapolate

#

It's the "same" concept...

#

In your case you are thinking about what to do in between two network updates...

#

But you have to do this "by hand"

#

if you do over the kinematic body, with fake physics, it's somehow simple

#

If you want to extrapolate using the local wheel colliders, then FORGET IT if you are talking about Unity's PhysX

slow monolith
#

hmmm alright I'll have a shot at it

gleaming prawn
#

hmmm alright I'll have a shot at it
At what exactly?

slow monolith
#

Making the car lmao

gleaming prawn
#

Ahh, ok

slow monolith
#

so for the "prediction" part, would I just take the current velocity of the car and just somehow predict it's next path

#

as you said to do between network updates

#

That doesn't sound too extremely difficult

gleaming prawn
#

so for the "prediction" part, would I just take the current velocity of the car and just somehow predict it's next path
Exactly

#

But it will never look as accurate as the one above

#

This above I can fully run the prediction with proper physics, so a remote car behaves as if it was LOCAL (because it is)

#

But I can only do this because:

  • synchronized tick based clock
  • cross platform determinism
  • stateless physics engine (that I can fully predict/rollback at will)
#

And I do not even need to transfer state, etc

slow monolith
#

alright

gleaming prawn
#

This is the "holy grail"

uncut bane
#

How can I completly disconnect a player from Photon master server by calling Photonnetwork.Disconnect() (on a button)? Or maybe a different function?

slow monolith
#

appreciate it

gleaming prawn
#

You can have "decent" physics without it

#

But you need at least some extrapolation

#

And no matter if using extrapolation or interpolation, the car will look "spongy", unless you use real physics locally (and that is the complicated part)

#

The SLOWER the car is, the easier it gets, sure...

slow monolith
#

so like sending the suspension and shit over the network to the clients

gleaming prawn
#

I'd NOT do that

#

it's overkill, and will look wrong because of delay

slow monolith
#

alright

#

all I need is just a passable car

gleaming prawn
#

I'd fake it:

  • assume the interpolated/extrapolated position/rotation
  • run one raycast per wheel (to position the wheel graphics)
  • fake the wheel speed to match the car speed (with radius)
#

So you can fake the wheels and suspensions of the remote car by running local casts

slow monolith
#

yeah that makes sense

gleaming prawn
#

In the video above, both cars run actual wheel colliders locally (in each client)

#

but that is only because I canb fully predict/rollback the full state of the physics

#

And it is fast enough for that operation

slow monolith
#

so like this is an example of not using extrapolation?

#

as the cars are glitching around?

gleaming prawn
#

let me watch

#

First: they clearly state in the video that this is a LOCAL lan test... let me watch to the end

#

Wow, that's horrible... Sorry

slow monolith
#

yeah lmao

gleaming prawn
#

Right at the beginning the cars are jittering

#

they are neither interpolating nor extrapolating

slow monolith
#

Thought so

gleaming prawn
#

and notice that is a LAN test

#

looks like they are sending at something like 15hz

#

which is ok

#

for state transfer... they could send faster in LAN, but it would just MASK the problems

#

One last thing

slow monolith
#

So get the information from server, lerp the transformation to the car, and then apply velocity to the car's rigidbody (so it continues driving between frames)

gleaming prawn
slow monolith
#

vid is private

gleaming prawn
#

I just made it non listed

#

Wait a bit

#

Can you try again?

slow monolith
#

still private

gleaming prawn
#

google takes some time to propagate the setting I guess

slow monolith
#

yeah

#

So get the information from server, lerp the transformation to the car, and then apply velocity to the car's rigidbody (so it continues driving between frames)
@slow monolith

#

is this right though?

#

like just as a general idea

gleaming prawn
#

No

#

you cannot rely on unity physics for the extrapolation

#

you need to run that yourself

#

That's what I said before

slow monolith
#

thats so confusing lmao

gleaming prawn
#

The remote car is a KINEMATIC body

#

that = not driven by physics

slow monolith
#

alright

gleaming prawn
#

so any interpolation and extrapolation is done by YOU

#

You can only extrapolate with unity physics IF IT WOULD be able to do resets/rollbacks without going belly up

#

AND you would also need synced clock/tick

#

I thought I made that clear

slow monolith
#

yeah I get it now

gleaming prawn
#

THere's a REASON why we do NOT use PhysX...:)

#

ANyway, the videos are not useful

#

As the package does not exist on asset store anymore (I deprecated it long time ago)

slow monolith
#

Ok

harsh dew
#

I would've still watched it 😉

slow monolith
#

And lastly, as for the player synchronization, do I need extrapolation for that as well?

#

or are they moving slow enough that you can just update the positions

harsh dew
#

Do you have good experiences with extrapolating vehicle physics? I think I've read on gafferongames that he hasn't had good results with extrapolating rigidbodies so I have never bothered.

gleaming prawn
#

as for the player synchronization
No... No need to extrapolate that

#

Do you have good experiences with extrapolating vehicle physics?
I do

#

Extrapolating rigidbodies is one thing... Etxrapolating CARS is another (not a generic rigidbody)

#

And it really depends on Which physics engine you use...:)

#

If you ask Glenn (Gaffer on Games) NOW, he'll tell you this: use Photon Quantum...:)

#

@harsh dew

#

Notice:

  • I'm not recommending you to extrapolate the physics body with unity physics AS A physics body (rather a custom extrapolation specific for a car)
  • to actually run prediction/extrapolation based on physics, you need to move away from PhysX
tawdry temple
#

i’ve got this city destruction game where the buildings fall apart, should i send all the transforms of the individual pieces to the server or just call the function that destroys the buildings?

robust egret
#

Someone else may have more insights. But I'd think that sort of depends on how important it is that the destruction looks the same on each machine.
If it doesn't really matter, just call destroy on each machine individually.
If you do want it to be the same, and you don't want to send transforms, you'd have to probably implement your own physics to make sure they're deterministic. Which is kind of a can of worms though haha.
If you do want it to be the same without that, you'll want to be sending data instead of running physics probably. Theres an article here on how to optimize that: https://gafferongames.com/post/snapshot_interpolation/

tawdry temple
#

thanks

gleaming prawn
#

If it doesn't really matter, just call destroy on each machine individually.
This is good advice

#

Sending all individual transforms would be overkill and not scale well

#

If the destruction is more a visual effect (and I strongly suggest you to design the game around this idea), than this is the BEST overall option (that will still look super nice)

#

Another interesting approach is to make a few bigger chunks of the buildings be SYNCED, while all the rest would be like local visual effect only (not affecting gameplay)

#

It really depends on the scale of the whole thing (how many individual pieces you are talking about, etc)

tranquil warren
#

Hey guys I am now currently using Mirror to make my multiplayer project. I've encountered a problem that when another player joins the game, the isLocalPlayer will return false on both side (Client & Server)

jade glacier
#

Be sure to join there Mirror Discord if you haven't @tranquil warren Usually much faster responses there for questions specific to Mirror.

tranquil warren
#

ok thx

pliant scarab
#

Anyone here who knows photon PUN that can help? Basically this is my problem.

So in the room just before the start of a game, you are able to choose a color of your own, and I've put them in a custom player properties so it can travel through scenes. Now when the game starts, I can set my own characters color that I chose except those who are not my player.

void Start()
    {
        if(!PV.IsMine)
        {
            Destroy(GetComponentInChildren<Camera>().gameObject);
        }
        else
        {
            playerModel.layer = 9;
            Material mat = myPlayer.material;
            mat = (Material)Resources.Load((string)PhotonNetwork.LocalPlayer.CustomProperties["Color"], typeof(Material));
            myPlayer.material = mat;
        }
    }`

This code only applies to the local player. I want to be able to do this with other players as well and then I tried this:

`void Start()
    {
        if(!PV.IsMine)
        {
            Destroy(GetComponentInChildren<Camera>().gameObject);
            Material mat = myPlayer.material;
            mat = (Material)Resources.Load((string)PhotonNetwork.LocalPlayer.CustomProperties["Color"], typeof(Material));
            myPlayer.material = mat;
        }
        else
        {
            playerModel.layer = 9;
            Material mat = myPlayer.material;
            mat = (Material)Resources.Load((string)PhotonNetwork.LocalPlayer.CustomProperties["Color"], typeof(Material));
            myPlayer.material = mat;
        }
    }`

But this just uses the same property as yours for everyone else so basically, they all got the same colors. Maybe there is a way for the local player to know that that exact player controller should have this exact color. I just don't know how to do it.

jade glacier
#

At a glance you are relying on CustomProperties which might not be set yet (race condition), but I can't say that for sure.

Typically for what you are doing here I would just include the players color in their instantiation data - personally.

#

If using customproperties, you might need to make color changes happen in response to the property change callbacks.

#

BUT - I am the wrong person to comment on this, as I don't actually make use of CustomProperties so I only know them in theory.

stiff ridge
#

No matter the PhotonView, you always load the came material (the one for the local player). On any client, the local player is just one client / connection / set of properties.

#

You need to load the material, as defined in the properties of the PV.Owner. Or creator.

cedar spoke
#

I want to play my game with friends but I found tutorials on unity networking gibberish. Any good resources I could check out that would helpe understand how to setup multiplayer

pliant scarab
#

Mirror tutorial by Dapper Dino on youtube

#

You need to load the material, as defined in the properties of the PV.Owner. Or creator.
@stiff ridge Thank you got it to work now!! THANKSS

drowsy vortex
#

damn, i was typing a scenario for you guys evaluate, made it in details, etc, i was reaching the end of it, and then i thought Ohhhhh this is trash, so i stopped myself from wasting your time. 😄

#

i can still share the idea if anyone is curious, but instead of optimizing, it would just add unnecessary complexity to a simple code 🙂

jade glacier
#

Is there a question at the core of all of that though? Best to just ask the question as concisely as possible.

drowsy vortex
#

yes there was a question 😄

graceful zephyr
#

@drowsy vortex wish more people would have that insight 😄

drowsy vortex
#

but when i typed the question i Ooooof at it and stopped 😛

#

no, that particular question would have been better with the context i typed, something you can't just ask without giving context, concise questions usually leads to other questions, i try to give enough information to obtain a straight answer instead of a question as an answer 😉

#

in my mind, most of the time, when i get a question as an answer to my question, it's because i failed in providing good information and making a good question. 😛

jade glacier
#

You are correct though. A well formed question is infinitely more likely to get you a well formed answer, or an answer at all.

drowsy vortex
#

yeah 🙂

#

anyway, thanks for your thoughts 😄

tough rain
#

hey does anyone know of a good socket.io solution for unity?

#

but i was wondering if there is a "you have to use this asset" solution. Previously we were using BestHTTP, which is works perfectly other than slight performance issues... but may have to go back to it 😔

tawdry temple
#

how do i check the isLocalPlayer variable?

#

and are you supposed to check if local player in every script or instantiate a different player object for non local players?

tawdry temple
#

(using MLAPI)

spring crane
#

Yea the common approach is to check ownership on each component

tawdry temple
#

thanks

junior willow
#

If I'm an experienced programmer, would it be best for me to create my own networking solution for a small fps game (4 players per game)?

#

or should I wait for unity's dots solution

gleaming prawn
#

I'd recommend neither

#

Use something that is production ready that you can find lots of documentation about....

#

There are several options that are proven to work well.

uncut bane
#

Hello, I get nullreferenceexception on

    void OnTriggerEnter2D(Collider2D collider)
    {
        if(!collider.isTrigger)
        {
            if (!photonView.IsMine) //NULL REFERENCE
            {
                Hit(collider.gameObject);
                DestroyProjectile();
            }
        }
   
    }

And I have no idea why. It happens when I shoot.

patent fog
#

Is it inside a MonoBehaviour or MonoBehaviourPun

uncut bane
jade glacier
#

And you have a photon view on the same object?

uncut bane
#

Yes I do

#

I mean, the gun is a scriptable object and it doesn't have photon view on it, but the player and the bullet does

jade glacier
#

No idea about any of that. We can only comment on what is shown.

uncut bane
#

All right so

#

Player prefab (in photon resources) has Gun child and it has bullet child. When I shoot once, there are million errors and I can't shoot anymore

jade glacier
#

What is the very first error in the log?

#

You said gun is a scriptable object, but you also said player has Gun child... so that makes no sense. You may need to clarify a lot of what you are doing before anyone can help here. @uncut bane

uncut bane
#

Yep, sorry. I'm trying to fix that and if I won't be able to, I'll ask here

fervent bluff
#

Hello. I recently started using Mirror and am having issues getting it to work the way i want. I have spent hours asking questions, Watching tutorials and reading the Docs but im still very lost when it comes to networking with Mirror. Is anyone here willing to be a PAID tutor? i feel like i would learn significantly better if i had 1 on 1 help. Im willing to switch to PUN as well as ive heard they are both really good. Please DM me if interested!

sleek laurel
#

how can i do a function on the clients side only?

#

(photon pun)

spring crane
#

@sleek laurel What do you mean by clients side only? Locally? Without hitting the relay/masterclient?

somber drum
#

I think he means only calling on client

#

Like [client] or !isServer I guess in pun

jade glacier
#

There is no concept of Server and Client like that in Pun though, since the relay is the server, and the players are all clients.

glad burrow
#

I have an error, any clue?

#

The code in the error.

jade glacier
#

The error indicates you are calling join lobby before you connected.

glad burrow
#

Any idea for fixing it?

jade glacier
#

Call join in the on connected to master callback

#

What are you using as a guide for this?

glad burrow
#

This is really just a game project I downloaded.

#

LOL

trail parrot
#

Hi. Has anyone had success in using particle system for like shotgun in networking?
Or even small amount of particle, just using the system to move them around, let each client simulate it themselves and only the server issues collision handling and also destruction of said collided particles (just send the byte spawn index)

I really think it's possible, and with a cap of like 1 byte (256) for the index, at most i'll only need to sync 256 * 8 bytes for new connecting players (2kb)

The only thing i'm wondering is about reliable indexing after i destroy some particles, but this question is more about the particlesystem itself

high night
#

@trail parrot try to sync deterministically

#

send like a startpos, direction

#

and determine the spread from hashing the current timeframe

trail parrot
#

Yep. Ill do that i think the seed will make it deterministic

high night
#

so you dont have to sync each pellet or anything

trail parrot
#

1 shotgun shot is 1 PS spawned, containing say 100 pellets

high night
#

or not sync any projectiles at all

#

you shouldnt "spawn" anything for any projectile

#

just make an rpc call to instantiate some rigidbodies or particle effects

trail parrot
#

Im spawning the ps, which will handle which particle has collided

#

And no i wont sync all pellets

#

Ill rely on the PS to burst out particles deterministically on all clients

high night
#

no need to spawn it im saying, treat it like a one time effect

#

in rpc body you could instantiate the prefab for it

trail parrot
#

But then how will the group of shots be updated if its not spawned?

high night
#

the "shotgun shot" doesnt have to have a network identity

#

@trail parrot they will all be local objects

#

i can explain it cleanly

trail parrot
#

Ok. But say 1 particle hits something. Server needs to send that event saying "the particle id 6has collided. Go destroy it in ur local clients too"

high night
#

on clientside, its just effects
on serverside, particles will do damage
and server will update clients about what that damage does

trail parrot
#

My question is, i'd like to have the client updated when 1 of the pellets hit something

high night
#

if it hits on server as well, clients will be updated

trail parrot
#

Client will be updated about the damage. But not about to destroy that single particle, bcoz theres no netId to send the message

high night
#

client can do whatever it wants the pellet, pellet is a local object

#

in client: just for looks
in server: does damage

#

client only listens to damage info server sends back
client doesnt care which pellet hits who

trail parrot
#

Thats the thing. As a client, i want them to have an accurate state about all the pellets whether theyre still alive or not, to dodge or whatever

#

My use case is not only for shotgun
Its mostly for like slow rotating enery balls aoe stuff

high night
#

on client, whereever a particular pellet is,
it wont be much too different on server side

#

you dodge the local pellet, you dodge the servers pellet

trail parrot
#

But if player 1hit a pellet and server doesnt broadcast that pellet 6 is destroyed, then player 2 will still be dodging "ghost" Pellet locally

high night
#

i see these pellets of yours need to be accurate

trail parrot
#

Not position wise bcoz they hopefuly be deterministic

#

Just about the state that theyre alive or not

high night
#

you can always destroy local pellets via another rpc

#

if you have like pellet indices

trail parrot
#

Yes and to do that i need netId on the parent PS object

high night
#

also determinitically synced

#

i see, thats fine

trail parrot
#

I think itll work

#

Just reading about the trigger/collider module for the PS, but not sure which channel to bring the question to

high night
#

there doesnt seem to be a well fit channel for it, i'd ask in either physics or general-code

trail parrot
somber drum
#

Any reason an rpc call wouldn't pass in a game object?

#

If I know the component exists

#

So should the game object

#

Calling void Rpcthing(GameObject go)

Passing in the object from a component I know exists, and it returns null? 🤔

jade glacier
#

Which library?

somber drum
#

mirror @jade glacier

jade glacier
#

Does that go have a netid?

somber drum
#

yep

#

no reason not to right? It must be something I've done in-between somehow

#

yea dumb thing with the component, I'll figure it out with debugger I'm sure

#

nah ok this is so confusing lol debugger shows the object I'm sending as Valid, Rpc sees it as Null.. Only these two are interacting with each other

somber drum
#

Annd it turned out to be a netid thing, I was going about it all wrong fixed thanks to the kind community over at mirror.

mighty light
#

Sorry if it's the wrong channel,
I'm getting this error when trying to connect to mysql on docker container
TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE
Anyone know's what's the problem ?

weak plinth
#

I just started with networking an k am pretty confused of what the differences are between Photon and Mirror

high night
#

@weak plinth with photon PUN, connections go over photons relay server, every player will connect there and you are limited by 20 concurrent users in free version

with mirror its same as minecraft by default, you connect with ip, you dont pay anything, you or your players will handle hosting themselves
but there are multiple "transports" in mirror they will allow you to pretty much anything you want, you should be able to have connections over relay servers as well with mirror, can also connect over steam via steam transport

weak plinth
#

ok thx

sleek laurel
#

how can i make everyone leave the game if master client leaves/disconnects?
(photon pun)

jade glacier
#

Just use the OnPlayerLeftRoom callback

#

And check if the departing player was the master.

#

Or OnMasterChanged or whatever that callback is named.

#

Or both.

sleek laurel
#

ok thx

#

im just gonna use OnPlayerLeftRoom

frail sorrel
#

Anyone experienced with Steamworks? Why does the SteamMatchmaking.RequestLobbyList() crash the editor?

#

It works when I use appid 480 (space war), but not the appid steam has assigned to my game

frail sorrel
#

If anyone encounters the same problem, it's as stupid as the fact that RequestLobbyList() crashes the game if there are no eligible lobbies lol

slim ridge
#

try wrapping it in try/catch

karmic void
#

Oculus Quest 2 Unity programming tutorial with Normcore.io for VR multiplayer features.

This video will show you how to:

  • Setup Normcore multiplayer feature with Unity3d and XR Toolkit
  • How to change the ray selector to change multiplayer object ownership upon selection
  • How to add RealtimeTransform and RealtimeView components to game objec...
▶ Play video
weak plinth
#

Does mirror networking work if someone on the other half of the Earth is trying to connect to me?

fair cosmos
#

@weak plinth Obviously!

weak plinth
#

hm

#

one of my friends tried to connect to me and it didn't work

gleaming prawn
#

It will not connect directly without using a relay or punch through

#

So maybe you did not ask the right question

#

If you don’t know what these two things mean, so maybe you should using something easier to work out of the box like pun

sleek laurel
#

i think my player prefab is randomly getting deleted after some time?

#

idk why

gray pond
weak plinth
#

Ok thanks

cerulean crescent
#

I'm currently writing a 2d shooter game with ECS, where I create pretty much everything from code (custom renderer etc).

NetCode as I've seen does everything with prefabs when it comes to creating players / objects that should be predictable (Ghosts) etc.
Is there some form of workflow where I won't need to create prefabs for everything, because that doesn't really fit the creation of a 2d game using spritesheets with a custom renderer etc.

I thought about possibly using Unity Transport to create my own custom solution and maybe borrow some concepts from NetCode.
Any advice would be appreciated!

green reef
#

Hello everyone, I have a networking problem that may have a simple solution. I have a host do Serverchangescene and I would have the client connect. This all worked great, but in my latest update I added sound effects and music which did not touch the network code. The client now connects and freezes up as if they tried loading before the scene finished loading. Any solutions?
P.S. The only solution I have as of now is putting the ClientScene.AddPlayer in am IEnumerator and waiting 5 seconds before calling ClientScene.AddPlayer.

gray pond
green reef
#

Never heard of mirror

#

I am using 5.x unet

gray pond
#

ooof

alpine pivot
#

Oof indeed

spring crane
#

5.x as in version of UNet or Unity

green reef
#

unity, I managed to get a sorta workaround solution. Has a few issues of its own, but livable

#

Thank you

spring crane
#

Mirror would probably be an upgrade with relatively little issues, but Mirror doesn't seem to be a fan of that ancient version of Unity 😄

green reef
#

lol I stick to the ancient version because usually unet works and I cbf to learn yet another one of unitys netcode rewrites

#

I watched a short 30 min video on someone using the new netcode and it looks like a nightmare.

spring crane
#

Well at this point one of the perks of these thirdparty networking solutions is that they are thirdparty 😄

opaque cedar
#

What is the best way to do multiplayer these days? When i started my current project i used photon but there's probably better options nowadays.

gleaming prawn
#

"Better" is relative to what you are trying to do, and to your team's expertise, etc. But there are "other" solutions, including from Photon/Exit Games (like Quantum or Bolt, or PUN2, or SNS), if you meant PUN when you said "photon".
Disclaimer: I work for Exit Games
If you mean anything from Unity officially, nothing stable or actually even useable...
Another popular choice is Mirror (which is also 3rd party)

opaque cedar
#

yes I meant pun, the "legacy" one I guess

#

I guess I'll look into pun2+ since it's on sale

#

thanks!

stiff ridge
#

PUN 2 Free and Plus are the same, aside from the one time subscription included in the PUN 2 Plus package.

#

You get 100 CCU for 60 months with the "plus" one but technically, you don't have to pay to check out PUN 2.

#

There is a sale every now and then.

opaque cedar
#

I see, thanks again.

jade glacier
#

Pun legacy (Pun 1) just exists so existing games that were made with it get the benefit of fixes. It is not recommended for anyone starting a new project. Pun2 is the current library.

hallow zinc
#

What is the best way to make network inventory?

jade glacier
#

Kind of depends on which library, your authority architecture, and what your inventory consists of. @hallow zinc

hallow zinc
#

Mirror

grizzled narwhal
#

Lol

hallow zinc
#

nothing is odne rn, i just want theory

grizzled narwhal
#

When the inventory changes => send the change to everyone who needs to know

hallow zinc
#

yes, but what with item prefabs on ground

grizzled narwhal
#

??

#

You said "network inventory" not "item system"

jade glacier
#

It typically starts with defining what "stuff" is involved. Then thinking about how that stuff can and should be indexed, serialized, spawned, etc.

#

The handling is different for a fixed set of objects that can be indexed, vs the ability for users to say craft items, and have those become part of the pool of world objects. Considerations like that need to be sorted.

#

Once you have a solid idea of the nature of the "stuff" involved, then you can start thinking about how to make that serializable.

hallow zinc
#

@jade glacier so let's say fixed set of items only, how these items can be dropped? should there be two prefabs for viewmodel and prop and what with the network identity?

jade glacier
#

Are you actually mounting these items to the object that is picking them up?

#

I am not sure about Mirror's handling of nested NetworkIdentities, but I assume it is OK. If the object needs to be reparented, you will need to sync the parent ID as well, to indicate parenting changes.

#

In that case, you likely want to just give all of these items their own NetId for simplicity, unless you are talking massive numbers.

#

Then each object just keeps track of its parent NetId. If it needs to mount to child objects of that player net object, then you will need to include some kind of system for identifying nodes on the player where things can be mounted, and serialize which node you are mounting to.

hallow zinc
#

GameObject with Network ID can't be child of another GO with NetID

jade glacier
#

Yikes, still?

#

Then that complicates it a bit yeah.

junior willow
#

Bruh can unity just release their new multiplayer system yet?

#

ive been waiting ages for this thing

alpine pivot
#

The DOTS one? even if they release that now, what about the GameObjects solution? that's what most people are gonna be interested in

jade glacier
#

The DOTS Netcode will be experimental for quite some time to forever. They did just put together a new team to make a new MonoBehaviour based offering. Not much has been said about that yet though.

patent fog
#

They stopped updating their DOTS shooter on github, but I hope they still work on that internally

grand elm
#

Does anyone know how I can make a client script that connects to my own nodejs server?

patent fog
#

C# should have some HTTP package. That is to say native, no Unity involved

grand elm
#

I know, but I need it to save the player's scores, coins, purchased things on the server

bright coral
#

Serialize -> Send

#

Networking is pretty engine / platform agnostic as far as sender and receiver go. As long as you're using the same protocol it really shouldn't matter if you're sending the data from Unity or not.

#

Never worked with NodeJS though so I don't know any specifics

gray pond
#

@hallow zinc Mirror has its own Discord for support (Asset store page has link), and your question is covered in our docs.

ocean abyss
#

Hello ! Is Forge Networking a good solution in terms of performance ? How many clients can it handle ?

stiff ridge
#

Depends on your game, network and hardware.

vale arch
#

I can and have made a game with single player version with just basic AI, but i want it to be multiplayer only. It’s a 2D game with up to 64 players (or potentially more), with some pretty simple interactions where whether two players touch eachother and a basic gun-like blast that all players have.

I looked around at hosting solutions that handle the multiplayer too (pun, unity’s suggested Multiplay), and they are very pricey for an indie developer with a small amount of cash ($850 + $0.29/cu & $1,500+ respectively. Obviously, i wouldn’t actually have 2,000+ on launch to need the $850/m plan from photon/pun- but the game really needs upwards of 64 active players in a single match to be fun, which photon stops saying 16 player per room limit at $850/m plan). Should I learn to make my own servers, seen a couple on youtube, or just give up the money and hope the first 2 months gives me enough sales to keep running with Photon/pun (or is there another option i didn’t see)?

jade glacier
#

With any library, you will want to sort out the costs of hosting. With Pun you will be looking at CCUs, with hosted servers you will be looking at bare metal costs, or cloud costs for spinning up Unity instances.

#

So you will want to bust out a spreadsheet and work out the costs at the various level of success, and sort out from that how you need to monetize to be sure you exceed those costs by a large margin (since you want to get paid of course)

vale arch
#

for the start, i don’t want to be pushing the game full of “buy buy buy these cosmetics” like fortnite, but keep more to a similar to Among Us (plus, i also still don’t know how the online data storage is to be done- do i also need to pay for an online database separate just to track (for now) free cosmetics owned and tracking game wins/losses among other simple stats?)

gleaming prawn
#

Among Us runs an infra structure VERY similar to PUN

#

FYI

#

Fully relay based, no dedicated servers with logic, etc

vale arch
#

i definitely can’t do that, upwards (or potentially more than) of 64 players will really increase network traffic more than needed, while a server-client can hide away players that are too far away to make a difference to the player

gleaming prawn
#

64 players is always challenging

#

I mean, with Photon Quantum (for which I'm one of the devs) works with 64

#

But it really depends on what kind of gameplay it is, etc

#

There's no way to do something with these specs "for cheap" IMHO.

#

I mean, you'll have to create your OWN netcode, which will take you some 3 years... give or take

#

If this is your first multiplayer game (honest question), you may consider starting with something less challenging

spring crane
#

It also pretty bold to assume you'll have 64 CCU per region.

#

Some have trouble reaching 64 total downloads

gleaming prawn
#

64 CCU is also different than 64 player per MATCH

#

Some have trouble reaching 64 total downloads
True...:)

vale arch
#

i get there is a cost, and it is fair- but i can’t pull out $1,000/m+ and hope the game makes profit in the first 2 months.

that’s why i kept the concept simple- interactions between players is just two touching or a very small gun-like blast that affects a small radiance around the player (in which, it pretty much just makes the player change sides).

jade glacier
#

You are working the problem backwards

#

Sort out the real hosting costs. Be it spinning up Unity EXEs, Cloud relay costs, whatever, and make a spreadsheet of the the costs associated with various user counts.

#

Then that will inform you how much you have to monetize your app.

#

If that cost + your personal income exceeds what you believe you can get users to spend... then stop now. Your game is just a hobby game. Release it with the free 20CCU cap, or host a machine somewhere and pay for that out of pocket.

#

Multiplayer games aren't fire and forget like single player games. You need to manage the costs involved and have a revenue if you want to come out ahead.

#

There may be some totally free options, like maybe Mirror using steamworks... but I am not sure about that. But there are very real downsides, and you have to design your game to account for that architecture.

vale arch
#

i guess i just have to go single player games till i somehow have profit to afford it all :/

jade glacier
#

I don't see why the costs are that high before you have users

#

But you do need users to pay up something, or you are just giving away your work and money.

#

Oh, the 1000+ was for Quantum you were saying?

#

Yeah, that is not geared at hobbyists atm. That $1000 gets you all kinds of tech help.

vale arch
#

I guess i’ll have to make other games that are single player instead*

yeah

jade glacier
#

I don't follow that logic, but I also have no idea what your goals are.

#

Single player games should still have a monetization plan. Unless this is pure hobbyist stuff you are doing.

#

Mirror + steamworks you can get a game out without hosting I THINK, but you do have some technical hurdles since that isn't really naturally a relay library.

Pun2 you only pay based on how successful the game is.

Same with other cloud services.

vale arch
#

pun2 has players per room limit of 16 until the premium plan (albeit, it doesn’t actually state what room limit is if any)- which for most games works fine, but my more battle royal style i had figured out doesn’t work well with that few players in a single game

spring crane
#

If you can't reliably succeed with singleplayer games, assuming your multiplayer game will hit these sorts of numbers seems a bit wishful

jade glacier
#

I would NOT attempt a BR as your first networking game

#

On any library

hard jay
#

hi, can somebody help me, I'm trying to get the id of the user from a php session variable, but i'm not pretty sure how to do that

#

this is my code at the moment, I'm using simpleJson for the second get call, in order to download the rest of the data in accord with the id of the session

weak plinth
#

Hello,
I added to my project AdMob system. I'm using interstitial ads, everything works fine. It works in such a way that after the end of the game, a button appears, which is to load the next scene (the ad appears when you click it), unfortunately the ad appears for about 1 second and the scene is loaded. The user has no time to close the ad. What condition can I use if I want the scene to load only after the ad is closed?

lone holly
#

Anyone have experience with logging in with unitywebrequests through a .NET core 3.1 api? I am having issues and need some help if you could DM me. thanks

livid gate
#

Hey, new to networking and relatively new to unity. I'm looking for a good networking system on unity. I'm trying to make it so that we have a lobby list where you can see all the lobbies created by players that you can join (games are hosted by the players). You play a match with around 10 people. Any recommendations? I saw Photon but they try to force you to use their service which I'm not a fan of.

Thinking of using server for matchmaking and p2p for in-game co-op

If you have have a suggestion for a good network system please @ me since I have all servers on mute.

alpine pivot
#

Fully relay based, no dedicated servers with logic, etc
@gleaming prawn
That's interesting for sure, how do you know for sure?

fair cosmos
#

@alpine pivot its developer said!

gleaming prawn
#

Yes, the dev has said it

#

I talked to him a couple of times as well, but he shares a lot about his tech stack publicly

fallow ice
#

Hi there, I’ve done zero networking work in unity, but I have a need to now, I see Unet seems to be being deprecated all over and I can’t find what the new world looks like - am I missing some 2020 unity network model thing?

#

I’ve done some rest async calls from unity, which worked okay

gleaming prawn
#

Unity has no built in netcode solution that is in useable state

#

Look for third parties, people develop and publish games with these Everytine for a reason

alpine pivot
#

@fair cosmos @gleaming prawn
Is there an article or something out there? Any links? Only info I can find is that they use Hazel Networking.
I'm very interested in the network infrastructure of this game.

somber drum
#

@fallow ice @alpine pivot Mirror is the community unet replacement, with a ton of improvements and close to no new features, which is important for stability / unet examples and tutorials to carry over fairly easily I guess. They also include a unet converter.

gleaming prawn
#

@alpine pivot Among Us is a very very simple game network-wise (there are many other more important aspects of it). Its architecture is a pure relay, client authority, no server logic whatsoever... There's no much to understand about that: it's exactly what you do with PUN if you just follow a basic tutorial, for example.
IMHO, What is unique about Forrest's work is that he wrote his own relay server code, deploys and orchestrates it himself with his own tooling ALONE (and with such large scale), etc.
He used to use Photon in the past, but does not make sense for him anymore because he could handle the scale with his own tools and could save some money with this. But HE still recommends people to just use Photon (at least that's what he told me)...
IMHO, most important thing to learn from Among Us (pure relay like PUN/Photon Realtime) and Phasmaphobia (built with PUN) is that you can have a super successful game with very basic networking tools sometimes: Focus on making a fun GAME

fallow ice
#

@somber drum so its safe to start with Mirror on new projects?

unreal prairie
#

Can somebody please explain what the base.OnPlayerLeftRoom(otherPlayer) does

fallow ice
#

@gleaming prawn just looked at that PUN stuff - that's cool too, might try that

alpine pivot
# gleaming prawn <@!391963258275495938> Among Us is a very very simple game network-wise (there a...

Thanks for the info and the good advice.
I'm indeed interested the most in how the Among Us developer has approached the orchestration and deployment part of networking for his game.
I'm working on my own relay based networking solution and it's nice to see that people have had decent success using these techniques.
Do you know if he is using one single server per region or not? i.e. when you select Europe in-game do you then connect to one single server in Europe or does the game balance the load across multiple servers in Europe?

gleaming prawn
#

Among Us is huge... He peaked at 2.5 Million CCU...

#

So AFAIk he runs a few thousand servers...

fallow ice
#

@gleaming prawn you saying he runs a custom back end with autodeploy for that scale?

gleaming prawn
#

yes

fallow ice
#

so he implented the PUN interface server side?

gleaming prawn
#

But notice, I'm NOT him, lol... Just check his Twitter

#

He shares a lot of insights about how he does it

fallow ice
#

cool

alpine pivot
#

Damn, I thought as much, no way one server can handle all those players

gleaming prawn
#

so he implented the PUN interface server side?
I think he implemented something similar to Photon Realtime (which he used a lot in the past)

#

And the equivalent of photon servers (both game and matchmaking servers)

#

What I said is that you can write a game exactly LIKE among Us just downloading PUN or Realtime... No need to anything fancy...

fallow ice
#

yea

#

neat thanks

gleaming prawn
#

To WRITE something like that (the infra) requires more guts...:)

#

He's forte_bass on Twitter for anyone interested in following his posts

unreal prairie
#

Does anybody know what base.onplayerleftroom(otherplayer) does

wanton vessel
#

I make a UnityWebRequest with .Post(string url)
the url has a "/" at the end, it needs that because the API won't recognize the command without it

whenever the request is done, I have an error and when I debug the requests url property, it doesn't have the "/" at the end anymore...
So UnityWebRequests removes my trailing "/" at some point in the process...
any tips?

patent fog
#

Yeah looks like it's parsed and mutated. Just a blind guess, maybe try to put a question mark in the end, like you would for sending params with a GET
/?
But you're sending a POST, so even more chances it gets discarded ^^

wanton vessel
#

I just tried /?
"category/?"
and it turned into "category?" 😦

#

I have no control over this API, it's just what I've got to work with D:

patent fog
#

Ok :/

wanton vessel
#

I tried // and /
they all get removed

#

can't find anything on google either oh well
probably will have to use a completely different http client for this one piece...

patent fog
#

Dont know if that will work, but you could try to give the constructor an URI instead of a string. I think it'll still parse it to validate but it's an easy try

#

Oh actually... You give the host to the constructor then the relative URL to the post () ?
Did you try posting directly to the absolue URL instead ?

#

@wanton vessel

#

Using an absolute URL should use the URI resource, and a trailing slash should be valid in theory...

wanton vessel
#

I've tried using the URI object, it still parses it
I haven't worked with the seperation of host / relative URL before
So when you say giving the host to the constructor, what do you mean exactly

patent fog
#

The UnityWebRequest can take the host as a param

#

So then you only need relative Urls when calling Post() for example

#

Or you can send an absolute URL, i dont know wich one you use

wanton vessel
#

right now I'm just giving the full url as string parameter with my _request = UnityWebRequest.Post(url, "") call

patent fog
#

Out of curiosity, could you try something like
_request = UnityWebRequest.Post(new Uri("https://yourhost.com/yourpath/"), data);

#

Nevermind you said you already tried

#

I'm tired -_-

wanton vessel
#

yeah at this point I tried it all
you can litterally debug the _request.url, right before you send the request
and it will be correct (having the "/" at the end)

but then whenever I access the response I can debug it again and it will not have the "/" anymore....

I can't trick it into not seeing the "/" without the API also not seeing the "/"
🤷 I'll find another way to get that json

patent fog
#

There could be a redirect on the server also. But I assumed you tested it without Unity ?

#

Yeah there might be better HTTP clients

wanton vessel
patent fog
#

Alright

wanton vessel
#

found a parameter I could attach to the url without the API whining about it, unity removes the "/" before the parameter aswell, added a "/" and unity doesn't remove that slash, but it still removes the slash before the parameter 😄

well like I said, I'll try a different one

stiff ridge
#

@unreal prairie, in general, it's C# code to call the method that is overridden (notice the "override" in the code). This is normal C# topic, which is covered in books, etc.

unreal prairie
#

Oh oke thx @stiff ridge

grand elm
#

How i can pass a form.AddField with more of 2 params?

wanton vessel
#

add 2 fields?

grand elm
#

It works, thanks a lot

grand elm
#

and how could I send a put request?

#

I know I have to send byte[] but I don't know how to put the player I want to update

unreal prairie
#

Are all the overides that you use with puncallback like a kind of if statements because that is the whay its is used ( like override onccenected to master ()
Do somethin)but i thougt that overides were something completly different. Can somebody help me out?

patent fog
#

Nothing to do with Unity or Networking

#

Just OOP Inheritance

unreal prairie
#

Ok thx i wil look into it

weak plinth
#

Hi all, I have a question about PUN2 photon. I want to change my "pass the screen" turn based 2 players game, into an online one. So I am learning PUN2 ..... im testing stuff, and getting some early results (after doing a few tutorials) , but I am not sure if it's the corret way or if Im going in the wrong direction.....

#

the Idea is that each turn, the UI is shown for 1 player, and not the other

#

and that many shared Scriptable Objects hold the game state data (points, moves, cards...)

#

i have something like that :

jade glacier
#

The easiest way for first time out is to make the whole game on a PhotonView entity, and pass ownership.

weak plinth
#

hum, interesting, im not sure I understand....

jade glacier
#

But if your game is already coded so that your logic is all over the place, that won't be an option

weak plinth
#

I already have the game, yes

#

my logic is right now, a gameloop with coroutines

jade glacier
#

Typically, converting single player to multiplayer is not recommended, and you are about to find out why.

#

If your logic is all on one place, that helps.

weak plinth
#

no no it's already myultiplyer

jade glacier
#

Ah

weak plinth
#

but it's pass the screen

jade glacier
#

"pass the screen" needs to be broken down into actual networking lingo.

weak plinth
#

well.... in the code snippet i posted above, I was hoping hiding and showing pannels (basically the UI) would be like going from Player 1 to player 2 turn ....

jade glacier
#

There are states (values) and there is who controls those states (owner/controller) and there synchronization (RPCs/RaiseEvent/Observables)

#

The UI is a backwards way to think about it, so I am going to avoid even looking at that too closely.

weak plinth
#

i guess..... :/

jade glacier
#

The UI is the end of the line. The focus is on the state data, and the controller, and how it is synced.

weak plinth
#

yeah.... hum.....I guess i was too optimist

jade glacier
#

Who sees the UI is just an IsMine check

#

I wish I could give you a better answer, but I make it personal policy to not talk people through bad architecture choices.

#

You can hack that together to work, but that is no benefit to anyone including yourself.

weak plinth
#

I understand....but I went so far, the "pass the screen " version , local 2player, is almost done, 2 years of work ahahaha.....cant change it now sadly ....

jade glacier
#

You should be able to break down your game into its parts though.

#

The first thing is to isolate out the states behind the UI info. Which you may have.

weak plinth
#

yes that I do

jade glacier
#

The next is to control which player has authority over that data. That is the player that is allowed to set the data, and who will broadcast the state changes to all other clients.

weak plinth
#

are these RPCs versions of methods a correct way to do things, in terms of making 1 client do something, and then the other one

#

yes

jade glacier
#

This involves wrapping a lot of your game logic in if (pv.IsMine)

weak plinth
#

yes, only 2 clients: the master one obviously and then the other player

jade glacier
#

The last step is setting up the sync code. Be it RPCs, RaiseEvent or Observables.

weak plinth
#

okay

#

I dont think i've quite understood the IsMine thing, I thought I did, but when I tested, it didnt work as expected.

jade glacier
#

THEN, the "passing the UI" or whatever is not part of the networking. Just at the end you monitor for OnOwnerChange (forget the exact callback name) to switch what the user is shown.

weak plinth
#

oh !

#

okay

jade glacier
#

If you don't understand IsMine and controller/owner yet - you need to do the tutorial again. It is core to everything.

weak plinth
#

the networking RPCs should not be the ones driving UI

#

yes

jade glacier
#

The UI should just respond to network events

#

Not be part of them

#

State is what you are networking.

weak plinth
#

so my networking logic should about be telling each player "it's your turn" or "its not your turn" ... ?

jade glacier
#

The callback will tell you that

#

Depending if you do a callback with ownership or not.

#

I would recommend doing a scene object for that, so you can use the owner of that object as the means to determine who is in control.

weak plinth
#

hum

#

okay

jade glacier
#

You can do that yourself, but then you have to sort out edge cases like players dropping and joining late and such.

weak plinth
#

yes

#

okay, well thanks a lot, you saved me wasting time on the wrong track with that UI thing

jade glacier
#

I would start outside of your game... on a new project.

weak plinth
#

yes of course that's what i am doing

jade glacier
#

Just make a VERY basic concept test

#

Set up the state data how it exists in your game, and try to pass around control.

#

You don't want to try to do your game, until you have a good understanding of Pun2

weak plinth
#

thats what im learning on, my test concept

jade glacier
#

yup, that is the kind of simple stuff you want to do while learning

weak plinth
#

i managed to make the end turn pass "control" but in a , evidently, wrong way..... by showing/.hiding the UI .... !

#

heresy i understand now :)))

jade glacier
#

yeah, that is the point though. Find out why that is bad with a cheap easy test.

#

Rather than failing and making a mess of your working game.

#

Try and fail a bunch of times, its all useful.

weak plinth
#

if I may.... why is it bad, besides principles or strentgh

jade glacier
#

Networking is VERY hard, but rewarding when you get it.

weak plinth
#

I mean, what problems would arise by just showing/hiding the UI in order to pass control .... ?

jade glacier
#

Why is it bad to have your UI data tied to your networking data?

#

Depends what you mean by the UI

weak plinth
#

basically, in my image the "buttons" that allows the players to interact with the game

jade glacier
#

you can make the base of your UI object a PhotonView, and store the state on components on that.

weak plinth
#

no buttons = no action possible = you dont have control

jade glacier
#

If it is all on one object, then you are just passing ownership back and forth.

weak plinth
#

but as you explained to me, hiding/showing gameobjects is not the correct way.... i didnt look into owership correctly yet, i believe

#

and i understand i should

jade glacier
#

There are a lot of questions buried in this one question, so it is hard to give you a clear answer.

weak plinth
#

i guess, no worries

jade glacier
#

You don't want the UI to be the data store, that is a given.

weak plinth
#

you already helped me a lot

jade glacier
#

No idea if that is the case here or not.

weak plinth
#

it's not, the data will be / are in scriptable objects

jade glacier
#

To work in the pun paradigm easiest, you want to make the state a child of a PhotonView.

weak plinth
#

okay

jade glacier
#

Scriptable objects makes this messy

weak plinth
#

yeah.... but my nearly complete game is already full of them for game states....

jade glacier
#

It is doable, but I can't give you an easy "how to" because that 100% relies on you to wire them up.

weak plinth
#

player status, the various status of the game.... all SOs ... :/

jade glacier
#

Yeah, which is why I cant help you. You have a completed game. That automatically paints you in to making bad choices.

weak plinth
#

yup :/

jade glacier
#

If you want to try to hack to to work, you just have to hack away.

weak plinth
#

next game will be cleaner 🙂

#

anyway, thanks a lot dude, ill get to reaading about ismine and ownership

fallow ice
#

Anyone know, with PUN, whether you can server side inject objects? Or does everything need to be created by a real unity instance?

#

Thinking of unity as a client in this sense, and some objects being under scripted server control

#

I think that might be the photon realtime i need

jade glacier
#

Or a plugin yes @fallow ice

#

The default relay without a plugin has NO knowledge of your game.

fallow ice
#

yea, I think i need most of the system running without unity - and unity as client

#

rather than P2P style

jade glacier
#

Typically to avoid a plugin, you can lean on the Master to act like a server, but that is not ideal.

#

Since the Master is 2 hops to everyone.

fallow ice
#

actually are they both p2p

#

realtime and pun

jade glacier
#

So there is more latency involved in using the Master like a server. But it allows that for that reason.

fallow ice
#

yea okay cool

#

i'll research that

jade glacier
#

Pun2 is Realtime... its just Realtime extended.

#

Realtime is just the transport layer mostly, with the region/room/matchmaking.

fallow ice
#

yea understood

jade glacier
#

Pun is a library that extends that to manage net entities.

#

The plugin works for both, since it is core to Realtime.

#

GL!

fallow ice
#

yea thanks! "to manage net entities." << aint this what realtime does? Im thinking of injecting server side entities and have them turn up in unity as gameobjects

jade glacier
#

Realtime manages players

#

There is no PhotonView in realtime that I am aware of.

#

PhotonView = Net entities with IDs

#

That is what makes "objects" and ownership and such possible. That is the Pun2 layer.

short mortar
#

Guys in photon I get this error that says

#

Can't call BoltNetwork.SetServerInfo when not in lobby

jade glacier
#

@short mortar be sure to join the bolt discord server for bolt support. They have their own discord

short mortar
#

I fixed my problem but thx for letting me know

somber drum
#

@fallow ice sorry for the late reply, yes totally safe it has to be one of the largest unity networking discord servers I've been on personally.
Lots of examples, community showcases / support

slow monolith
#

How often to send update packets? Is every 10ms good?

#

or is that gonna ddos my users

gleaming prawn
#

@short mortar if you join Bolt's Discord, next time just poke Ramon Melo there, he's the lead dev and normally very active in the community.

ornate zinc
#

Anyone got a simple solution for a local moderator/user setup? Like, 2 tablets for example, one beging moderator, the other is a user being controlled. I was thinking about using websocket, but maybe there is something better?

short mortar
#

@short mortar if you join Bolt's Discord, next time just poke Ramon Melo there, he's the lead dev and normally very active in the community.
@gleaming prawn do u know how can I join?

gleaming prawn
#

I am not allowed to paste a discord invite here

#

But you can just search for bolt or photon bolt

short mortar
#

ok

short mortar
#

Guys if im using photon and I wanna change the tag of something it tell me only the server can do that idk how can change tag in photon?
pls someone reply quick

short mortar
gleaming prawn
#

I’ll pm you an invite, it’s a public discord server

#

Done

deep coyote
#

hey does anyone know a lot about Photon Pun 2? because I'm having problems

jade glacier
#

Best to just pose the question, there are quite a lot of Pun2 users here, as well as devs. @deep coyote

deep coyote
#

ok, my game is all set up, and the multiplayer even works, but when you push a player, it's really weird