#archived-networking
1 messages Β· Page 45 of 1
yeah their shit
but their Tools are nice
and documentation too
building a game in their platform isen't a bad choice if you want to pay for it
@compact bramble LLAPI is awful, our servers got attacked with like 3 various "vulnerabilities" from it
Crashing a server with one packet π
Hey! I asked some time ago how games usually handle networking with clients which also have servers build in them. And the specific part I mean is connecting to that server from a different IP. Now have I seen as answer steam works, but what if I also would like to supply a possible game outside Steam. How would I do this?
You need some form of relay servers
you could use your own relay server framework
use steam
use photon
or anything really
What exactly is a relay server, @sand lotus ? Since if I google it I get e-mail services π
don't click on that link unless you're using firefox, it might confuse google's tracking
β
π€
Is there any way I can use Steam's relay servers without having to apply as a partner?
yes
well
I dunno if you still need register to get the DLLs from the steamworks SDK
but it doesn't cost anything
I'm assuming now you ask more of if you have to pay for Steam direct etc to get your own appid to use with the testing?
in which case you can just use the SDK with appid 480 (shows up as spacewar in steam)
it doesn't cost you anything and you can test your game with it
@void burrow
steamworks.net and facepunch solution may ship with the needed dlls already, I'm not 100% sure about it
in which case you don't even need to register
I'll take a look if 480 works π
of course you wouldn't ship a game with that conf, but it's nice that you can test it before going full in
It's just to test yes π
Steamworks.NET be like "let's make everything a byte[]" π¦
Cause that's exactly what a transport does?
Guys what would be a good way to demo a project for a multiplayer online game? To show off a 10 player deathmtach demo without setting up a complex network so it can get funded
And is that a good idea
since I've heard you should network code a game from scratch
and not additive
I don't understand what complex network you would need to set up
why not just have 10 players connect and play?
If you're saying your game currently has no networking and you want to get a 10 player online deathmatch going....well you've got a long road ahead of you
@frank abyss
oh well
I do recommend implementing networking from the start
as for "a good way" there are just so many, and it's going to depend a lot on the type of game and what kind of server-client architecture you want
by which I mean, do you want to pay to host dedicated servers that run your game that players connect to
or do you want to have the players themselves be the hosts and connect to eachother
dedicated host vs peer-hosted (sometimes called peer-to-peer) will help determine which networking system you use, and there are a ton to choose from
we actually ran in to a similar scenario to what you're describing with our game Grabbles when we reached out to publishers
they wanted to see the networking in action, turns out, it didn't actually work
we had gone with a peer-hosted architecture, and that was the day that we learned about NAT issues on routers and how most players can not be connected to by default
the publisher did not take us on π¦
Anyone knows if NetworkServer.RegisterHandler() calls the function assigned async or sync?
almost certainly async from the perspective of the networking thread
since your handler gets called on the main thread
much of the unet code is available online to poke through if you were not aware. maybe not the pieces you need in this case though.
So, I've a big question. How do servers in general handle stuff like physics, pathfinding, world rendering, anti-cheats etc. Are there any good tutorials out there explaining how this is done or someone in here which could explain to me some stuff about the topic?
mainly server has to do no rendering just simulations of the player
physics are handled by server (eg shooting)
anti hack is (last position - current).magnitude > your tolerance value
But how do I implement for example a map server side?
I see how it can be done with for example a voxel terrain based game, but outside that idk.
just empty colliders will do just fine
no need to render it just save the same copy of the client
remove textures remove meshes keep colliders
Is there something wrong with the Matchmaker atm? My client gets kicked out after 10-20s, hardly sending any data (3.9kb/s peak on connect, afterwards 100-300 bytes/s <- not from me)
EDIT: nvm, accidentally called "StartClient" 2x
But how would I even do that server side? Would I assume if I'm using a client & host in 1 program that the client which is the host has a correct map?
hi guys I am a making a multiplayer space sim game, but my network programmer has had to leave unexpectedly. I am lead graphic artist and own the project, I need some help to fix some networking issues. I started making the game on unity 5.6, but really need to upgrade project to new unity network system.I cant log in anymore is one of the problems. Its only running on local host anyway, Also there are 3 dll files that my project uses that are no longer working and its part of the loggin in system. So yes some help to fix this would be reat. I can do collab project if anyone wants to help me out. cheers
You have only DLL files and no source?
noi, i have entire project lol sorry
Is there anyone here who has been playing around with Unitys new networking code? I have an issue I'd like some help with.
never mind. Found out the issue was because of a hidden const value that I had to change
@knotty timber " I need some help to fix some networking issues"
that's not networking, sorry to burst your bubble but unlike regular code there's no "lets just fix this little thing and leave it" with networking
usually it'll be a protracted length of time
(you need someone on it full time)
ok
starting again in 2018
n
best start with networking
unity is working on this but will take a long time yet
Without p2p sadly π¦
But asking again in here since I still don't quite get it, imagine I've a server and a client in one with 3 other normal clients connected to it. How would the server figure out how to do stuff like physics? Would it assume the client where the server runs on has a correct map where it then can run simulations inside of? I'm really new to this and would love to learn it, but I just don't quite see how it's suppose to work. π
So what's the deal with the networking atm? The current documentation still seems to be referring to HLAPI, even though my unity editor says this API is deprecated.
Sorry if this gets asked a lot, but it's hard to find a clear answer online about this.
FPS Sample is the showcase of the new networking system. it uses it
new networking system, with documetation
it also has it's own examples/samples
it's all preview though, and the current system, while depreciated, will continue to work and be supported for 2-3 years
graph there shows the depreciation timeline
once more all together for sticky sake:
https://github.com/Unity-Technologies/FPSSample
FPS Sample is the showcase of the new networking system. it uses it
https://github.com/Unity-Technologies/multiplayer
new networking system, with documetation, which also has it's own examples/samples
The New Networking is in preview though, and the current system, while depreciated, will continue to work and be supported for 2-3 years.
https://blogs.unity3d.com/2018/08/02/evolving-multiplayer-games-beyond-unet/
The Graph there shows the depreciation timeline
So no one knows an answer to my question? π
@void burrow server simulates, clients predict as always
although you'll probably have some problems since physics aren't deterministic
However, my problem already starts with getting server side a map somehow.
@paper flint Thanks π a sticky is useful indeed
The high level stuff seems way simpler to use though π¦
@glass bobcat Any idea on how to achieve that?
What's the context?
The context of?
like, why is it hard for you to get a map serverside?
You can just load the map
and run the server as a headless client
the map is a scene right?
Yes.
well just load the scene and run as a headless client
that way there's no graphics rendering
But what about the user running on that program?
If it's a dedicated server, aka with no player on it, you don't care
for listen servers a player is the server so it's just the same thing
imagine I've a server and a client in one with 3 other normal clients connected to it.
so the server is a player right?
It's running in the same physical program, so I guess yes?
That's how I would like it yes.
the client under the server communicates as normal with the server
What have you tried and what are you stuck on?
But I still don't understand how I'm suppose to just 'load in the map'.
What I've tried until now is just communicating without the server handling physics etc.
The scene yes.
What networking solution are you using?
I've messed around with LiteNetLib and with Steam.
So basically
you need to load the same map on the server and clients
else you'll have a ton of issues with sync
like players trying to go through walls server side etc
once that's done, assuming your movement is deterministic, there shouldn't be any issue
players predicting clientside should have the same results on the server's side
the server needs to handle physics
well, depends, is it server authoritative or not?
Well yes.
Are you using the CharacterController, Rigidbody or your own solution?
I'm normally using a rigidbody which velocity I change my self.
Rigidbodies aren't deterministic so you might have some desync client and server side
which, because of the butterfly effect, can become worse and worse
but the server will have to simulate physics too
you can't trust the clients with 99% of the things
That I understand.
But I should try loading the map on the server side if I get you right?
yes
The server runs standalone right?
No player that plays on the same program as the server?
Okay so a player is the server and a client at the same time?
Two solutions:
- Run the server in the background and have the player connect to it.
- Give authority to the player and have him be the server directly.
"in the background" - You mean as separate process?
Yes
run it with -batchmode -nographics
it'll run in a console window without any graphics of any kind
but still load the map etc
when the game start you can detect if it's running in headless mode
and then assume it's a server
Any benefits over using one way or the other?
I haven't really played around that much with networking, I'm fond of the theory and I've played around with it a bit
All I can think of is that it will be weird to handle a separate process on the same pc with packets.
And what about Steam?
What do you mean?
What if I'm using steam's it services to send packets?
Does it still first try to connect to it self?
Send what packets? I'm a bit lost ^^
Imagine being the host & client in separate processes and using Steam. Will the packets send from the client to server still go through Steam it's networking or will that directly return as local packet to the server?
what are you using Steam for?
But that's my question, will Steam detect that it's not necessary and send it directly back to the correct process?
You know what, whatever. I'll assume one player is the server. π
I haven't played around with Steam so I don't know
but even if it does, that doesn't matter
it'll still work
Hmm
Choices
xD
I see a plus side on running it as a separate process. If the client dies the server lives (right?).
Or does the process then just stop?
@glass bobcat ? π
depends on how you start the process
but normally
you just start it outside of the client's process
@void burrow
so yeah the client crashing won't crash the server for example
I would have to figure some stuff like stopping the server. But thatβs a pretty big advantagr I feel like.
So if I get you correct now I should try the following Create a client & server in one Unity project -> Detect if it's headless mode and assume it's running in server mode and otherwise it's a client -> Start a separate process if the client wants to start a server -> Do server stuff.
Not sure if this has been discussed yet, but can we anticipate unity's new networking layer in the next Unity update?
Having server code on client side is bad for bussines
About new Unet i think is not mature enough for anything atm
i wouldn't use it for production
Why. What's wrong with distribution of server files to customers
they can use your shit to hack
using unet is bad enough since you have no control over firewall ... no custom handshake
You just have to fix security bugs
yes but why make it easy for them?
C++ transport source is not available anything you build ontop of that is ussless
depends on game then
cloud
if you cant affford 100 euro / mo to host your server
then drop it
Our last title was open sourced and self hosted. It's still alive and making money years later
make it offline
good for you π
This notion that you should not allow customers to self host is limiting
it depends on what you are trying to achieve
if you are making a mmo = bad if you are making a shooter = bad
sims maybe are ok to some point
so you made that in unity?
ok
But my vision about self hosting hasn't changed
It's all cool that things are in the cloud
But we're game developers
Not Server hosting companys
like i said it depends on your aplication
for example i am making a free to play game and i am selling customizations
if i add server code in client is bad for business π
Question: On my mmo browser game when you opened the inventory it asks the server for items and it displays a loading indicator, then when it receives the packet it populates the UI.
So the question is : Do you think i should stick to that or how would i regenerate the item indexes once a user throws the item or make sure the inventory is an exact match on both client and server
this will only have a maximum of 12 slots so that is one short and 2 bytes per item
Sorry for my bad English π
so i regenerate inventory index on both client and server when i delete an item right?
Hey, me again π
Assuming I've to send a byte[] and receive a byte[], what would be a efficient way of creating packets so I can send or receive packets?
Because I can't imagine creating a new object, serializing it to a new byte[] or get a byte[] and then make a new object out of it is the most efficient thing to do, in the case of a game.
@sand lotus The thing is I would like to learn it my self instead of keep on using frameworks for everything. Which I'm also not a big fan of. π
Or is it really that hard that I couldn't π€
It's doable
Is it possible you could explain the concept to me?
How do I efficiently go from a class / struct to a byte[] or from a byte[] to a class / struct which also can be re-used π
Or at least I assume something is being re-used.
You write parts of it to a buffer
Like writing ints books floats
Then read back on other side
Alright, then I'm going to look into buffers.
I think I get the concept, it's simply a way of formatting your packet on a specific level like bits or bytes from given variables. But then still my question, what about all the classes / structs that are being made. Should I like recycle them?
Because I can't imagine it being very efficient to keep on creating every frame new classes / structs, when for example using player movement packets.
Should I like recycle one object over and over for each packet?
Is that even possible without proper pointers π€
It's basically a queue if I get it right @glass bobcat ?
But I don't totally see why that would be needed.
to avoid create new byte arrays every single time
but that's up to your networking solution
if it doesn't do it, well you'll have to modify the lib yourself
The thing is, it requires me to send a byte[] to it.
Why do you use low level lib in the first place if you have issues with byte[]?
The problem is not that I can't use it @undone sigil . But I rather know how to do stuff efficiently in stead of just doing something. π
And since I'm trying to learn it, I obviously don't know everything.
I'll say this, first have a game that you can live from, then focus on efficiency π
But @undone sigil then you should first get a good game, which also involves efficiency. :3
premature optimisation is the root of all evil
I personally disagree, preventing is better than healing. In my opinion π
Any advice for an insane person that wants to roll their own rollback netcode system with the basis of what photon truesync once had?
So basically, the idea is to set up a system that fulfills the requirements to integrate frameworks like GGPO.
making snapshots of the whole game state
applying snapshots of previous frame states (rollback)
deterministic simulation
multiple logical frames simulated per single visual frame
don't use floats 
haha, thanks!
maybe a bit of a background, I already started with it around 15 months ago, but dropped it a long time ago too.
at the moment, there is a fixed point number using an int64 (or long if you will), which has a distribution of q39.24. I don't handle over/underflows at the moment since it is rather expensive, but I might consider to switch to a q47.16 format, if overflows prove to be an issue in the tests.
I think one of the hardest things is to be able to completely destroy and rebuild visual state if the simulation is only dependent on data.
for objects that are in the scene anyways, it is not that hard, (just enable/disable objects), but for things like projectiles, particle effects, maybe audio, this needs to be more carefully planned out.
I wonder if I should keep track of creation and destruction events of those elements or just make it in a way so the visual state is pretty much "stateless" or at least can be completely constructed from the data representation of the world state, without having to rely on the previous visual state. (although, this might be a bit expensive, if there are elements active that are used after the rollback happened too, it would be a waste to destroy those and reinstantiate them... although it might not be that bad if those objects are pooled anyways)
but, if you have any resources, maybe about technical implementation too, that would be appreciated.
I love gafferongames for the high quality networking blog posts, and there is also this excellent post "Understanding Fighting Game Networking" from http://mauve.mizuumi.net
As it stands, Unity might only be used for taking inputs and rendering, but not sure yet
since the simulation should happen in a way that execution of functions and flow is the same on each client, I wonder if I should make a class that distributes unique IDs to entities to determine when some entities might not have to be destroyed on rollback, but simply repositioned,
the rollback would restore the number of the last used value of the ID distribution class too probably
@lusty crow https://www.youtube.com/watch?v=7jb0FOcImdg
In this 2018 GDC talk, Netherrealm Games' Michael Stallone describes the drastic engine changes, optimizations, and tools that are involved in rolling back a...
ah, thank you!
I think I encountered the talk a few months back, but glad to discover it again, will pick it up. From what I can remember it was really good (back then it was only in the gdc vault I think?)
Rollback Networking:
INVERSUS: http://blog.hypersect.com/rollback-networking-in-inversus/
Meseta: https://medium.com/@meseta/netcode-concepts-part-3-lockstep-and-rollback-f70e9297271
BBI: https://www.youtube.com/watch?v=-_0TtPY5LCc
Mortal Kombat: https://www.youtube.com/watch?v=7jb0FOcImdg
Physics/Prediction: http://www.codersblock.org/blog/client-side-prediction-in-unity-2018
you people are awesome, thanks!
there is also https://github.com/XMunkki/FixPointCS which is a fixed point math lib with focus on performance (no overflow checks as you described)
lastly, I thought I might try LiteNetLib to manage networking connections etc., since UNET got deprecated. Do you have any thoughts on that?
(basically p2p connections, one player might assume the role of a host if there are strange desyncs and just sending bytearrays I would assume (though for managing the menus and syncing that up - more high level libs might be convenient, but that is not necessary)
any low level network lib will do since you're only sending a few input-bytes
you dont need any abstraction there (imo)
thanks
Hey! Question, how did you guys learn the concepts & implementation of networking?
Internet, trial & error, open source projects.
Here lads mad idea but could you use a discord server as a database and use Unity to have a bot post messages to the server and read from them to store data?
why would you use a discord server?
It sounds more logical do me that the bot stores messages in it's own database and you query from there in unity,
maybe you can use message logs to let the bot search for messages and report back in Unity
so unity makes a request to a endpoint connected to the bot, the bot does some stuff and that backend then answers to the unity request
as much as discord breaks, I wouldn't think of it as a good candidate for this hehe
i saw someplace where someone turned Wordpress blog into a database
I would store the things you want to query in a separate database
but i'd honestly probably go for something made for the task, like Google App Engine, they give free quotas which are great for starting out
I've been using it for over 7 years now as a free data storage and application DNS service
never paid a dime
only limit that may be an issue is with the free tier you only get 1 gig of data storage
but really depends what you're storing if that's enough.
newbie here reading up on Photon PUN. When you do an PunRPC call, is the method only executed on the "same singular object" on each of the clients? Like, if there were 5 trees, and a PunRPC was called on tree #3, the method is run on tree #3 on all clients?
Yeah good point about it breaking to be fair, my reason for it is I figured it would be a cool way to visualise data and easy to modify. Impractical, but cool nevertheless lol
@nimble grove yes it is only called on the one
thank ya
ah interesting, didn't think about that
You could always have an RPC method which calls a static method if you need that
true yeah
@lusty crow : As you mention TrueSync, I guess you know about Quantum? It is the spiritual successor and a full predict rollback network system. However, I guess you want to implement it yourself, right?
I heard about it, yes,
but I can't quite afford to pay 10,000$ a year though π
(except if they have changed their pricing?)
I am open for suggestions of existing frameworks, but I want to try it myself, yes (until I have found a better solution that is).
(oh, seems like it is 1000$/month for sdk access now)
@graceful zephyr needs payment
sure! ^^
I go for cheaper
there are some unity games utilizing ggpo, but you still have to set up your game to support it, which isn't an easy feat.
the team behind Dynasty Feud even managed to make their completely own rollback system
Yes, you have to setup your game to support it but once that's done, all the networking is done by the system sending input. That's all. No decision what to sync, how and when.
that's true indeed
Did the Dynasty Feud team post something about their system? Is there a postmortem or such?
GGPO afaik also only works with 1v1 scenarios
i could be wrong on that tho
i.e. fighting games
they revealed some of their approaches in a forum thread (dynasty feud),
from what I have seen in the documentation, it works with more players too, (I think legal league uses it and allows for 4 players?)
but the problem is that it is p2p and with 4 clients, your latency is pretty much the latency of the worst connection between any of the clients
hello fholm!
Lethal League! It is a mixup between fighting and baseball game, there is one ball flying around and you hit it with a bat.
Other Unity games I know to use GGPO: Fantasy Strike and Punch Planet
Thx
Are there any games out yet that use photon quantum?
not sure, but I have seen someone that develops for quantum before
*with the quantum sdk I mean
Sure lots but it isn't for solo Devs anyway
Fholm is the architect for it so he knows
I like how it is ECS and uses deterministic physics
quantum uses ECS?
I know it does have fixed point math for physics (for determinism)
I thought fholm's ECS networking experiments were for something totally different
I would assume it uses one ECS architecture and is it's own thing but not unity ECS?
still, really cool
I wouldn't assume it uses ECS at all unless otherwise stated somewhere π

Everyone doubts old hippo but learns in the end :p
I
hey guys, newbie here again with a quick question. I'm reading through Photon's PUN 2 documentation and thinking ahead of how to set things up. Lets say I wanted to make a Diablo-like game (where players team up against enemies). I'm wondering how to handle who controls the enemies.
Is this correct: The "Master Client" PhotonNetwork.InstantiateSceneObject() to spawn the enemies, and thus controls/updates them. If the Master Client disconnects, the enemies persist since they're a "Scene Object" and control is transferred over to the new Master Client?
Generally yes, the MasterClient will act as the authority of NPCs unless you can manage to make it deterministic (which you probably aren't going to)
@nimble grove
I haven't written much around master client changes, but the general idea would be to not store any server only stuff on the master, so that at any point any client could become the authority when the HasAuthority torch is passed
@jade glacier thank you! sounds like what I had in mind with the passing the torch... awesome
PUN isnt a strong server/client relationship because you don't REALLY want to be routing all traffic through it (the relay servers make that slow and expensive)... so generally you will end up making most things very player authority, with the exception of some key stuff you give the master authority over... like scores or any other values that would break things if all of the clients disagreed on.
gotcha, thank you
are we not allowed to post code? I just typed up a question and hit enter and it instantly disappeared
Test test
Im making a simple game using PUN 2. Everything is working great so far, except that when I run the game twice on my computer, the camera for the second player doesn't follow their character.
- In the first scene the player just presses the Connect button. When OnJoinedRoom() is called, the scene is switched to the Gameplay scene using PhotonNetwork.loadlevel().
- In the Gameplay scene is an object called GameManager with a script that spawns the player and sets a target for a script on the Main Camera so that it follows that player.
For some reason it works for the first player to connect to the server, but not the second. I can't seem to post code so I'm not sure how I'm supposed to get help...
Camera.main.GetComponent<CameraHandler>().target = spawnThisPlayer.gameObject.transform;
Thats in the start() function
If I look at the Main Camera in the Inspector while running the game (on the second player), the Target field is "None". I know I'm reaching that line of code where I set the target because I did a Debug.log line there
you can post code using tags (as shown in the sticky in #π»βcode-beginner ) as long as it's not too long. if it's a long script, use pastebin/hatesbin or something similar.
ah ok thats probably what it was, thanks!
my "GameManager" script: https://pastebin.com/LQ1GnbPf
I'm new to Unity but I feel like I grasp most of the concepts... but I'm having difficulty figuring out why the camera's target is set for the first player to join the room but not the second
well hopefully someone can answer that, Networking is a mystery to me, I've never touched it.
hehe yeah, no problem. if there is a better way to show whats going on i'd be glad to add info. honestly the project is so small I wonder if I could just upload the project or something π
(and I'm posting here in the networking channel because its only the 2nd player to join that has the camera issue, so I'm thinking its something related to using PUN but have no idea why it would happen)
@vital hawk yeah quantum has its own ECS
Read a lot of the linked articles on rollback networking, the 8 frames in 16ms talk was fantastic,
I think now I am ready to torture myself try an implementation π
static public List<NetworkConnection> localConnections { get { return instance.m_LocalConnectionsFakeList; } }
this are ANONYMOUS connections?
in NetworkServer
I was wondering, if i want to sync a lot of entities over network like trees to change the weather dynamically, i guess i wont check every frames if i changed the weather it would be unoptimized, i thought about events but i dont get how it works wouldn't it be easier to use events for lets say Inputs instead of checking every frames for a change ?
cs NetworkMessage.conn.connectionId
xd
@solar garden u can asign each "Changing tree" a unit id
and whenever you change somthing just let all the clients that can see the tree know
anyway it seams conectionID is bugged
if i open the server is auto decrementing
Yeah but you would have to check every frames right ?
for eg if i go online on user id 1 and then go online on user id 2
i get connection id 1
lol
no
what would change to your trees?
A single var
i mean u will change the collor or leafs
or what exactly π
anyway the controler that changes your var
make it update clients
The movement of the tree agains wind
But i was thinking like if i would use events to change the value but i guess i still have to check in a uptate anyway
Im thinking about optimisation
Because the game would be a multiplayer fps i im trying to find the best way to not use bandwith for nothing
So your situation is as folows hoot: you have 1000 trees, and you have a wind going through your scene, why dont you just inform the clients of any wind strenght change and let the trees move on each client as the wind tells
so as soon as wind changes from 3... to 4 strength
just inform them of that
and done
Yeah but i would informe them each frames ?
how often does the wind strength changes
and does the wind change scene wide or localised/
you could opt to send new windstrength every second or every 5 seconds, and client side it would move towards the new defined strength every frame a little bit
Oh it would be just one change of var and i guess localized
Its cosmetic
if its 100% cosmetic then don't waste data on it
can't clients just do everything local
as long as its not storming on one player and idle on other it's fine
you could set up that on start of game wind is a certain value and be done with it
or if you want varying levels of wind
Well thats the problem the wind could change in a game
either have a deterministic floating value that pingpongs for everybody
or regulary just send to clients the current server wind in intervals
make wind scene wide will be a lot easier
if you want varios winds on local places
then you have to make some zone system
where people are in a certain windzone
Oh no i meant wide
and then you send to the people in that zone the wind value
most simple solution send server wind strength every x seconds
client side Mathf.MoveTowards(curwind, serverwind, 0.2*Time.deltaTime);
or some variation of that
Thats what i was wondering wouldn't events be usefull here ?
events?
I dont really know what they do but
depends what events
you have c# events
unity events
maybe some network library events
xD
why would you use them
no
C# events is to do something and call event receivers all over your code
has nothing to do with networking
I thought it was something you can call when ever something changes instead of checking every intervals
@sand lotus how do you manage your serverscene player reference
i mean in how many containers
That's a funnny one
yah
well we don't use any build in unity networking stuff cause it's crap
i use 3 lol
but we have a network transport that has peers
do you sell it?
no
anyway
peers have ids
and they are in a array
to send shit you loop over that array
and that array has structs that connect them to player objects and other shit
Peers are provided by network library
or auto incrementation
I recommend this one
Simple basic UDP network library of high performance
What do you guys use for your network ?
then you hook your own higher level stuff on that
well that ^
and a lot of my own code
i used unet transport layer
Oh ENet ok
it dosent alweys send disconect
i guess that is your implementation
if you're set on not wanting to use enet you can try litenetlib
using (Host server = new Host()) {
Address address = new Address();
address.Port = port;
server.Create(address, maxClients);
Event netEvent;
while (!Console.KeyAvailable) {
bool polled = false;
while (!polled) {
if (server.CheckEvents(out netEvent) <= 0) {
if (server.Service(15, out netEvent) <= 0)
break;
polled = true;
}
switch (netEvent.Type) {
case EventType.None:
break;
case EventType.Connect:
Console.WriteLine("Client connected - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP);
break;
case EventType.Disconnect:
Console.WriteLine("Client disconnected - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP);
break;
case EventType.Timeout:
Console.WriteLine("Client timeout - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP);
break;
case EventType.Receive:
Console.WriteLine("Packet received from - ID: " + netEvent.Peer.ID + ", IP: " + netEvent.Peer.IP + ", Channel ID: " + netEvent.ChannelID + ", Data length: " + netEvent.Packet.Length);
netEvent.Packet.Dispose();
break;
}
}
}
server.Flush();
}
i used what they give on github
i just want a library that handles low level stuff
Yes same
i dont give a fuck about high level
yep
Lucky i tried i dont get anything :/
obviously
swtiching connections ids
shit tons of bugs lol
do i have any choice lol
Yeah dont use unet it will be gone anyway
Anyway tell about this problem you have with enet, i could maybe fix it and PR it
Yeah your choice is varios
You can opt for enet, LitenetLib, or any of the others that come to mind
They are kind of similar anyway it wouldn't be a big switch
and it worked?
yes?
By all means if you know a bug i can repro that would be great
yes.
I PR to it
Just PM me with details if you want
enet itself is super old and has been used in countless games
this specific fork is less old and possibly can contain bugs
but it should be very stable
if i had a way to integrate 3d phisics in java
i would of used my mmo engine
lol
it uses nio sockets (TCP) but is very stable
isnt WoW also using tcp?
yes
Wow has enough money to put a server or at least relay servers next door to the players
most indies are not in that position
data stalls are a real thing
How did you guys started with networking i can't find anything good to learn low level networking
π€
As long as your βjust doingβ doesnβt involve getting security leaks in a live game π
You can still make mistakes with that.
Minecraft for example which would allowed a server to check if any file exists on a connected client π€
That it breaches the privacy of a user.
Wow but like any files ?
But besides that you also had a lot of weird hacks because the server didnβt check enough what the client is doing.
I believe it was only on the disk running, but yes.
You cant hack very far if the calculation is on tve server yes ?
Yes, but if you donβt check certain stuff clients can do the craziest things. Thatβs the point Iβm trying to make. Also you should secure the client from the server in the case that players can access the server.
π
Or rather in general secure both sides from each other.
Im in the scope of a fast passed fps appart from position sync you cant go wrong :p
Sure you can.
Well in the mean time im not even that far so i cant really say
Items, hits, health..
Yeah its hard work
When i started i didn't thought it could get this more complicated but then networking and shaders came along π
π
Is there a way to use steam id for players in unity ?
Not sure how reliable it is though.
hey guys, has anyone ever worked with a large scalable server structure and want to give me some insights?
for a brief explanation...
basically we have horizontally scalable lobby servers where clients are actually connected to and got their data cached, we also got a cache layer to distribute necessary information across the whole structure and a matchmaking server which is not scalable and deals with all matchmaking for that region...
what we need insights to is how to deal with parties from players who are connected to different lobby servers, how to make their connection? (where does the request fall to? who sends the request? who receives the request?) after the connection is done how to queue the party in the Matchmaking server?
I know it isn't exactly a question, it's more like a request for sharing similar experiences and practical knowledge! has anyone ever run into a structure like this or a problem like this? would you mind sharing ideas, solutions, etc?
@obsidian ocean this is wayy to big to answer in a simple "oh here's your solution"
Thx @void burrow
@graceful zephyr Yep I understand this... But it's so hard to find the needed information on the topic and it's such a delicate part of the development, I thought a broader approach would be more productive...
@obsidian ocean I have, with success, used an actor based system before (Project Orleans) running on azure, it takes care of the clustering for you
Is there a possibility for a webgl game to keep running in the browser even when the tab is not focused?
I was telling someone that you can check "running in background" but that doesn't fix the issue that the browser itself actually decides on how many resources to allocate to each tab. So it could be that despite the setting, the game won't be updated when the game tab is unfocused in the browser.
Is this true and if so, is there a possibility to prevent that?
slams table
I just want to send only inputs and have clever people (tm) work out all the net stuff for me
what are you referencing? ^^
Unity's new networking.
Unity exists to fix everything that isn't my fault yet
I'm quite happy to convert my entire codebase to dots if that is a genuine side effect.
haha,
their new networking solution is very barebones still, from what I've heard.
Someone I know made a wrapper around it, with package confirmation, channels like all cost delivery and fragmented sending and stuff like that
(or is that in by now? I thought it is only a simple interface for sending and receiving packages with a few additional functions?)
It's shit
don't use it
its nothing more than a wrapper around native sockets
no reliablity
nothing there has any possiblity to scale
and their weak attempt to slap jobs on it doesen't help at all
ah yeah, thx
I'm aware a lot of people are looking at my comment regarding automatic networking as if I'm a mad bastard from mars, but it's not a difficult thing to achieve within a closed box, and dots code is that closed box, so the possibility of it (for physics based stuff) is still on the table at least (if everything possible goes through physics)
i dont get all this fuss about physics over network
im not to this part yet but in a authoritative setup why would it mater
Yeah in authoritative setups I should be able to do nearly no work on networking
server has his rolling barrel and clients only get the pos and rot updated
Actually with full determinism, this data does not need updating at all
ah ?
your local client simulates it with correct accuracy
it would need corrections at some point
one of the benefits of deterministic lockstep is that you only need to transmit inputs and occasionally make hash checks etc., that can safe a lot of internet traffic
but creating deterministic systems for everything, like physics for example, can be a real pain
if you have regular server authority structure, you should also have a game and data layout that makes the amount of data sent to each client not too expensive, this is a consideration of how much bandwidth you can expect clients to have, with upload and download
in the early days, with age of empire for example and the really low kilobyte internet back then, deterministic lockstep was really the only way to go (imagine how many units there can be in a game and how much it would cost to keep them synchronized across all clients if the game was not deterministic)
lockstep is not the same, because wit ECS worlds you do not need to suffer the drawback of lockstep, that is, the client will pause waiting for others, because we can resimulate up to a point and the dots is fast enough to handle that
With lockstep in RTS, it's OK to wait before sending input until the next cycle because RTS is a lot slower pace
And if you are too late in your actions, your input is queued
It can't work for an FPS game, but dots can make that sort of thing work in theory
(due to rewind and simulate up to)
is there already a technology or framework that actually uses lockstep with unity dots?
I agree that - maybe ecs in general - but especially the way unity implements it is well suited for rts games
I read somewhere that unity will build their upcoming features burst-compatible and βdeterministic by defaultβ, so once thatβs released (ai, navigation, physics..) it should be easy to add networking (or create a deterministic lockstep framework) with dots
yep, however, I am not confident to give any estimations how long this might take
hey guys, I posted a question/issue a couple days ago but I dont think I explained it very well so I didnt get any responses. I've been trying to figure it out but have had no success. I'm testing out PUN2, and made a super simple test game, but for some reason the script for the camera works for the first player that joins, but not any player that joins after that. I made a video showing the issue: https://youtu.be/AAkcFD9zh3o
Would really appreciate any help - I'm fairly certain its somehow related to PUN2 even though its the camera that is having the issue. (side note: no other scripts touch the Camera besides the one in the video where I set the target)
@compact bramble using full predict/rollback for an entire FPS simulation is not.. easy either
as it comes with other weird caveats
@nimble grove didn't watch video because on mobile but I'm assuming your camera isn't working on the 2nd player?
Some things to remember with cameras and networking. If camera is spawned in with player be sure to destroy any cameras not owned by the player.
I'll look at the video later when I'm at my computer. Or you can link code here.
Thanks @indigo current, im setting the target of a script on the Main Camera (camera.main) . Not creating any additional cameras. Hopefully its something silly im overlooking but i have no idea what (maybe something special with how PUN does LoadLevel() or something?) Thank you for the help
can you paste method where u set camera
I watched the video but its hard to see the debug on mobile. I'm not seeing where you show debug on second player when it joins.
PUN LoadLevel is only for master client and syns other clients to that level.
Weird. The check of IsMine looks fine and it even logs that the camera gets set as target.
How do you switch scenes?
Maybe it's related to the LoadLevel() bug we had in PUN v2.8. The level got loaded after the OnJoined callback. I guess you instantiate and set the cam target but due to loading the second scene there is a new camera instance.
There is a PUN v2.9 in the Asset Store with a fix for that execution order. It may be the solution, @nimble grove .
@graceful zephyr I agree it's impossible for most but when you have a company with billions then the customer rightfully demands these problems get solved :D
Being completely inside a deterministic across any cpu closed box does help a lot though.
@compact bramble no i mean there are actual mechanics in how a full predict/rollback simulation works which makes it at least partially unsuitable for FPS games
It's unsuitable if it's not high performance enough to do it for every actor
?
I don't think 100 players would perform well if it requires the amount of rollbacks I'm imagining it could need
but maybe dots?
Anyone which has a nice article about client side prediction? π
Most modern networking solutions provide prediction already.
I'm using a bit more low level stuff π
I found this btw, which I'm currently reading. http://www.gabrielgambetta.com/client-server-game-architecture.html
I'm not one of the Subnautica devs π
@indigo current @stiff ridge Thank you guys for the help! This is the "Launcher" script - the LoadLevel() is called in OnJoined callback like Tobi said (its basically a copy of the PUN2 basic tutorial's Launcher script): https://pastebin.com/yu71q4Pu
Going to update PUN2 and see if that helps
Is it correct to call the initial LoadLevel() on all clients in the OnJoinedRoom callback? I am indeed using AutomaticallySyncScene = true
@stiff ridge Welp, updating did indeed fix the issue! Awesome
Thank you
No, loadlevel is for master client only
@nimble grove
If automatically sync scenes is enabled other players will join automatically after receiving a message by photon
ohhh I see where I got confused I think
https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/gamemanager-levels ("Loading Arena from the Lobby" section)
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!
i was referencing that Basics Tutorial and I'm not changing Arenas/Levels based on the number of players, so I took out that line checking if PlayerCount = 1
Cool thanks, didn't realize the initial scene would get loaded for the players that join later on so long as the Master Client calls it (I suppose it caches the LoadLevel call or keeps track or something)
I have a full PUN series. It was originally for v1 but the information works on v2.
Here's my video on level transition that might help
https://www.youtube.com/watch?v=f8WsLIiRyJU&list=PLkx8oFug638qVMIrtqOnwmqnW6o8WDgQ1&index=6
You can skip over anything not related to loading the level
If you do and you come across something thats not PUN v2 accurate please let me know.
Read description of videos π
it was one of my first series so its not my best work but I cover a ton of material
While you're here do you mind answering a quick question? I posted on the forums : https://forum.photonengine.com/discussion/13731/best-way-to-call-an-rpc-from-a-child-object-that-doesnt-have-its-own-photonview#latest
Not sure if I should be reconfiguring my "Player" setup or something
hey guys, I read that fixed update is actually not really fixed, it could run multiple times in a frame which makes it not reliable for network loop so is there any kind of unity loop(coroutines, invoke etc.) that i can rely on ? or should i seperate my loop in a dedicated thread ? and in that scenario what is the best way to deal with unity API thread safety ?
you have to reference a photonview component to make the call, so most use the one on the parent. adding another photonview is an option and might not be awful if you don't have hundreds of views.
but generally you go through the main one
also if youre using it for actions like shooting where lots of bullets are about you should be using events (its in one of my videos, a shorter one near the end)
so like, if the child object "Left Gun" needs to call its own method SwitchGun() on call clients, is there any way to do that without adding an additional RPC* method to one of the parent "Player" scripts?
(also thanks, I'll find that info on the events for the bullets)
Its been a long time since Ive used photon but I think you can call in the script without the view, while referencing the view from the parent
but you'd have to test that
iirc photon links up rpcs with scripts not the views
Ok it looks like you dont have to "observe" a script with PhotonView to call an RPC on it, but when I tested it, it doesn't work for RPCs in scripts that are in child objects
you might just have to attach another photonview
which isnt really a big deal if ur running a small game
yeah that'd totally work, and this game is indeed just a test project... was trying to think ahead for more complex player/enemy prefabs and how to organize it. wasn't sure how much 'slower' it'd be having multiple PhotonViews on each enemy kinda thing
worry about performance later.
its really easy to optimize networking down the road once u better understand it
cool π
only use RPCs for vital things though
like 'player died' or anything that would break the game if it didnt send
roger that
@compact bramble again you're missunderstanding me, it's how a full predict/rollback simulation works technically that makes it hard to do for an FPS, i.e. how it affects gameplay, shooter first mechanics, etc.
has nothing to do with performance, or wallhacking, etc.
stuf flike that
with the dots stack + threading that's probably fine
@stone prism in order to realize a real fixed update loop, you literally have to interrupt other executing processes between execution, there is a good reason why this isn't the case in the unity event flow
fixed update should be sufficient enough in that, let's say after 10 seconds, the simulations should have executed the same amount of fixed update cycles.
however, there will always be small discrepancies, and if one machine cannot keep up, the fixed delta time is permitted to be a little bit longer, depending on your settings, so that would need to be considered
I am not sure how modern frameworks solve this, but the server could keep track of the lastly executed frame it receives from the clients and if there is a too big discrepancy, let some clients wait 1 or 2 frames here and there, so that players are in sync again
but depending on your network model, that might not even be necessary,
but it would be important in any kind of lockstep like system
and yeah, you could have 0 fixed updates in 1 update cycle, or 3
depending on how long the update cycle actually lasts
hmm im using state synchronization model so as you said it looks like i dont need that kind of precision, thank you for detailed explanation
@stiff ridge Does PUN2 RPCs accept ulong and uint? My demo code required me to ByteConvert those values to long and int - wondering if I can remove that from my demo code yet. And heya.
https://doc.photonengine.com/en-us/realtime/current/reference/serialization-in-photon NM, answer is there for me.
I guess that leads to the question of whether PUN2 can eventually support unsigned primitives?
Photon doesn't support ulong and uint, so you have to convert those.
To properly support this, we would have to add that to our serialization, which is lower-level. Obviously, it could be done but is a bit more effort to get it into the server, too.
I couldn't give an ETA for that but will take a note of the feature request.
no worries, more just a curiosity at this point
Easy enough to byte convert, just makes my unified code for various platforms a little goofy looking having to explain my usage of ByteConverts all over
Those are the only missing pieces?
That I have run into, I don't really do much outside of byte[] though so I am not really the target audience for the various primitives and such
@stiff ridge
You maybe could make an overload that implicitly byeconverts on the way in and out if you want to avoid touching the guts of your engine? But really... that's a can a worms and if no one is complaining about the lack of unsigned support... maybe just ignore me?
My reason for wanting it is strictly for the dumbest cosmetic reasons
hehe
Char maybe as well? Basically once you get in there.. just add all of the C# primitive types?
Anything could be registered as Custom Type quite simply but there's overhead associated with custom types (type and length info), so I would prefer primitive types directly supported.
Just an odd step anyway for something "primitive"
esp when you guys did some of the hard stuff like dictionaries... an odd omission of the really easy stuff.
I don't know if your serialization packs values at all protobuf style, but zigzagging the signed values might have some benefits if there is some internal use of PackedBytes
(separate topic)
We skipped uInt and uLong as we thought there are not frequently used and there very few requests over the years. But yes: Kind of strange in hindsight.
Zigzag encoding is used for Int and Long.
The newer Protocol 1.8 has a few more tweaks but there's room for improvement, of course.
Yeah, then probably not something to be concerned about. My use case is kind of oddball so I'm not really the best person to be putting in requests. π
Question, how would one implement client side prediction with entities bumping into the player? Since I can't see that go very well with what I've read.
(The picture attached is the scheme for what I've seen so far)
I think the short answer is you will have lots of prediction misses since the player lives in the future
You can try to extrapolate the entities that bump into the player, is their movement at least somewhat deterministic?
ie. You can predict where they will be in x milliseconds?
With entities I also meant other players, so not really I think.
Then you will get lots of misses, for the obvious reasons
prediction puts the local player's entity in the future relative to the server-based world rendering around him
So you either need to move your player back in time (don't predict)... or you need to extrapolate the world to get a better guess of how it will look in the future (where the player is)
Don't predict would be a lot worse I feel like.
yup
having players able to bump into one another exposes the ugliness that most networking wizardry tries to hide from the player
Things like firing projectiles are mushy enough that you can futz with the time difference
But bumping right into another entity that exists in a different timeframe... you get into Dr. Who. TimeyWhimey trouble
Didn't Minecraft fix this problem a bit with how their system works?
Like if 2 players overlap which each other they can still stand inside each other, but get pushed away a bit over time instead of being unable to at all stand in each other.
Because then you can predict based on the position of the other player where you should get pushed to.
Or would it totally fail what I'm saying right now? xd
yeah, that could be a solution
you will have to build in some kind of forgiveness or slow correction, but its going to keep you out of full sync... whether that is important or not... is up to your game
None of it fails
just desyncs have to be dealt with
one way or another
In our game I disabled pushing but you still bump into eachother, the server is authority so if client side physics get out of sync it just moves you back or both players if they both make weird things, it works okayish, small dragging of players to correct position is almost unnoticable
If you are running a simulation in the background and what you are rendering is interpolations of that sim... you can correct pretty harshly on the sim side... and smooth that out in the Update() phase so the player doesn't feel it
But the client will still know its REAL location, even if its not showing it to you immediately
I'm really starting to understand why networking can be a real pain π
And how big of a topic it exactly is, the more I read about it.
yup, bottomless pit
but as long as you don't let it scare you, even making crappy networking is fun and useful while you get it sorted
I've started with a server which pretty much only broadcasted packets π
I'm 2 years in and still learning. I'm not going to have my ServerAuth asset done for like another year probably - its a massive array of challenges
So looking into how to improve that.
The learning process is never over in programming π
I'm now trying to get a p2p system working with 1 authoritive peer.
Which only does movement with client side predicition & I'm going to try to implement the MineCraft way for entities I think.
yup, refactor refactor refactor
And then toss it all in the trash ... and start over once you realize why those shortcuts were bad ideas
and make a whole new set of bad shortcut choices
Never throw away projects.
repeat
You can learn so much from them π
Keep working components, but projects should get burned often imo
I found with networking, over time solid components and libraries emerged that I got right
I would keep those, and toss out the rest
https://assetstore.unity.com/packages/tools/network/transform-crusher-free-version-117313 Like this guy evolved from my many attempts. It kept being the core part I could keep when starting over.
π
So another question, I have once again the same set-up as previous. https://cdn.discordapp.com/attachments/497874116246896640/561126416255811585/fpm2-05.png
How would I handle this situation if a packet is lost?
Because then the client will predict the movement wrong.
it will be corrected when server sends the true position
it not just prediction its prediction and correction
I understand, but the prediction will get lost no matter what?
Unless your client is lagging π
yep ^^
this is just a test to see how prediction works under such unrealistic network conditions
600 ms latency and 3/2 drop rate which makes it nearly impossible to play any kind of game
or even watch a video π
hey all
does ReadPackedUInt32 makes the transmitted data smaller ?
or WritePackedUInt32
It's basically using a variable length encoding
Bits Min Dec Max Dec Max Hex Bytes Used
0-7 0 127 0x0000007F 1 byte
8-14 128 1023 0x00003FFF 2 bytes
15-21 1024 2097151 0x001FFFFF 3 bytes
22-28 2097152 268435455 0x0FFFFFFF 4 bytes
28-32 268435456 4294967295 0xFFFFFFFF 5 bytes```
so depending on what value you send over the network it will use more or less bytes
so small values use up less space than a normal 4 byte int
whilst high values might actually use more bytes.
it uses the first bit of every byte as a flag to tell if the reader should read the next byte aswell for this value
if you write a packed value you should also read a packed value
don't mix them
The Unity NetworkReader and Writer are terrible and slow though I would not use anything unet at all.
oh
i was trying to pack vic and caster player ids
tyvm for explication β€
are slow because it converts every value even if is the value it expects lol
i mean it casts the value
for eg write(int32) in the write function it has (int32)Value
π
:)))
casting primitives is almost a nothing cost. I doubt that would be the source of any slowness. Probably just more some inefficient code for doing the counting of zeros on the left. @weak plinth
@void burrow If you are doing your server auth by sending user inputs, the general practice for lost packets is that the server assumes you are holding down the same keys for that missing tick that you were for the previous tick. If it guesses wrong, then a correction will be needed.
Is anyone aware of how to integrate amazon gamelift client into Unity?
Everything I found seemed unnecessarily complicated
@indigo current I'm going through your Photon Networking v2 tutorial (and I'm using PUN2) -> if I see discrepancies how do you want me to notify you? Could comment on the video or message you here. Thanks again for the tutorial
I could also compile them and give you them when I finish the tutorial
Cool
I made them originally for v1 but I did review the API changes and updated descriptions where needed. There's always a chance I missed something though. Also previously I didn't have the ability to link to other videos for hotfixes, while I do now.
Lots of hot networking action in here lately.
Hello, I want to get into networking, whats a great tutorial?
Im used to ue4's networking and unity has network manager but it says its going to get removed.
oh
How much high level are you looking for
This might be a good start
I have been using ue4's networking so i should be able to wrap my head around somethings fast
@latent warren I recommend Mirror and Telepathy https://github.com/vis2k/Mirror They're good working and simply written, good for learning. The documentation is sufficient. If you want UDP networking though, you might want to switch out Telepathy for something else (like Unity LLAP, SteamNetwork or Enet).
Creating a multiplayer game? You're going to need matchmaking! Google Cloud and Unity have been leading a new open source matchmaking project that's extensible and scalable to millions of players. In this session, learn how Open Match works and...
@sharp willow thanks, i will check it out
@latent warren If you want something that works out of the box, is scalable and used by a lot of people, you might want to look into PUN: https://www.photonengine.com/pun
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!
Not so good for learning networking though
i have seen pun, so is it possible to have like a dedicated server?
Photon uses a concept of rooms. You can have a "player" who is in reality a server is sitting in a room and other players can connect to the same room. You set the server "player" to have authority and you basically have a dedicated server. Photon just handles the relay service and matchmaking.
oh okay, thanks for explaining
That's PUN though, they have other services too. I think Photon Server is what you want if you want to handle your own network of servers. https://www.photonengine.com/en-us/Server
Redistributable cross platform multiplayer game backend for realtime games and applications. Develop authoritative logic with SDKs for android, iOS, .NET., Mac OS, Unity 3D, Windows, Unreal Engine, HTML5 and others.
Other fun things are Photon Quantum, which I'm using at work and is amazing for fast-paced games.
i dont want to own any servers, i would like for player to launch their own dedicated servers
Then imho you shouldn't look into Photon and do your own networking setup using something like Mirror.
oh ok
PUN is quite good if you don't need dedicated servers and only need p2p.
i think i will look into mirror
For games below 8 players that's quite nice
well my game will prob have like 30 or less players in a match
Then, if you really want player-hosted servers, you should do your own networking using Mirror or something similar. My two favourite picks for that are Mirror and ENet.
alright, Im used to ue4's networking where most things are handled for you lol
but it will be neat learning this
Unity is in a peculiar position right now. UNet is deprecated and the new networking layer won't be production ready for at least a year, so your best bet are external assets like these two.
alright, well thanks for telling me about mirror and other options
I imported Mirror from the asset store and it just gave me a lot of compile errors.
better go to mirrors discord and ask for help there
alright
The issue with DragonMar was a System.Threading DLL in his project that shouldn't have been there, not an issue with Mirror.
We helped him in Mirror's Discord sort it out.
Yep, one of my assets had that dll and removing it fixed the errors
looking forward to dots based networking
would be nice to know on what sample project they are working, in the gdc talk it was described as the 'mother of samples' π¬ i guess it will contain dots networking, either with prediction/rollback or deterministic lockstep
@sharp willow Though honestly the best advice for anyone is to abstract completely as possible from any networking library or engine
Write and read byte[] and try to rely on things like syncvars/rpcs as close to zero as possible
Code entwined with HLAPIs = unreusable knots of garbage π
There are diffrent approaches. One might suggest going from the bottom up and learning the low level stuff first, but it takes a long time to reach a functional game that way and that might discourage some people that are starting out.
I like for starters having the connections all handled and the NetIds provided
that feels like a good compromise
You can still handle your order of serialization and such and practice good networking
without getting lost in setting up connections and trying to handle messages
But that is just one approach, its just where I think most people would be better off starting
At least if they don't want to generate piles of useless code libraries
And generally makes porting to a new library less hell
I see too many devs developing one game for X years, while doing stuff that is basically reinventing the wheel. The advantage of using popular open-source networking libraries is that they're community-tested and optimized, and if you don't like something in them - you have the code, you can change it. You can spend months/years developing your own networking solution or you can focus on actually making your game.
For sure
but most of what you write generally is going to come down to serialization of objects in some form
the problem with the HLAPIs is they can all dramatically vary in when they process RPCs and syncvars and such
Serialization is just one small part of that. The bigger problem is synchronization.
I say this having a store asset that works for PUN and UNET
yeah, that is the issue
the timings of the libraries are wildly different, so its best to abstract from any of that
You can use syncvars and rpcs, but they should be abstracted enough to defer any critical processing of them to where it won't matter when they arrive or leave
But really, at that point, why not just pass around a byte[] and serialize it like a big boy π
I'm not saying its for everyone, just that my advice to anyone who wants to get decent with networking and isn't just farting out "MyFirstAndOnlyNetGame"
they should really abstract away from the HLAPIs and write their own handling for writing frame based state updates
But if they aren't ready for that, at least getting down to the object level serialization gets them on the right path for things like bitpacking and setting up tick based frames and such
Having a zillion syncvars and rpcs is a brutal port to anything
Again, not trying to fight here - just saying that is the advice I give
Hello everyone!
Hazel is back! Please see:
https://github.com/DarkRiftNetworking/Hazel-Networking/issues/12#issuecomment-480527680
Any good resource on how to handle network movement/physics, the jittery movement just wont do it for me, even with a simple Lerp 
for physics i found lerping position and setting velocity works preeeeety goodokayish
If you want to drop a few bucks, this has some pretty good sync logic: https://assetstore.unity.com/packages/tools/network/smooth-sync-96925
would you say its worth it as a learning resource? just checking out the code
because it doesnt support dr
dr?
dark rift networking
The logic there is pretty universal and can be applied to any LLAPI.
It also contains the full source code, so you can modify it however you want.
The support mentioned there just means there's a few extra methods for those specific APIs.
You can easily add your own.
i checked it yeah, but its way to highlevel for me, no idea whats going on^^ im still very new to networking got my own jittery movement sync working but its pretty shit, but works for "now" oh well
"my own solution" aka Vector3.lerp oldposition newposition time.deltatime 
You generally have to start with how you are simulating @torn compass
To get a good smooth result, you need an even simulation timing that is sending at a regular interval as well - ideally from a simulation that is tied to like FixedUpdate... rather than just moving stuff in Update() with time.deltaTime
Once you have an evenly timed simulation to sample from (like with rigidbodies and physx)... you send an update on that tick
That way on the receiving side it knows what the t value for your lerps are
on the most basic level you can store your incoming updates in a Queue, and pull from that queue in FixedUpdate... and lerp between the previous and the most recently dequeued
That ensures your lerps are all perfectly spaced
which = smooth
On a more advanced level, you would number your outgoing updates - and store those in an ring buffer (an array) - and pull from that. The advantage there is it knows if a frame got lost in the mail, and knows to extrapolate or interpolate a replacement frame if you experience packetloss or a late packet.
ill start with getting it all in a queue, baby steps ^^
right now im just lerping the oldpos to newpos received
Once you get that queue going, then you are on a better path
the main thing to remember with networking is that the Simulation comes first, and is god
networking is second
If you have a solid tick based simulation system, you can use that to predict on clients using the exact same code that the server uses, and everything starts to be nice and tidy and deterministic.
The simulation is god, and the networking just fills in the blanks that the simulation uses. If they don't get filled in time (latency/loss) the sim keeps going with its best guess.
You then later can start to think about how to clean up desyncs, which will be easier since you have a nice tidy simulation. @torn compass
@torn compass Make sure that you update oldPos to be the position of the game object at the point in time when you recieve the message and then also try using LerpUnclamped
if that doesn't fix the jitteryness perhaps it's just packet loss and you should do what valve does and keep a buffer of two snapshots so that if one is lost you don't see any jitter
the Entity interpolation part
I used darkrift initially but switched to ENet and this worked for me. This worked on DR
//On position update from server
playerNetworkData.ID = newData.ID;
playerNetworkData.position = newData.position;
playerNetworkData.rotation = newData.rotation;
//Take snapshot of position when we recieved the message
lastPostion = transform.position;
lastRotation = transform.rotation;
timeSinceLastUpdate = 0f;
void Update()
{
float interpolant = timeSinceLastUpdate / ServerSettings.Instance.TickRate;
transform.position = lerp(lastPostion, playerNetworkData.position, interpolant);
transform.rotation = slerp(lastRotation, playerNetworkData.rotation, interpolant);
timeSinceLastUpdate += Time.deltaTime;
}
using physx with interpolation on rigidbodies is the same concept
where lerp is actually Vector3.LerpUnclamped
just using the Unity.mathematics library
and slerp is Quaternion.SlerpUnclamped too i believe
you don't have to interpolate anything unless it's rendered though if its purely for a visual step
I think I dont need to update oldpos
its simulated on the server, so transform.position is basically oldpos at that point in time
i just noticed, i wasnt even updating in update
when receiving a movement package
i just called a void SetTransform()
i'd guess your jitter issue is due to using Lerp and not LerpUnclamped. If say for example you have an update rate of 10 updates per second and a position update packet comes in a little bit over 100ms since the last update, say 120ms for example, your object will stay in place at the final point for that extra 20ms
also if by "Vector3.lerp oldposition newposition time.deltatime" you mean Vector3.Lerp(old, new, Time.deltaTime), that's not what you want to do. That will move you some fraction of the way to the new position each frame.
like if you were running at 100fps you'd be moving 1% of the way between old and new each frame
instead you'd want Vector3.LerpUnclamped(old, new, timeSinceLastPositionPacket/timeBetweenPackets) where timeBetweenPackets would be 0.1 seconds for an update rate of 10 updates per second
and only update old when you get a new position update
or just do what hippo said and use physx interpolation
but i think understanding how you are meant to use lerp is important. People use Time.deltaTime as an interpolant all the time for no good reason
with Time.deltaTime it's more like an easing function rather than linear
i really appreciated your help, but i think im to stupid for all this yet ,still trying to figure alot of sync stuff out, why its not working, how to handle it better, how to setup better, etc, its really not easy ._.
ill try to implement all what you said and report back once i got something working
hey all. been looking around for a while now, and it seems that mono has a bug with WSS connection. I can easily connect to a WebsocketServer, but once I try a WSS, get an exception on connect. anyone has ever managed to create a WSS connection?
Which networking package are you using? @weak plinth
probably all of them π I tried System.Net.Websockets,. Websockets-sharp, and some other implementations I've found around Github
I even have a project that can connect if I run it under Visual Studio via a console app, but bringing it into unity it fails
There is a lot of info about Mono bugs, and also some issues with how mono manages its certificate store
but I have yet to find a solution that works for me inside unity
wrong cert is probably the issue....there's unity forum posts about that
Mirror supports websockets with wss out of the box, so you might want to look at that [https://assetstore.unity.com/packages/tools/network/mirror-129321]
@weak plinth
The problem from what I was reading seems to be that Mono uses their own certificate store. i'll check out mirror, thanks!
@jade glacier why is unity stealing my high performance physics that has networking capability
New Networking, New Physics, DOTS, Real-time Raytracing and Visual Scripting?! Get 25% off all Synty Studios Assets: http://bit.ly/SyntyStudios β₯ Support Bra...
lol
I'll have to watch, or do you mean the DOTS name? π
"Built with networking in mind"
you are optimistic there friend
@jade wharf
one day I will have my idealistic future of automatic networking by default (it's not so dumb, I mean UE4 does have this if you inherit from agent)
I think emotitron mean the physics part
but it is built networking in mind
so that's not even a stretch
Unity needs way more timing callbacks for the whole lifecycle of each screen refresh for starters
Like a "Post Physics" callback for starters
I do
as well as my own time and simulation stuff... the point is I had to do all of that
Unity needs to do it
Having callbacks for timings at all will be a nice thing coming with DOTS
hmmm, if the graph is to believe at https://docs.unity3d.com/Manual/ExecutionOrder.html, input events from the old input system at least run right after all physics steps have been done
Update and FixedUpdate don't cut it for physics
well, for starters, I wouldn't even want DOTS simulation groups to use the regular Unity callbacks
like, they plan to use fixedupdate for simulation group again
but I'd rather have thing that steps the physics on ECS code itself
of course one can modify these as one wishes
Whatever the pipeline is, I just want to be able to subcribe to callbacks to each phase of it, and be able to really manhandle the order of exec inside each of those
Unity Physics actually does have more callbacks in general
you can get stuff done in the middle of the physics sim parts
I see, well fixedupdate is just a function call with a perfectly working mechanism so no reason not to use ?
well, fixedupdate is trigged by code we don't have access to
FixedUpdate isn't even tied to physics. If you turn off autosimulate.. Fixed keeps going
we do
its going to be a bit antiquated
I want full access to as many parts I can, especially if it drives the physics
there is api for changing the order unity does its calls
yeah, I'm aware how fixedupdate runs right now
@vital hawk Exactly, I want a callback for everything
you can toggle the autosim off, step as youwant
with current setup, I'd disable the built-in setup as I don't want Unity to handle physics stepping code at all
it's only way I can be in full control
I do turn it off, and I simulate it in my updateManger's fixed... after I call OnPrePhysx and then after I call OnPostPhysx