#archived-networking
1 messages · Page 87 of 1
@opaque dew my serializationrate by default was 10
so i set it to 20 on awake
and now it's smooth
thx
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?
Does the object this is on have a PhotonView?
What components are on your Player prefab in your resource folder?
Here are the components @jade glacier
Nvm I fixed it
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
@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
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
@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.
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
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)
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.
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
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 ^^"
´so you need a global database that multiple app instances can access? that has the same data?
Yeah
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
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
if you want to do something like D3 mentioned:
https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
Thanks!
@weak plinth Yeah use mirror
Photon is paid after 20 ccu
You can get 100ccu if you set up your own server
not going for anything powerful so mirror should be fine then, wasnt sure if there was something better
@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
like host the servers?
No
(artist brain here)
Its relay only
Like you host a game in steam
And then your steam friend joins you
Thats it
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
ooh yeah, i get that
But looks like there are no defined limits how much you can use it
how do i access it?
You'd release your game to steam if you got something nice
hopefully i will
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
i know hamachi a bit
Dont worry about steam now
thank you
appreciate it
haven't used hamachi(was gonna for subnautica then i realized i dont have friends :l)
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"];
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?
@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
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
no u cant
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?
I think using fixed point float is faster, more accurate and safer
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)
Read the IEEE 754 spec for a complete explanation of how floating point math is done (an example: https://en.wikipedia.org/wiki/IEEE_754)
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...
@high night ur wrong
Allright, i see. Thanks for info. I will not be trying hacky things as i suggested.
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
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
So I have spent the last few hours trying to fix these errors, does anyone have any info on them or can point me in the right direction?
The top error applies to this one
The bottom applies to this one
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
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
WhyI cannot access and how can I access to that switch value?
sorry @weak plinth I'm not sure this is the right channel. We normally discuss on the topics of online multiplayer/netcode/networking APIs.
@weak plinth Uhh, have RandomObj be a public variable rather than a local one?
oh.. you are correct.
I've just declare RandomObj as a public variable instead of a local one but i is still cannot access.
post is on hastebin.com?
I am thinking I will not use IBM anymore I have found a plugin that does the same speech thing.
thank you @robust egret
using .net sockets with il2cpp
it doesn't seem to work after I changed to that build system
anything I need to do?
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?
Help to support the channel if you are feeling super kind: https://www.patreon.com/dapperdino
Join our Discord: https://discord.gg/sn9xXK4
https://docs.microsoft.com/en-us/windows/mixed-reality/voice-input-in-unity
In this video I show you how you can use your own voice to ...
ohhh thank you you saved my life @robust egret I owe you one
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
Other online games connect without any issue? What is Photon reporting in your log?
I can't seem to get the following error "error CS1001: Identifier expected" out of this line of code. I am new to Photon
Any help?
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
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! "
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
@weak plinth your RPC target is wrong, the second parameter in RPC method is to specify receive target
https://doc.photonengine.com/en-us/pun/current/gameplay/rpcsandraiseevent
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
@weak plinth it happened when I used mirror too switch to 2020 version and it should be OK
@crimson nymph thnks
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
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.
hmm ill check thanks
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
I am getting this error "Object reference not set to an instance of an object" on the highlighted part of the code. I don't see whats wrong with it.
mean u dont have this PhotonView component on the gameojbect
What is the best free way to start adding an online multiplayer mode to an local multiplayer (offline) turn based game for 2?
@fallen cave you can use hamachi for quick try out
puts you and your friend in virtual lan
No, i mean i didn't have even added networking code
I'm literally new to this, trying to add multiplayer to a game
it can be played over lan you said?
which means you got networking code done
your game is single player then?
or like hotseat?
Sorry, i write it down wrong so, i mean my game can be played by 2 players on the same device
Yes
Hotseat
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
Ohh i see, thanks for explaining me the basic concepts
Any suggestion about where i can start learning all of these?
@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
Photon is free?
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
And can i sell my game for free if i have 20 or less players online?
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
Uhm okay, i will check it out
I just have to be sure it's free
Thank you @somber drum and @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
Mirror also have a relay server transport: darkreflectivemirror
you can use it to make rooms as u did it in photon
cool
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?
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
right now not, but in some days nat punch is coming too
@sonic echo this guy is the developer
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.
My game is a 2d game, constant round restarts, and different colored players, whats the best network asset to use? Photon? Mirror? unity's?
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.
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
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
@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.
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 😛
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.
I would assume so yes
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.
it's handling nat punching yes
If it does punch, then it is not relay
ah ok, so there the added latency
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
I keep changing photon animator view to Discrete
they keep going back to disabled when i play
or build
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
i just dont want to install external add-ons
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
@serene fern He has a specific discord for custom networking help join it!!!
How do I load a level in photon without destroying a gameobject
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.
Why is the server rendering anything at all? that's not it's job.
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.
i'd guess it's trying to be in two places at once
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.
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
@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
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)
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
I don't know, haven't used it in those situations, I think there are a few restrictions but it should all work
at the moment im developing for android linux and windows
but i would like to develop for consoles too
@alpine pivot @rugged rose Also, I have a ton of Mirror resources. Largest collection available, material for beginners and advanced users. https://trello.com/c/wMqH190r/39-important-information
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.
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.
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
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.
Will have to look into that, thanks
thanks @opaque dew
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?
Gamelift is through amazon i believe,
I found some mirror documentation about using EC2 to run a dev server on it
Yeah, I would pin the Mirror channel about this. They might have some people who have dealt with it.
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
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.
Isn't Mirror built on the deprecated UNet? That and the need for one's own server is enough to deter me.
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.
Yeah I just mean when PUN2 is an option, Mirror just seems super offputting
The choice between Pun2 and Mirror should really be based on the architecture you are after. They have very different hosting and authority models.
mm yeah true, I was centering my entire focus around Mirrors need for a server, which Gurem DID say to ignore lol
@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
yeah that's fair lol
we've worked way too hard to take that beating
I see, my bad, I'm sorry for that
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.
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.
hey guys should i use photon for a multiplayer racing game
??
is the free version enough??
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".
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
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.
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.
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.
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)
The owner by default is whoever created it.
Scene Objects are unowned, and by default Master controls them
If you have some custom rules for who can interact, the current controller would be the one to enforce that.
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
UNet is dead since a LONG time
Consider MLAPI or Mirror if you like the general approach
no comment...:)
suggestion: look for tutorials from people who actually work on released games, etc (in your case online multiplayer games)
i wish Brackeys didn’t stop uploading :(
I mean, at the time he made that video, HLAPI was probably not yet deprecated
Anyone familiar with Mirror Networking and can help me figure out why child of child of a gameobject wont update over the network?
@fervent bluff does the parent object have authority?
@fervent bluff Please join Mirror's Discord for direct support. Link is in the Asset Store page.
@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
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
@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
i can’t really find a tutorial
ay why I switched to mirror lol
should be similar though in that local authority can be checked
must be in the docs
thanks
i’m using MLAPI because it apparently has better performance
i just followed the flowchart on the website to choose
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.
thanks!
yea both my players are exactly the same
with all the same scripts
if you guys have a tutorial for MLAPI pls lmk
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?
And is there a specific time-frame that I should have clients send out their update packets? Like every millisecond or something?
i just followed the flowchart on the website to choose
@tawdry temple That flowchart shouldn't be taken as any sort of gospel
@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
@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?
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
Well the client would be telling the server his exact place in the world, so it wouldn't really be a wrong assumption right?
Btw, I've been writing online/multiplayer car physics for more than 7 years
alright
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
Btw I'm not making a really faced paced racing game, just a simple RP game
And it will NOT help anyway...:) having a server
I'm also making my own networking tool with websockets
Well, I told you what you'll see
alright
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"
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
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?
it will smooth... but
remember interpolation = MORE lag
you have the internet lag (the actual time for the data to be transferred) + the interpolation
But yes, you NEED interpolation
what I suggest is that you use extrapolation as well
to somehow compensate the interpolation
how often should I be sending out position updates
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
alright
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
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
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)
Alright yeah that makes sense
But I'll say it AGAIN:
- it will NOT look realistic/correct
It's a hack...
Try it
Have you ever played GTA V? The car networking is awful in that game but it looks alright
But technically you need to understand more
thats sort of what im aiming for
Even THAT is using extrapolation
okay
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
So extrapolation is essentially just prediction
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
alright cool
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
complicated but do-able?
also the faster a car is going, the more unpredictable it will be?
the faster it will go, the worst it will look if you do NOT use extrapolation
Does unity have extrapolation built in?
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
hmmm alright I'll have a shot at it
hmmm alright I'll have a shot at it
At what exactly?
Making the car lmao
Ahh, ok
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
this is how determinism looks like: https://www.youtube.com/watch?v=he_qd2nDPBQ&ab_channel=ErickPassos
Testing Quantum's predict/rollback fully deterministic simulation to implement 3D car physics.
Two game clients connected to same server, input being exchanged between them (via server).
No input-delay used (full rollback netcode mode), 100% WYSIWYG physics.
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
alright
This is the "holy grail"
How can I completly disconnect a player from Photon master server by calling Photonnetwork.Disconnect() (on a button)? Or maybe a different function?
appreciate it
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...
so like sending the suspension and shit over the network to the clients
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
yeah that makes sense
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
Hi guys! This is a test of our multiplayer car project. In this video We show you the multiplayer test in local (LAN) :D
★ Website: http://www.masterdevelopers.altervista.org/
★ Facebook page: https://www.facebook.com/pages/MasterDevelopers/460706697394941?fref=ts
so like this is an example of not using extrapolation?
as the cars are glitching around?
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
yeah lmao
Right at the beginning the cars are jittering
they are neither interpolating nor extrapolating
Thought so
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
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)
I long time ago (2015 I think), I wrote this: https://www.youtube.com/watch?v=5NElL09jw74&ab_channel=ErickPassos
vid is private
still private
google takes some time to propagate the setting I guess
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
No
you cannot rely on unity physics for the extrapolation
you need to run that yourself
That's what I said before
thats so confusing lmao
alright
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
yeah I get it now
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)
Ok
I would've still watched it 😉
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
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.
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
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?
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/
thanks
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)
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)
Be sure to join there Mirror Discord if you haven't @tranquil warren Usually much faster responses there for questions specific to Mirror.
ok thx
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.
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.
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.
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
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
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 🙂
Is there a question at the core of all of that though? Best to just ask the question as concisely as possible.
yes there was a question 😄
@drowsy vortex wish more people would have that insight 😄
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. 😛
You are correct though. A well formed question is infinitely more likely to get you a well formed answer, or an answer at all.
hey does anyone know of a good socket.io solution for unity?
ive been using this one https://github.com/doghappy/socket.io-client-csharp but we're having issues with ios and android.
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 😔
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?
(using MLAPI)
Yea the common approach is to check ownership on each component
thanks
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
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.
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.
Is it inside a MonoBehaviour or MonoBehaviourPun
MonoBehaviourPunCallbacks
And you have a photon view on the same object?
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
No idea about any of that. We can only comment on what is shown.
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
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
Yep, sorry. I'm trying to fix that and if I won't be able to, I'll ask here
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 What do you mean by clients side only? Locally? Without hitting the relay/masterclient?
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.
The error indicates you are calling join lobby before you connected.
Any idea for fixing it?
Call join in the on connected to master callback
What are you using as a guide for this?
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
@trail parrot try to sync deterministically
send like a startpos, direction
and determine the spread from hashing the current timeframe
Yep. Ill do that i think the seed will make it deterministic
so you dont have to sync each pellet or anything
1 shotgun shot is 1 PS spawned, containing say 100 pellets
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
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
no need to spawn it im saying, treat it like a one time effect
in rpc body you could instantiate the prefab for it
But then how will the group of shots be updated if its not spawned?
the "shotgun shot" doesnt have to have a network identity
@trail parrot they will all be local objects
i can explain it cleanly
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"
on clientside, its just effects
on serverside, particles will do damage
and server will update clients about what that damage does
My question is, i'd like to have the client updated when 1 of the pellets hit something
if it hits on server as well, clients will be updated
Client will be updated about the damage. But not about to destroy that single particle, bcoz theres no netId to send the message
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
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
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
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
i see these pellets of yours need to be accurate
Not position wise bcoz they hopefuly be deterministic
Just about the state that theyre alive or not
Yes and to do that i need netId on the parent PS object
I think itll work
Just reading about the trigger/collider module for the PS, but not sure which channel to bring the question to
there doesnt seem to be a well fit channel for it, i'd ask in either physics or general-code
Yeah im always confuses. I was pretty active in #✨┃vfx-and-particles but thats more for vfx graph..
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? 🤔
Which library?
mirror @jade glacier
Does that go have a netid?
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
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.
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 ?
I just started with networking an k am pretty confused of what the differences are between Photon and Mirror
@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
ok thx
how can i make everyone leave the game if master client leaves/disconnects?
(photon pun)
Just use the OnPlayerLeftRoom callback
And check if the departing player was the master.
Or OnMasterChanged or whatever that callback is named.
Or both.
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
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
try wrapping it in try/catch
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...
Does mirror networking work if someone on the other half of the Earth is trying to connect to me?
@weak plinth Obviously!
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
Mirror's Discord link is in the Asset Store description - join there for support. 🙂
Ok thanks
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!
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.
Sounds like you might be using Mirror. We have a discord linked from the Mirror asset store page for support.
ooof
Oof indeed
5.x as in version of UNet or Unity
unity, I managed to get a sorta workaround solution. Has a few issues of its own, but livable
Thank you
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 😄
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.
Well at this point one of the perks of these thirdparty networking solutions is that they are thirdparty 😄
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.
"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)
yes I meant pun, the "legacy" one I guess
I guess I'll look into pun2+ since it's on sale
thanks!
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.
I see, thanks again.
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.
What is the best way to make network inventory?
Kind of depends on which library, your authority architecture, and what your inventory consists of. @hallow zinc
Mirror
Lol
nothing is odne rn, i just want theory
When the inventory changes => send the change to everyone who needs to know
yes, but what with item prefabs on ground
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.
@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?
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.
GameObject with Network ID can't be child of another GO with NetID
Bruh can unity just release their new multiplayer system yet?
ive been waiting ages for this thing
The DOTS one? even if they release that now, what about the GameObjects solution? that's what most people are gonna be interested in
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.
They stopped updating their DOTS shooter on github, but I hope they still work on that internally
Does anyone know how I can make a client script that connects to my own nodejs server?
C# should have some HTTP package. That is to say native, no Unity involved
I know, but I need it to save the player's scores, coins, purchased things on the server
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
@hallow zinc Mirror has its own Discord for support (Asset store page has link), and your question is covered in our docs.
Hello ! Is Forge Networking a good solution in terms of performance ? How many clients can it handle ?
Depends on your game, network and hardware.
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)?
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)
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?)
Among Us runs an infra structure VERY similar to PUN
FYI
Fully relay based, no dedicated servers with logic, etc
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
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
It also pretty bold to assume you'll have 64 CCU per region.
Some have trouble reaching 64 total downloads
64 CCU is also different than 64 player per MATCH
Some have trouble reaching 64 total downloads
True...:)
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).
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.
i guess i just have to go single player games till i somehow have profit to afford it all :/
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.
I guess i’ll have to make other games that are single player instead*
yeah
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.
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
If you can't reliably succeed with singleplayer games, assuming your multiplayer game will hit these sorts of numbers seems a bit wishful
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
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?
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
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.
Fully relay based, no dedicated servers with logic, etc
@gleaming prawn
That's interesting for sure, how do you know for sure?
@alpine pivot its developer said!
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
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
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
@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.
@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.
@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
@somber drum so its safe to start with Mirror on new projects?
Can somebody please explain what the base.OnPlayerLeftRoom(otherPlayer) does
@gleaming prawn just looked at that PUN stuff - that's cool too, might try that
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?
Among Us is huge... He peaked at 2.5 Million CCU...
So AFAIk he runs a few thousand servers...
@gleaming prawn you saying he runs a custom back end with autodeploy for that scale?
yes
so he implented the PUN interface server side?
But notice, I'm NOT him, lol... Just check his Twitter
He shares a lot of insights about how he does it
cool
Damn, I thought as much, no way one server can handle all those players
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...
To WRITE something like that (the infra) requires more guts...:)
He's forte_bass on Twitter for anyone interested in following his posts
Does anybody know what base.onplayerleftroom(otherplayer) does
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?
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 ^^
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:
Ok :/
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...
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...
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
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
right now I'm just giving the full url as string parameter with my _request = UnityWebRequest.Post(url, "") call
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 -_-
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
There could be a redirect on the server also. But I assumed you tested it without Unity ?
Yeah there might be better HTTP clients
Yes works just fine in postman
Alright
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
@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.
Oh oke thx @stiff ridge
How i can pass a form.AddField with more of 2 params?
It works, thanks a lot
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
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?
These are native overrides
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/override
Nothing to do with Unity or Networking
Just OOP Inheritance
Ok thx i wil look into it
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 :
The easiest way for first time out is to make the whole game on a PhotonView entity, and pass ownership.
hum, interesting, im not sure I understand....
But if your game is already coded so that your logic is all over the place, that won't be an option
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.
no no it's already myultiplyer
Ah
but it's pass the screen
"pass the screen" needs to be broken down into actual networking lingo.
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 ....
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.
i guess..... :/
The UI is the end of the line. The focus is on the state data, and the controller, and how it is synced.
yeah.... hum.....I guess i was too optimist
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.
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 ....
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.
yes that I do
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.
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
This involves wrapping a lot of your game logic in if (pv.IsMine)
yes, only 2 clients: the master one obviously and then the other player
The last step is setting up the sync code. Be it RPCs, RaiseEvent or Observables.
okay
I dont think i've quite understood the IsMine thing, I thought I did, but when I tested, it didnt work as expected.
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.
If you don't understand IsMine and controller/owner yet - you need to do the tutorial again. It is core to everything.
The UI should just respond to network events
Not be part of them
State is what you are networking.
so my networking logic should about be telling each player "it's your turn" or "its not your turn" ... ?
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.
You can do that yourself, but then you have to sort out edge cases like players dropping and joining late and such.
yes
okay, well thanks a lot, you saved me wasting time on the wrong track with that UI thing
I would start outside of your game... on a new project.
yes of course that's what i am doing
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
yup, that is the kind of simple stuff you want to do while learning
i managed to make the end turn pass "control" but in a , evidently, wrong way..... by showing/.hiding the UI .... !
heresy i understand now :)))
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.
if I may.... why is it bad, besides principles or strentgh
Networking is VERY hard, but rewarding when you get it.
I mean, what problems would arise by just showing/hiding the UI in order to pass control .... ?
Why is it bad to have your UI data tied to your networking data?
Depends what you mean by the UI
basically, in my image the "buttons" that allows the players to interact with the game
you can make the base of your UI object a PhotonView, and store the state on components on that.
no buttons = no action possible = you dont have control
If it is all on one object, then you are just passing ownership back and forth.
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
There are a lot of questions buried in this one question, so it is hard to give you a clear answer.
i guess, no worries
You don't want the UI to be the data store, that is a given.
you already helped me a lot
No idea if that is the case here or not.
it's not, the data will be / are in scriptable objects
To work in the pun paradigm easiest, you want to make the state a child of a PhotonView.
okay
Scriptable objects makes this messy
yeah.... but my nearly complete game is already full of them for game states....
It is doable, but I can't give you an easy "how to" because that 100% relies on you to wire them up.
player status, the various status of the game.... all SOs ... :/
Yeah, which is why I cant help you. You have a completed game. That automatically paints you in to making bad choices.
yup :/
If you want to try to hack to to work, you just have to hack away.
next game will be cleaner 🙂
anyway, thanks a lot dude, ill get to reaading about ismine and ownership
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
Or a plugin yes @fallow ice
The default relay without a plugin has NO knowledge of your game.
yea, I think i need most of the system running without unity - and unity as client
rather than P2P style
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.
So there is more latency involved in using the Master like a server. But it allows that for that reason.
Pun2 is Realtime... its just Realtime extended.
Realtime is just the transport layer mostly, with the region/room/matchmaking.
yea understood
Pun is a library that extends that to manage net entities.
The plugin works for both, since it is core to Realtime.
GL!
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
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.
Guys in photon I get this error that says
Can't call BoltNetwork.SetServerInfo when not in lobby
@short mortar be sure to join the bolt discord server for bolt support. They have their own discord
I fixed my problem but thx for letting me know
@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
How often to send update packets? Is every 10ms good?
or is that gonna ddos my users
@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.
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 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?
I am not allowed to paste a discord invite here
But you can just search for bolt or photon bolt
ok
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
btw I cant find it at all
hey does anyone know a lot about Photon Pun 2? because I'm having problems
Best to just pose the question, there are quite a lot of Pun2 users here, as well as devs. @deep coyote
ok, my game is all set up, and the multiplayer even works, but when you push a player, it's really weird