#archived-networking

1 messages Β· Page 45 of 1

compact bramble
#

we're talking about a company with more money than unity trying use unity's tech for free and pulling a hissy fit when their plan didn't turn out

sand lotus
#

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

undone sigil
#

@compact bramble LLAPI is awful, our servers got attacked with like 3 various "vulnerabilities" from it

#

Crashing a server with one packet πŸ‘€

void burrow
#

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?

sand lotus
#

You need some form of relay servers

#

you could use your own relay server framework

#

use steam

#

use photon

#

or anything really

void burrow
#

What exactly is a relay server, @sand lotus ? Since if I google it I get e-mail services πŸ˜‚

split crescent
#

don't click on that link unless you're using firefox, it might confuse google's tracking

#

β›…

void burrow
#

πŸ€”

void burrow
#

Is there any way I can use Steam's relay servers without having to apply as a partner?

vital hawk
#

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

void burrow
#

I'll take a look if 480 works πŸ˜„

vital hawk
#

of course you wouldn't ship a game with that conf, but it's nice that you can test it before going full in

void burrow
#

It's just to test yes πŸ™‚

void burrow
undone sigil
#

Cause that's exactly what a transport does?

void burrow
#

I understand.

#

But I'm still sad

#

xD

frank abyss
#

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

rigid fiber
#

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

frank abyss
#

I don't know anything about networks and I don't have a game yet

#

It's research

rigid fiber
#

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 😦

weak plinth
#

Anyone knows if NetworkServer.RegisterHandler() calls the function assigned async or sync?

rigid fiber
#

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.

void burrow
#

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?

weak plinth
#

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

void burrow
#

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.

weak plinth
#

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

calm snow
#

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

void burrow
#

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?

knotty timber
#

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

sand lotus
#

You have only DLL files and no source?

knotty timber
#

noi, i have entire project lol sorry

wheat flower
#

Is there anyone here who has been playing around with Unitys new networking code? I have an issue I'd like some help with.

wheat flower
#

never mind. Found out the issue was because of a hidden const value that I had to change

compact bramble
#

@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)

knotty timber
#

@compact bramble ok

#

Im recreating the project anyways mate

compact bramble
#

ok

knotty timber
#

starting again in 2018

compact bramble
#

n

#

best start with networking

#

unity is working on this but will take a long time yet

void burrow
#

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. πŸ™ˆ

tardy thistle
#

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.

paper flint
#

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

void burrow
#

So no one knows an answer to my question? πŸ˜”

glass bobcat
#

@void burrow server simulates, clients predict as always

#

although you'll probably have some problems since physics aren't deterministic

void burrow
#

However, my problem already starts with getting server side a map somehow.

tardy thistle
#

@paper flint Thanks πŸ˜ƒ a sticky is useful indeed

#

The high level stuff seems way simpler to use though 😦

void burrow
#

@glass bobcat Any idea on how to achieve that?

glass bobcat
#

What's the context?

void burrow
#

The context of?

glass bobcat
#

like, why is it hard for you to get a map serverside?

void burrow
#

Because I have no idea how to do such a thing xd

#

And never done it before.

glass bobcat
#

You can just load the map

#

and run the server as a headless client

#

the map is a scene right?

void burrow
#

Yes.

glass bobcat
#

well just load the scene and run as a headless client

#

that way there's no graphics rendering

void burrow
#

But what about the user running on that program?

glass bobcat
#

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

void burrow
#

imagine I've a server and a client in one with 3 other normal clients connected to it.

glass bobcat
#

so the server is a player right?

void burrow
#

It's running in the same physical program, so I guess yes?

glass bobcat
#

well that doesn't change anything really

#

it behaves as a normal server

void burrow
#

That's how I would like it yes.

glass bobcat
#

the client under the server communicates as normal with the server

#

What have you tried and what are you stuck on?

void burrow
#

But I still don't understand how I'm suppose to just 'load in the map'.

glass bobcat
#

define load in the map :p

#

load the scene?

void burrow
#

What I've tried until now is just communicating without the server handling physics etc.

#

The scene yes.

glass bobcat
#

What networking solution are you using?

void burrow
#

I've messed around with LiteNetLib and with Steam.

glass bobcat
#

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?

void burrow
#

Well yes.

glass bobcat
#

Are you using the CharacterController, Rigidbody or your own solution?

void burrow
#

I'm normally using a rigidbody which velocity I change my self.

glass bobcat
#

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

void burrow
#

That I understand.

#

But I should try loading the map on the server side if I get you right?

glass bobcat
#

yes

#

The server runs standalone right?

#

No player that plays on the same program as the server?

void burrow
#

That's the problem, they'd.

#

It's not a dedicated server I'm using.

glass bobcat
#

Okay so a player is the server and a client at the same time?

void burrow
#

Yes.

#

Like I said before, one program that runs both client & server.

glass bobcat
#

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.
void burrow
#

"in the background" - You mean as separate process?

glass bobcat
#

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

void burrow
#

Any benefits over using one way or the other?

glass bobcat
#

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

void burrow
#

All I can think of is that it will be weird to handle a separate process on the same pc with packets.

glass bobcat
#

Not really

#

the local player connects to its local ip

void burrow
#

And what about Steam?

glass bobcat
#

What do you mean?

void burrow
#

What if I'm using steam's it services to send packets?

#

Does it still first try to connect to it self?

glass bobcat
#

Send what packets? I'm a bit lost ^^

void burrow
#

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?

glass bobcat
#

what are you using Steam for?

void burrow
#

It's relay servers.

#

If needed

glass bobcat
#

You won't need it for the local player

#

For remote players yes you will

void burrow
#

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. πŸ™‚

glass bobcat
#

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

void burrow
#

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 ? πŸ˜„

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

void burrow
#

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.

visual tulip
#

Not sure if this has been discussed yet, but can we anticipate unity's new networking layer in the next Unity update?

weak plinth
#

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

sand lotus
#

Why. What's wrong with distribution of server files to customers

weak plinth
#

they can use your shit to hack

sand lotus
#

Yes new unity network is nothing finished

#

They can always hack

weak plinth
#

using unet is bad enough since you have no control over firewall ... no custom handshake

sand lotus
#

You just have to fix security bugs

weak plinth
#

yes but why make it easy for them?

sand lotus
#

Because money

#

Customer self hosting

#

Saves a lot on cloud cost

weak plinth
#

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

sand lotus
#

Our last title was open sourced and self hosted. It's still alive and making money years later

weak plinth
#

make it offline

sand lotus
#

It sold 4 million copies

#

Because of its openness

#

People created thousands of mods

weak plinth
#

good for you πŸ˜ƒ

sand lotus
#

Special customized servers

#

And maps

#

Etc etc

weak plinth
#

what kind of game you have?

#

may i have link?

sand lotus
#

This notion that you should not allow customers to self host is limiting

weak plinth
#

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

sand lotus
#

It's a shooter

#

You're too close minded

weak plinth
#

so you made that in unity?

sand lotus
#

No

#

We're working on a game in unity now though

weak plinth
#

ok

sand lotus
#

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

weak plinth
#

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 πŸ˜ƒ

sand lotus
#

Yeah

#

I suppose

weak plinth
#

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 πŸ˜›

sand lotus
#

One packet is fine

#

You could sync transactions

weak plinth
#

so i regenerate inventory index on both client and server when i delete an item right?

void burrow
#

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
#

Use a serialization class

#

Like mine

void burrow
#

@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 πŸ€”

sand lotus
#

It's doable

void burrow
#

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.

sand lotus
#

You write parts of it to a buffer

#

Like writing ints books floats

#

Then read back on other side

void burrow
#

Alright, then I'm going to look into buffers.

void burrow
#

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 πŸ€”

glass bobcat
#

You can yes

#

Search for circular buffers

void burrow
#

It's basically a queue if I get it right @glass bobcat ?

#

But I don't totally see why that would be needed.

glass bobcat
#

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

void burrow
#

The thing is, it requires me to send a byte[] to it.

undone sigil
#

Why do you use low level lib in the first place if you have issues with byte[]?

void burrow
#

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.

undone sigil
#

I'll say this, first have a game that you can live from, then focus on efficiency πŸ˜„

void burrow
#

But @undone sigil then you should first get a good game, which also involves efficiency. :3

glass bobcat
#

premature optimisation is the root of all evil

void burrow
#

I personally disagree, preventing is better than healing. In my opinion πŸ˜„

lusty crow
#

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

jovial rapids
#

don't use floats feelsscientistman

lusty crow
#

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

sand lotus
lusty crow
#

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?)

lusty crow
#

you people are awesome, thanks!

jovial rapids
lusty crow
#

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)

jovial rapids
#

any low level network lib will do since you're only sending a few input-bytes

#

you dont need any abstraction there (imo)

lusty crow
#

thanks

void burrow
#

Hey! Question, how did you guys learn the concepts & implementation of networking?

sand lotus
#

Internet, trial & error, open source projects.

lethal tree
#

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?

lusty crow
#

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

paper flint
#

as much as discord breaks, I wouldn't think of it as a good candidate for this hehe

lusty crow
#

yeah

#

should be rather slow

paper flint
#

i saw someplace where someone turned Wordpress blog into a database

lusty crow
#

I would store the things you want to query in a separate database

paper flint
#

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.

nimble grove
#

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?

lethal tree
#

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

nimble grove
#

thank ya

lethal tree
#

np

#

Not sure about static methods though, if that's even possible

nimble grove
#

ah interesting, didn't think about that

lethal tree
#

You could always have an RPC method which calls a static method if you need that

nimble grove
#

true yeah

stiff ridge
#

@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?

lusty crow
#

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)

compact bramble
#

@graceful zephyr needs payment

lusty crow
#

sure! ^^

compact bramble
#

I go for cheaper

lusty crow
#

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

stiff ridge
#

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.

lusty crow
#

that's true indeed

stiff ridge
#

Did the Dynasty Feud team post something about their system? Is there a postmortem or such?

graceful zephyr
#

GGPO afaik also only works with 1v1 scenarios

#

i could be wrong on that tho

#

i.e. fighting games

lusty crow
#

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!

stiff ridge
#

Interesting. Thanks for the info.

#

Legal League or Lethal League? πŸ˜ƒ

lusty crow
#

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

stiff ridge
#

Thx

jovial rapids
#

Are there any games out yet that use photon quantum?

lusty crow
#

not sure, but I have seen someone that develops for quantum before

#

*with the quantum sdk I mean

compact bramble
#

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

vital hawk
#

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

lusty crow
#

I would assume it uses one ECS architecture and is it's own thing but not unity ECS?
still, really cool

vital hawk
#

I wouldn't assume it uses ECS at all unless otherwise stated somewhere πŸ˜„

jovial rapids
vital hawk
#

oh, it was on the topic πŸ˜„

#

I swear I read the bullet points πŸ˜„

compact bramble
#

Everyone doubts old hippo but learns in the end :p
I

nimble grove
#

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?

jade glacier
#

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

nimble grove
#

@jade glacier thank you! sounds like what I had in mind with the passing the torch... awesome

jade glacier
#

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.

nimble grove
#

gotcha, thank you

nimble grove
#

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.

  1. 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().
  2. 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

paper flint
#

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.

nimble grove
#

ah ok thats probably what it was, thanks!

#

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

paper flint
#

well hopefully someone can answer that, Networking is a mystery to me, I've never touched it.

nimble grove
#

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)

graceful zephyr
#

@vital hawk yeah quantum has its own ECS

lusty crow
#

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 πŸ˜…

weak plinth
#
 static public List<NetworkConnection> localConnections { get { return instance.m_LocalConnectionsFakeList; } }
#

this are ANONYMOUS connections?

#

in NetworkServer

solar garden
#

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 ?

weak plinth
#

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

solar garden
#

Yeah but you would have to check every frames right ?

weak plinth
#

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?

solar garden
#

A single var

weak plinth
#

i mean u will change the collor or leafs

#

or what exactly πŸ˜„

#

anyway the controler that changes your var

#

make it update clients

solar garden
#

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

sand lotus
#

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

solar garden
#

Yeah but i would informe them each frames ?

sand lotus
#

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

solar garden
#

Oh it would be just one change of var and i guess localized

sand lotus
#

how localized?

#

and how often does that strength change

solar garden
#

Its cosmetic

sand lotus
#

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

solar garden
#

Well thats the problem the wind could change in a game

sand lotus
#

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

solar garden
#

Oh no i meant wide

sand lotus
#

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

solar garden
#

Thats what i was wondering wouldn't events be usefull here ?

sand lotus
#

events?

solar garden
#

I dont really know what they do but

sand lotus
#

depends what events

#

you have c# events

#

unity events

#

maybe some network library events

#

xD

solar garden
#

C# events

#

Would be the same ?

sand lotus
#

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

solar garden
#

I thought it was something you can call when ever something changes instead of checking every intervals

weak plinth
#

@sand lotus how do you manage your serverscene player reference

#

i mean in how many containers

sand lotus
#

That's a funnny one

weak plinth
#

yah

sand lotus
#

well we don't use any build in unity networking stuff cause it's crap

weak plinth
#

i use 3 lol

sand lotus
#

but we have a network transport that has peers

weak plinth
#

do you sell it?

sand lotus
#

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

weak plinth
#

based on what principle u make a peer ?

#

ip ?

sand lotus
#

Peers are provided by network library

weak plinth
#

or auto incrementation

sand lotus
#

I recommend this one

#

Simple basic UDP network library of high performance

solar garden
#

What do you guys use for your network ?

sand lotus
#

then you hook your own higher level stuff on that

#

well that ^

#

and a lot of my own code

weak plinth
#

i used unet transport layer

solar garden
#

Oh ENet ok

sand lotus
#

don't use unet

#

its broken

weak plinth
#

i tryed to use enet

#

but the events are broken

sand lotus
#

where did you get stuck

#

they are not

weak plinth
#

it dosent alweys send disconect

sand lotus
#

i guess that is your implementation

#

if you're set on not wanting to use enet you can try litenetlib

weak plinth
#
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();
}
sand lotus
weak plinth
#

i used what they give on github

solar garden
#

Its never the fault of the software πŸ˜›

#

I settled on Forge

#

Its medium level

sand lotus
#

yes it does a lot of stuff for you

#

it depends the skill of programmer and time

weak plinth
#

i just want a library that handles low level stuff

sand lotus
#

Yes same

weak plinth
#

i dont give a fuck about high level

sand lotus
#

yep

weak plinth
#

i can make that easy

#

so far unity is acting gay on a lot of players connected

solar garden
#

Lucky i tried i dont get anything :/

sand lotus
#

obviously

weak plinth
#

swtiching connections ids

sand lotus
#

LLAPI is unstable from 8 players on

#

don't use it

weak plinth
#

shit tons of bugs lol

sand lotus
#

HLAPI is broken at all

#

just don't use Unet

#

plz no

weak plinth
#

do i have any choice lol

solar garden
#

Yeah dont use unet it will be gone anyway

sand lotus
#

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

solar garden
#

They are kind of similar anyway it wouldn't be a big switch

weak plinth
#

Vince did you use it on production

#

i mean enet

sand lotus
#

yes

#

i am

weak plinth
#

and it worked?

sand lotus
#

yes?

weak plinth
#

ok

#

lol

#

do u update it or made any changes to lib?

sand lotus
#

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

weak plinth
#

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

sand lotus
#

tcp for games oh boy

#

i guess for slow paced MMO its ok

jovial rapids
#

isnt WoW also using tcp?

sand lotus
#

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

solar garden
#

How did you guys started with networking i can't find anything good to learn low level networking

sand lotus
#

just doing

#

Networking is not easy

void burrow
#

πŸ€”

solar garden
#

Yeah i get that πŸ˜„

#

Ok then

void burrow
#

As long as your β€œjust doing” doesn’t involve getting security leaks in a live game πŸ˜…

solar garden
#

😱

#

Well as long as it is authoritative πŸ˜„

void burrow
#

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 πŸ€”

solar garden
#

Check ok but then what ?

#

Whats the problem ?

void burrow
#

That it breaches the privacy of a user.

solar garden
#

Wow but like any files ?

void burrow
#

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.

solar garden
#

You cant hack very far if the calculation is on tve server yes ?

void burrow
#

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.

solar garden
#

Im in the scope of a fast passed fps appart from position sync you cant go wrong :p

void burrow
#

Sure you can.

solar garden
#

Well in the mean time im not even that far so i cant really say

void burrow
#

Items, hits, health..

solar garden
#

Yeah its hard work

#

When i started i didn't thought it could get this more complicated but then networking and shaders came along πŸ˜„

void burrow
#

πŸ˜‚

solar garden
#

Is there a way to use steam id for players in unity ?

void burrow
void burrow
#

Not sure how reliable it is though.

obsidian ocean
#

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?

graceful zephyr
#

@obsidian ocean this is wayy to big to answer in a simple "oh here's your solution"

solar garden
#

Thx @void burrow

obsidian ocean
#

@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...

graceful zephyr
#

@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

lusty crow
#

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?

compact bramble
#

slams table

#

I just want to send only inputs and have clever people (tm) work out all the net stuff for me

lusty crow
#

what are you referencing? ^^

compact bramble
#

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.

lusty crow
#

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?)

sand lotus
#

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

lusty crow
#

ah yeah, thx

compact bramble
#

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)

solar garden
#

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

compact bramble
#

Yeah in authoritative setups I should be able to do nearly no work on networking

solar garden
#

server has his rolling barrel and clients only get the pos and rot updated

compact bramble
#

Actually with full determinism, this data does not need updating at all

solar garden
#

ah ?

compact bramble
#

your local client simulates it with correct accuracy

#

it would need corrections at some point

lusty crow
#

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)

compact bramble
#

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)

lusty crow
#

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

jovial rapids
#

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

lusty crow
#

yep, however, I am not confident to give any estimations how long this might take

nimble grove
#

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)

graceful zephyr
#

@compact bramble using full predict/rollback for an entire FPS simulation is not.. easy either

#

as it comes with other weird caveats

indigo current
#

@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.

nimble grove
#

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

indigo current
#

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.

stiff ridge
#

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 .

compact bramble
#

@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.

graceful zephyr
#

@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

compact bramble
#

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?

void burrow
#

Anyone which has a nice article about client side prediction? πŸ˜„

indigo current
#

Most modern networking solutions provide prediction already.

void burrow
#

I'm using a bit more low level stuff πŸ˜„

indigo current
#

are you making subnautica 3? πŸ˜„

#

with networking!

void burrow
#

I'm not one of the Subnautica devs πŸ˜‚

nimble grove
#

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

indigo current
#

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

nimble grove
#

ohhh I see where I got confused I think

#

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)

indigo current
nimble grove
#

sweet!

#

thanks a lot

indigo current
#

You can skip over anything not related to loading the level

nimble grove
#

I'll probably end up watching the whole thing πŸ˜„

#

series*

indigo current
#

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

nimble grove
#

Not sure if I should be reconfiguring my "Player" setup or something

stone prism
#

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 ?

indigo current
#

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)

nimble grove
#

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)

indigo current
#

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

nimble grove
#

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

indigo current
#

you might just have to attach another photonview

#

which isnt really a big deal if ur running a small game

nimble grove
#

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

indigo current
#

worry about performance later.

#

its really easy to optimize networking down the road once u better understand it

nimble grove
#

cool πŸ‘

indigo current
#

only use RPCs for vital things though

#

like 'player died' or anything that would break the game if it didnt send

nimble grove
#

roger that

graceful zephyr
#

@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

lusty crow
#

@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

stone prism
#

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

jade glacier
#

@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.

#

I guess that leads to the question of whether PUN2 can eventually support unsigned primitives?

stiff ridge
#

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.

jade glacier
#

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

stiff ridge
#

Those are the only missing pieces?

jade glacier
#

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

stiff ridge
#

hehe

jade glacier
#

Char maybe as well? Basically once you get in there.. just add all of the C# primitive types?

stiff ridge
#

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.

jade glacier
#

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)

stiff ridge
#

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.

jade glacier
#

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. πŸ˜ƒ

void burrow
#

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)

jade glacier
#

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?

void burrow
#

With entities I also meant other players, so not really I think.

jade glacier
#

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)

void burrow
#

Don't predict would be a lot worse I feel like.

jade glacier
#

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

void burrow
#

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

jade glacier
#

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

sand lotus
#

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

jade glacier
#

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

void burrow
#

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.

jade glacier
#

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

void burrow
#

I've started with a server which pretty much only broadcasted packets πŸ˜„

jade glacier
#

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

void burrow
#

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.

jade glacier
#

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

void burrow
#

Never throw away projects.

jade glacier
#

repeat

void burrow
#

You can learn so much from them πŸ˜„

jade glacier
#

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

void burrow
#

πŸ˜›

void burrow
#

Because then the client will predict the movement wrong.

stone prism
#

it will be corrected when server sends the true position

#

it not just prediction its prediction and correction

void burrow
#

I understand, but the prediction will get lost no matter what?

stone prism
#

yes but it should not be noticable

#

it happens very rare

void burrow
#

Unless your client is lagging πŸ˜„

stone prism
#

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 πŸ˜„

weak plinth
#

hey all

#

does ReadPackedUInt32 makes the transmitted data smaller ?

#

or WritePackedUInt32

sand lotus
#

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.

weak plinth
#

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

#

πŸ˜„

#

:)))

jade glacier
#

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.

low jackal
#

Is anyone aware of how to integrate amazon gamelift client into Unity?

#

Everything I found seemed unnecessarily complicated

vernal remnant
#

believe it is unnecessarily complicated

#

at least it was for unreal

nimble grove
#

@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

indigo current
#

PM please thank you

#

@nimble grove ^

nimble grove
#

Cool

indigo current
#

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.

jade glacier
#

Lots of hot networking action in here lately.

latent warren
#

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.

sand lotus
#

Basically unity has no networking right now

#

But Assets exist. And github projects

latent warren
#

oh

sand lotus
#

How much high level are you looking for

latent warren
#

okay i will test that out

#

thank you

sand lotus
#

This might be a good start

latent warren
#

I have been using ue4's networking so i should be able to wrap my head around somethings fast

sharp willow
#

@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).

vital hawk
latent warren
#

@sharp willow thanks, i will check it out

sharp willow
#

Not so good for learning networking though

latent warren
#

i have seen pun, so is it possible to have like a dedicated server?

sharp willow
#

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.

latent warren
#

oh okay, thanks for explaining

sharp willow
#

Other fun things are Photon Quantum, which I'm using at work and is amazing for fast-paced games.

latent warren
#

i dont want to own any servers, i would like for player to launch their own dedicated servers

sharp willow
#

Then imho you shouldn't look into Photon and do your own networking setup using something like Mirror.

latent warren
#

oh ok

sharp willow
#

PUN is quite good if you don't need dedicated servers and only need p2p.

latent warren
#

i think i will look into mirror

sharp willow
#

For games below 8 players that's quite nice

latent warren
#

well my game will prob have like 30 or less players in a match

sharp willow
#

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.

latent warren
#

alright, Im used to ue4's networking where most things are handled for you lol

#

but it will be neat learning this

sharp willow
#

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.

latent warren
#

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.

undone sigil
#

better go to mirrors discord and ask for help there

latent warren
#

alright

gray pond
#

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.

latent warren
#

Yep, one of my assets had that dll and removing it fixed the errors

compact bramble
#

looking forward to dots based networking

jovial rapids
#

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

jade glacier
#

@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 πŸ˜ƒ

sharp willow
#

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.

jade glacier
#

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

sharp willow
#

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.

jade glacier
#

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

sharp willow
#

Serialization is just one small part of that. The bigger problem is synchronization.

jade glacier
#

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

karmic void
torn compass
#

Any good resource on how to handle network movement/physics, the jittery movement just wont do it for me, even with a simple Lerp emo

#

for physics i found lerping position and setting velocity works preeeeety goodokayish

sharp willow
torn compass
#

would you say its worth it as a learning resource? just checking out the code

#

because it doesnt support dr

undone sigil
#

dr?

torn compass
#

dark rift networking

sharp willow
#

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.

torn compass
#

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 emo

jade glacier
#

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.

torn compass
#

ill start with getting it all in a queue, baby steps ^^

#

right now im just lerping the oldpos to newpos received

jade glacier
#

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

tired hound
#

@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;
    }
compact bramble
#

using physx with interpolation on rigidbodies is the same concept

tired hound
#

where lerp is actually Vector3.LerpUnclamped

#

just using the Unity.mathematics library

#

and slerp is Quaternion.SlerpUnclamped too i believe

compact bramble
#

you don't have to interpolate anything unless it's rendered though if its purely for a visual step

torn compass
#

I think I dont need to update oldpos

#

its simulated on the server, so transform.position is basically oldpos at that point in time

torn compass
#

i just noticed, i wasnt even updating in update

#

when receiving a movement package

#

i just called a void SetTransform()

tired hound
#

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

torn compass
#

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

weak plinth
#

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?

gray pond
#

Which networking package are you using? @weak plinth

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

gray pond
#

wrong cert is probably the issue....there's unity forum posts about that

#

@weak plinth

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 wharf
#

@jade glacier why is unity stealing my high performance physics that has networking capability

#

lol

jade glacier
#

I'll have to watch, or do you mean the DOTS name? πŸ˜›

#

"Built with networking in mind"

#

you are optimistic there friend

jade glacier
#

@jade wharf

compact bramble
#

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)

vital hawk
#

I think emotitron mean the physics part

#

but it is built networking in mind

#

so that's not even a stretch

jade glacier
#

Unity needs way more timing callbacks for the whole lifecycle of each screen refresh for starters

#

Like a "Post Physics" callback for starters

vital hawk
#

you can easily implement that on your own

#

if you need it

jade glacier
#

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

vital hawk
jade glacier
#

Update and FixedUpdate don't cut it for physics

vital hawk
#

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

jade glacier
#

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

vital hawk
#

Unity Physics actually does have more callbacks in general

#

you can get stuff done in the middle of the physics sim parts

compact bramble
#

I see, well fixedupdate is just a function call with a perfectly working mechanism so no reason not to use ?

vital hawk
#

well, fixedupdate is trigged by code we don't have access to

jade glacier
#

FixedUpdate isn't even tied to physics. If you turn off autosimulate.. Fixed keeps going

compact bramble
#

we do

jade glacier
#

its going to be a bit antiquated

vital hawk
#

I want full access to as many parts I can, especially if it drives the physics

compact bramble
#

there is api for changing the order unity does its calls

vital hawk
#

yeah, I'm aware how fixedupdate runs right now

jade glacier
#

@vital hawk Exactly, I want a callback for everything

vital hawk
#

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

jade glacier
#

I do turn it off, and I simulate it in my updateManger's fixed... after I call OnPrePhysx and then after I call OnPostPhysx