#archived-networking

1 messages ยท Page 50 of 1

jade glacier
#

What is moving the camera itself though code wise? vs the target (which is the car)

#

ie. Does it jitter if the camera is tripoded?

manic solstice
#

The jitter also seems to happen with just non script driven parented unity camera.

jade glacier
#

then its just shit interpolation code

#

The car is non-kinematic?

#

with interpolation = true?

#

We are talking dumb clients - so I expect it to be isKinematic == true on all dumb clients

manic solstice
#

I'm going to try and get one of the devs on the project to hop on here.

jade glacier
#

when kinematic you either have to move with MovePosition() every Fixed, and enable Interpolation on the rb...

#

Or you need to store your own lerp points in Fixed, and interpolate manually in Update

#

Ping me in here if you get them

solar garden
#

I saw that in many authoritative setup you have some kind of input manager that sends inputs to the server to remotely controls players, i was wondering isn't it easier to have this input manager being a local object and control your player as you would do in local too ? Since you have to predict by already doing that why just not send positions and reconcile when its off ?

jade glacier
#

That is prediction. Prediction is applying the same inputs and simulation code locally every tick that is applied on the server.

#

The server broadcasts its state results for that tick, and the owner checks its history to see if it got the same results. If so... all is fine. If they disagree, it has to set itself to that server indicated state (along with anything else you may want to rewind and include in the resim), and then reapply the inputs again for each tick between that and current.

#

You don't send positions typically from the client, because the server doesn't care for most networking setups.

#

It is on the client with server authority to get itself back into agreement with the server.

solar garden
#

But then how do you check for wrong posisionning if you dont send the position ?

jade glacier
#

The client checks, not the server

#

The server does not care what the client thinks

#

The client is just guessing at how the future will play out on the server with the inputs it has given.

#

But if something on the server blocks you, or a weapon pushes you or your packets get lost and the server has to guess your inputs.... you will now have the wrong view of reality as the player, and you will know about it when the server gets its tick results back to you.

#

You can send your client state, but that doesn't gain you much, unless you are going to have the SERVER correct to match the client...

But that what was the point of server auth?

solar garden
#

But isnt it wrong to trust the client for correcting it self back ? How would the server know that the client did correct it self ?

jade glacier
#

No, that is what you want... there is no trust there

solar garden
#

Is it like if the client doesnt want to correct it self then he won't have the right sim ?

jade glacier
#

The client can go off into space for all the server cares.... its not going to see things that way.

#

If the server says you are at 2, 3, 3 .... that is where everyone will see you. If you choose to say you are at 200, 40000, 30000.... that is your problem

solar garden
#

Ahhhhh this is actually funny ๐Ÿ˜‚

jade glacier
#

The server doesn't correct....

#

the server is god

#

once it sims... that is it. That is the word of god.

solar garden
#

Yeah its like "go on cheat, you will randomly die" ๐Ÿ˜‚

jade glacier
#

Your player will find out its out of sync a moment later, and needs to get back into sync, or else the player will be seeing things all wrong.

#

exactly, you will just be seeing a lie as the player - that is no benefit

solar garden
#

This is pretty cool so position is only broadcasted from the server

#

You still have to

jade glacier
#

that is the typical pattern for non-deterministic games

#

Clients -> inputs -> Server -> results -> all

solar garden
#

This is not deterministic ?

jade glacier
#

Deterministic follows the pattern of only sharing inputs.

#

That is the point of determinism, the results will all agree, if everyone gets the same inputs.

#

Obviously that is much harder to do that just sharing inputs. It is very hard in fact.

solar garden
#

This would be a blast for traffic

jade glacier
#

yeah, it allows massive simulations with very little traffic

solar garden
#

Thats where the physics problems comes from

jade glacier
#

as well as how to predict and correct

solar garden
#

Different time step different CPUs

jade glacier
#

you have to constantly be guessing other players inputs, and then resim as the real values arrive.

#

time step isn't the issue, this is all fixed step

#

If the buffers start to grow or shrink too much you have ways to deal with that. The issue is that the player no longer has her own view of the world that is different from everyone elses.

#

standard networking the player usually lives in the future, and the server allows for that and favors the shooter.

#

deterministic networking you extrapolate the networked world so that you are in the present, but the present isn't known yet - so it does a lot of constant guessing and reguessing while it waits for inputs.

solar garden
#

If the physic is the same for everyone you can extrapolate ?

jade glacier
#

by definition

#

deterministic means exactly the same results for exactly the same inputs

#

The guesses are wrong for the extrapolation

solar garden
#

Hmm ok

jade glacier
#

but they aren't "real", they are cosmetic

#

so the player has a close to real as possible guess at things at all times

solar garden
#

Feels wanky

jade glacier
#

The player doesn't see 100% reality

#

Because she sees the future at all times

#

its not ideal for all game types

#

fast counterstrike FPS games are likely to never be fully determinstic, because players can be too erratic for the extrapolation

#

but for like a vehicle sim, its really good usually

#

fholm had a sample of Quantum working with an FPS, and the extrapolation rubberbanding was pretty minimal though

solar garden
#

I seen that in tf2 you can change your interp value to basically backstab peoples where they were but in the present

jade glacier
#

You are extrapolating user inputs, so they tend to extrapolate pretty well... if you were holding down the w key last tick, its a safe assumption that you still are.

solar garden
#

Is it ?

jade glacier
#

Safer to assume so than not

solar garden
#

A clif begs to differ ๐Ÿ˜‚

jade glacier
#

Anyway, I think that answers your original question

solar garden
#

Yeah thanks for all the info i was actually wrong on something i didnt even touched yet heh

#

I was just thinking of something if the client moves himself around the battefield, then he can spot other players

#

You can't just let the client unsupervised

#

Let say he is on one end of a tunnel and then teleporting on the other side he will see the other players before they do

jade glacier
#

If you don't control what it sees on the server side yeah

solar garden
#

Ohhhhh

jade glacier
#

giving players other player info that it doesn't need is always a security risk

#

Why are you worried about any of this btw?

#

Security is NOT something anyone making their first games should be thinking about, its futile at best.

solar garden
#

Thats why players dissapear when you lag in csgo

#

Im just trying to figure things out..

jade glacier
#

Could be, don't know their code base all that well

solar garden
#

I dont either just guessing but when you peak with high ping there is a chance players will dissapear for a few

jade glacier
#

That may just be that it won't extrapolate past a certain point and is making it clear to you that you are lagged out

#

yeah, familiar with how CS deals with latency and buffers

#

just not the details of how it deals with timeouts and such, that is all pretty unimportant

#

Those parts are always evolving as people tweak settings and such

#

CS was the standard for basic FPS shooters for quite a while. Bolt follows its spec pretty much exactly.

solar garden
#

How would you control what the player see ?

#

You would still impose the camera a culling over the network ?

jade glacier
#

You just don't send updates for entities to players the server feels should not be able to see them

#

based on distance, or some complex line of sight checks... whatever you feel like doing

#

But you shouldn't really even be thinking about this stuff yet. Not even Apex or Fortnite think about that stuff

#

They just have basic distance zone checks as far as I know, and that isn't anti cheat... that is just to keep packets under control

#

Focus on that logic, how to not waste data.

#

Or really, just finish something, then evaluate it.

solar garden
#

True thanks for that

patent saddle
#

never trust the client

jade glacier
#

and never trust a fart.

patent saddle
#

thank you for attending my ted talk

spice void
#

Hey so does anyone know when the newest version of unity will have built-in multiplayer support? Or otherwise what would it look like to try and make a multiplayer game in unity right now?

stray scroll
#

@spice void What do you mean with built-in multiplayer support?

spice void
#

@stray scroll as in when I go to add the multiplayer script to my project files, Visual Studio Code will understand what I am trying to do and not try to tell me that there are errors that are not really there.

stray scroll
#

Not sure what multiplayer script you're referring to? But you can check out the new multiplayer stuff exists on https://github.com/Unity-Technologies/multiplayer . (I don't get any errors when using it). But it isn't just plug n' play, you have to set it up and use some of their tools to generate scripts etc. I would image you'll have to download the package later via the Package manager.

#

If you're no fan of ECS, I would recommend go look at Mirror or Photon.

spice void
#

@stray scroll I have been recommended Mirror and Photon as well. I was just hoping to find out what version of Unity would be best for making a multiplayer game using any of these tools?

stray scroll
#

What unity version is compatible with Mirror or Photon?

jade glacier
#

2017+ for Pun2

#

2018+ for Mirror

#

Any for unet and pun1

#

I believe

#

Generally I would try to stick with LTS versions, unless you have good reason not to.

rich flame
#

Should i make a new project with UNet or switch to photon

proper olive
#

UNet is deprecated IIRC.

rich flame
#

Yeah, i guess

#

But you can still use it

#

I guess ill learn photon ๐Ÿ™‚

#

So do i wanna use PUN or photon real-time?

#

I guess pun

#

Just saw it was a plan

rich flame
#

Pun is a bit different from UNet

weak plinth
#

What do you want from your project?

#

Do you want an easy networking solution, or do you want a high-performance solution? @rich flame

jade glacier
#

You really have to define your project first

rich flame
#

Probably a P2P fairly easy system, ive already familiarised myself with unet

jade glacier
#

before deciding how it will host

rich flame
#

Probably a first person multiplayer sandbox

#

With p2p support as i have shonky internet and no real income

jade glacier
#

Competitive at all? Or super friendly coop?

rich flame
#

Coop with some moments of competition

weak plinth
#

P2P can still be client-server

rich flame
#

Yeah

jade glacier
#

Honestly you won't be able to make this choice with the limited experience you have now

rich flame
#

I know

jade glacier
#

you need to go make a demo in a few of the platforms

weak plinth
#

Many games use a client-server model where the server can be/is locally hosted as a P2P model

jade glacier
#

before even asking this question

weak plinth
#

Minecraft is one of the games that does this

rich flame
#

Ive already made a game with unet

#

But i was wondering if i should switch to pun

jade glacier
#

That doesn't matter though, I have a game I made when I started too... networking laughs at single player games

weak plinth
#

UNet is deprecated. It's never a good idea to use something that is deprecated

jade glacier
#

You have to go make some basic demo games first

#

or this conversation won't really have much meaning

rich flame
#

I guess

jade glacier
#

Have you made a PUN2 or Mirror garbage demo game?

rich flame
#

Nope

#

But i have with unet sadly

jade glacier
#

Bolt, Forge, PUN2, Mirror are the HLAPIs you mostly have to choose from - I would spend a day trying to make a tutorial in each of those

rich flame
#

Ok, thanks for the help

jade glacier
#

a day for each btw... you won't get much done - but you need to get your hands dirty in them a bit to start getting them

rich flame
#

Okie

silver heath
#

how would you display pun2 ping latency on scene canvas? figured it out

void burrow
#

Hey! I have a question. If I want to use a local p2p system (just for testing) with 1 host and multiple clients, and want to simulate physics what would be a good option? Right now I was thinking of 2 ways.

  1. Have a separate physics scene on the host client which will tick at rate X, thus disabling autoSimulation on the host client and manually calling it for scene's and then have full control over the speed at which the server ticks. (Which is probably heavier though since you now have to tick X times more every second)

  2. Have the host client calculate everything in FixedUpdate, thus having less control over the tick speed since physics still have to look good for the host client, thus update quite often. However allowing to do everything in the same scene and not having to tick more then it already does.

Any idea if these are regular approaches or just really bad ideas, or can be improved on a specific point? ๐Ÿ˜„

#

I just realize option 2 might be very bad, because you can't really hide simulating multiple inputs from users, imagine a player has send 5 input states and you are calculating that inside 1 FixedUpdate, then you'll have clients bouncing all over the place for the host ๐Ÿค”

jade glacier
#

When you start talking about a host, that isn't what I would consider P2P

#

P2P generally is a terrible term for networking anyway, because it rarely means what it sounds like

#

If you are talking about a proper host, that is a server - it just happens to be run by one of the players

#

unless you want relay, like PUN2

#

If you are talking about a host, as being an actual proper server then you generally have that server act as the final word of god for the simulation state results

void burrow
#

Then let's call it local clients connected to each other with 1 of them having the server inside the same application as the game ๐Ÿ˜„

#

Thus the server being hosted on a client

jade glacier
#

That is server client, and the server having a client. UNet called that "Host"

#

But that term isn't universally accepted, but that is another discussion

#

But you are describing Server client

void burrow
#

Multiple clients connected on a local network to a host

jade glacier
#

Just with one client having an extreme advantage ๐Ÿ™‚

#

This is for lan only?

void burrow
#

In my case for simply testing it's lan only.

#

Nothing more than that for now, just to keep it simple.

jade glacier
#

I would not test for a net architecture you don't intend to actually use

#

because making something work on lan and the internet are two different paths

#

You will make choices for LAN that will break on the internet, so if you plan to ultimately make this a net game, plan for that now.

#

It matters because on lan, you can just have the server simulate and make all clients dumb with no prediction and call it acceptable

#

On the internet you have loss, lag and jitter - so you have to implement real buffers, lag compensation, and prediction

#

If you build it "simple" without that - you are going to end up throwing out all of our work and will have to start over.

#

are you on PC or Mac?

void burrow
#

PC

jade glacier
#

get clumsy

#

to simulate the real internet on lan

#

Anyway, so to the actual question, let me reread

#

You can have your primary physics sim run on the basic fixedUpdate without turning off autosimulate, won't matter that much.

#

But if you plan to get creative with adjusting your buffer sizes on the fly, you can do the overwatch thing and have your clients tweak their sim rates to make the server happy with its buffer

#

Not sure in your question why you think that calling Simulate() yourself would result in more CPU work?

#

You are trying to simulate each player separately? Don't do that.

#

For networking you buffer everything

#

Messaging <-> Input and State Buffers <-> Simulation

#

the server holds a small buffer that collects each players inputs, and it consumes them each tick

void burrow
#

No? What I was trying to say with I assume you're talking about option 1 is the following.
The hosts runs the server sim in a different scene, when you're ticking that at let's say 30 ticks a second that will be on top of whatever the host their game is running.
Let's say the host their game runs 50 physics steps each second then on top of that their will be 30 physics steps right?

jade glacier
#

If you want to totally isolate your simulation for the server you can do that sure

#

But it would still be done normally on the same tick rate that clients sim at

void burrow
#

Depends whether or not you turn of autoSimulation for physics.

jade glacier
#

You need all of your sims to run at the same rate

#

Otherwise you break the ability to predict

#

You can send every 2nd or 3rd sim tick as a net tick

#

like you can sim at 60fps and send at 20fps

#

But the simulation (physics) ticks should all match if you want to do any prediction (you do)

#

To answer your question... there is only one sim rate... and everyone uses that

#

Anything else will lead to chaos, madness and failure

#

turning off autosimulate is useful for if you want to tweak with the fixedDeltaTime a bit to subtly tweak buffer sizes, or to resim stuff

#

But you do not want to be mixing your simulation rates

void burrow
#

So if I understand you correctly, assuming we are the host. If I want a lower tick rate for the server I'm better of just sending every 3rd sim tick (assuming we have 60 sim ticks a second) a message to clients then creating some kind of separate scene which has it own sim rate?

jade glacier
#

best to name your ticks in conversation here to avoid any murkiness

#

sim tick and net tick

#

sim tick is the rate at which the server and all clients do sim calcs... taking inputs and producing new states.

#

net tick is just the rate at which you send those.

#

if you send every 3rd, you will need to bundle the last three user inputs, because the server will need all three inputs the client applied to its prediction sim, to apply to 3 ticks of the server sim.... in order for them to agree

#

Keep in mind, lowering your net tick increases latency in a couple ways

#

For anything competitive you generally send every sim input and state result as soon as possible

#

You don't need a separate scene for simulation on the host, unless you are really going for a true Server/Client separation

void burrow
#

So basically there isn't a single 'tick', but you have a sim tick rate and a net tick rate? But are those the same for both client and server? So if the sim tick rate for the client is 60 does the server also have that rate?

jade glacier
#

It is pretty common for the host scene to just be the authority scene - but that does give the host player a MASSIVE advantage

#

I guess we should back up... are you planning to do client prediction?

void burrow
#

are you planning to do client prediction?
Yes, that was my goal to learn ๐Ÿ˜„

jade glacier
#

Then clients and servers are both simulating - at the same rate

#

the clients only simulate themselves

#

Unless you are extrapolating players, then you have to sim them all with input guesses and such

#

But since you say you are learning, I assume just basic interpolated states is what you are doing right now

#

Player presses keys... each tick the client collects those inputs... applies them locally to its own self sim.... sends those results with a tick id number to the server. It consumes that tick when it is time and simulates with it (along with inputs from other players) and server spits out a state results. Owner gets back a state result and tick id. Owner checks that state against what it got for that tick id. If owner disagrees, owner sets its state to what the server said, and reapplies inputs and resims from that tick of disagreement back to the current tick.

void burrow
#

So if I understand you correctly. The player holds let's say the W key. We apply that in fixed update, and after Unity is done with it's own sim we grab those results and send it along with the current sim tick to the server. The server puts it in some buffer, and then when the server their next sim tick occurs they send back the results with the sim tick from the client. If the client sees that the stored result on the client is different from what the server send them then the client recalculate's all inputs from the given tick to the current tick?

jade glacier
#

Generally speaking you don't send the client results to the server, but you can.

#

Server Auth = Server decides what the result was... client doesn't

#

The client is just simulating its guess of what the server will also say

#

So you get immediate feedback

#

If the server however says "nope, you bumped into this other player" - you will hear back from it with a different result than you got

#

And it is on the client to resim and get itself back into agreement

#

Basically what you were saying, but there is no point wasting data sending your state to the server

void burrow
#

So instead of the current state of the player, I only send the inputs to the server?

jade glacier
#

yup

#

client -> inputs -> server -> state results -> all

void burrow
#

But how do people store input from a client from Update -> FixedUpdate, since Update can occur more or less than FixedUpdate. ๐Ÿค”

#

And you don't want to get input inside FixedUpdate since then you're going to miss things like GetButtonDown.

#

Would a buffer work in which we keep the latest input for that?
So if I've 5 frames with input and then a FixedUpdate I keep the last result in case another FixedUpdate occurs before Update, and if Update occurs I just simply remove that last value and replace it with this one, and from that point keep buffering.

jade glacier
#

the standard unity way, you capture the inputs every Update() and hold that

#

All that matters is whatever you do, you are applying the same inputs to your client sim tick as you do to your server sim tick

#

how you collect those inputs, totally up to you.

#

How you deal with getting inputs into PhysX in FixedUpdate is the exact same concept

#

only you are storing and numbering those Fixed Updates inputs and results

#

The main benefit of manually simulating there, is you can get an actual PostSimulate() timing

#

since Unity has no PostPhysX timing, which is a pain in the ass.

void burrow
#

I've another question, if people use relay servers for their game. How on earth do they make authoritive servers, since like you said sometime ago. If you use the clients with 1 host concept you'll get massive amounts of delay. Client -> Relay -> Host -> Relay -> Client.

jade glacier
#

you don't

#

relay isn't used for competitive stuff, unless you make use of server plugins

#

You typically only use the Master in that environment for lazy stuff like marking the end of a match or something

#

You would want to give clients a lot of authority in relay environments

void burrow
#

Ah, alright.

jade glacier
#

That being said, it can be done. I have my demo scene I test for my asset connecting over a mobile hotspot here in Mexico, to a relay in Europe and back twice.

void burrow
#

But with a lot of latency?

jade glacier
#

fair amount yeah

void burrow
#

But let's say you're using relay servers. How would you go about for example picking up items, or in general authority? What if 2 clients do it at the same time and send each other packets that they picked it up.

jade glacier
#

You have can either make it wait a split second for confirmation, or you predict and then undo the action if it fails

#

That is mexico wifi to EU relay servers... so the health bars on that target are two trips to europe and back

void burrow
#

I really hate that a part of clients just can't connect to each other. Makes it so much more complicated :c

jade glacier
#

They can with NAT punch if you want to deal with that

#

But clients cross connecting is its own set of headaches

#

fine for two players, but you generally always want all to one

void burrow
#

Still NAT punch isn't a guarantee that it will work.

jade glacier
#

Relay is still a server client, its just a dumb server

void burrow
#

Btw, you said earlier on that if using LAN you don't need client side prediction. But clients can still lag on LAN, like a laptop connected to wifi right?

jade glacier
#

lag yeah, but you won't be dealing with a lot of jitter and such - depends what you consider acceptable

#

The main thing is to not spend a month writing code and testing it on Lan, and THEN finding out how it really runs on the internet.

void burrow
#

Thanks a lot for answering my questions btw! Really appreciated ๐Ÿ˜„

jade glacier
#

np

maiden sundial
#

Hello ive made a very simple script that works as a flashlight. The problem is when one player turns her flashlight on/off the other player can't see it

Iam using photon 2, i guess my problem is that i don't know how to send it to ther server rather than it only being client-sided

maiden sundial
#

Iam really new to this. I tried following a guide, and read some documentation but i can't really understand this. Iam trying to syncronise whenever a player toggle her flashlight across the server so other people can see it.

stray scroll
#

@maiden sundial Post the whole script

void burrow
#

Question, if I want a player movement system with client side prediction and thus the server being authoritative. Would the only way for this being having a deterministic system for this. So sending the inputs from the client to the server and trying to get the exact same result on both the machine's?

jade wharf
#

Calculate for client send to server

#

Server then sends you to a position, which may or may not be exactly where you already calculated

#

If it is, then you dont teleport to that position, but instead continue

#

If there is a disagreement, server always wins and you snap to that position

void burrow
#

I understand, but the way of telling the server where the client predicts it's going to is what I'm trying to figure out.
Right now the only way I can see this work kind of reliable is by sending input to the server as @jade glacier said before. However this will require determinism in the whole movement system, and I'm looking if there are any other options before I just straight up dive into this one ๐Ÿ˜„

jade glacier
#

If you are going to try to bake some forgiveness into the server, you can do that.

#

its not unheard of for clients to send their states, and have the server make a ballpark check of if those states aren't too unrealistic, and if so accept them @void burrow

jade glacier
#

I typically bake quantization into my owners results. By that I mean I compress states before sending in a way that is lossy... and I will decompress those on the owner and correct the state results to match that. That ensures that the server and the owner are more deterministically in agreement.

burnt axle
#

How do you referance an gameobject from the server? Normaly i would just use the gameobject, but since its a networked gameobject, does it need the netid or a network id of some sort?

jade glacier
#

Unet?

#

For Unet/Mirror I think the Commands and RPCs automatically know to use the netid.

#

You can pass the GameObject as a parameter as far as I know, but yeah - you would if rolling your own grab the NetworkIdentity.netId

burnt axle
#

Unet yes, so i can just pass the local gameobject as a referance? thats pretty nice

#

since commands are called on the player object that is the host, can you call methods on that player object too?

jade glacier
#

you mean RPCs?

#

the RPCs and Commands turn it back into a gameobject reference on the other end

#

behind the scenes commands/rpcs get the netId of the gameobject, and send that as packedbytes - and on the other end look up the scene GameObject with that netid.

#

I believe at least. I never touch Commands/RPCs but that is what I recall.

burnt axle
#

I mean calling specific methods on the host gameobject from a remote client (not host). I could probabl make an method that does it, but im just wondering if Unity got something already built in. Yeah i would would guess thats how it works too.

jade glacier
#

You will have to be more specific in what you mean by calling methods

#

because that is yes or no, depending if you are talking about commands and rpcs or not

burnt axle
#

say host gameobject has a script with a method called "logme", how do i call this from an remote client that is not a host?

jade glacier
#

By using Commands and RPCs

#

Have you done any unet tutorials?

burnt axle
#

yeah ive read the docs a little and watched 2h videos about it a while ago

jade glacier
#

You should do some tutorials. You need to be familair with the usage of Syncvars, Command and RPCs in order to use the HLAPI

burnt axle
#

yeah ill do that

jade wharf
#

I mean, for fps, basic movement can be made deterministic so easily its laughable

#

You should see the simple calculations that something like csgo makes for movement

#

And people have gone so far to become โ€œmovement expertsโ€ in that game

gray pond
exotic valve
#

when in the Unity editor, do the first person arms show with local client? I'm having a bit of an issue with it, and I'd just like for it to look like a normal proxy player

#

Does anybody have a resolution for something like this?

jade glacier
#

That sounds like a very specific question to your own code, so nearly impossible to say @exotic valve

weak plinth
#

Am I the only one having issues with PUN not finding matches recently?

jade glacier
#

the editor often connects to a different region

#

while deving, hard code a region into your pun settings... like region us or eu @weak plinth

weak plinth
#

Ah that did the trick. Thanks ๐Ÿ™‚

jade glacier
#

np

weak plinth
#

Ugh - this network interpolation is killing me...

#

Has someone managed to get the famous source interpolation to work using PUN?

jade glacier
#

For starters, CS style networking is very reliant on server auth and player inputs.... so not sure how you are going about that with PUN

#

https://assetstore.unity.com/packages/tools/network/simple-network-sync-134256 For this, it replicates the transform from the authority to others on a regular tick, which is a subdivision of the fixedUpdate... so it samples and sends on a fixed timing, and all clients consume those from their buffer on that same fixed timing.... that gives you a meaningful lerp value for your interpolation.

weak plinth
#

Interesting. RPC's aren't managed by this?

jade glacier
#

that gamieon script seems to be relying on OnPhotonSerializeView or whatever its called, and that is definitely not a fixed based timing.

#

So you are generating your state updates at a totally arbitrary interval, which means trying to interpolate them correctly is nearly impossible, unless you serialize in a time stamp, and pull from the buffer at the same rate the owner sampled it....

Which do DO NOT recomend

#

that is baking in all kinds of frame dependencies and insanity

#

I deal with it (and am talking with Tobi about incorporating it into PUN2 itself) by adding a networking update manager singleton, and all of my networking fires based on its timings. This makes it behave in a more Bolt-like way than the adhoc messaging that happens by default.

weak plinth
#

So this.. fix... might end up in the PUN2 package?

jade glacier
#

Its not really a fix, its just a whole alternate to the PhotonSerializeView way of doing things. I have a whole set of components that are drag and drop that use it, so they all defer their timings and such based around that master timing singleton. Not everyone would want to get their heads around that complexity of that, and may be fine with just the adhoc messages.

#

But they do cause serious problems with things like micro-jitter and any kind of determinism or keeping things generally in sync and in agreement.

#

All of the HLAPI suffer from this

#

UNet, Forge, Mirror also have no built in handling for fixed tick or simulation based timings.

weak plinth
#

So the 13.4โ‚ฌ i almost threw at this asset can be for naught if it is integrated into PUN ๐Ÿ™‚

#

even though you would benefit from it

jade glacier
#

And they all suffer on this front for it

#

I have no idea on the timeframe for if/when it will become part of PUN2

weak plinth
#

Well 13โ‚ฌ is most likely worth it anyway. I'm gonna try it out

jade glacier
#

The main thing in your case is to dig around what is going on with the NetMaster and the NetObjects as far as the interface callbacks

#

Its all about breaking down the fixed steps into a bunch of deferred timings, so things are very molecular in the order in which they occur each tick

#

The main takeaway, is that it ALL happens on a fixed tick... Update() is ONLY for interpolation between those states, and is entirely cosmetic.

#

All of the action happens around the FixedUpdate/Simulation

weak plinth
#

So i threw the SimpleSyncTransform to my character prefab and the interpolation seems to be working way better, but there are some serious jerkiness.

jade glacier
#

That likely is some kind of controller conflict?

#

how are you moving your object?

weak plinth
#

I'm trying to integrate this into the MoreMountains TopDown / CorgiEngine

#

So I rely on their input

jade glacier
#

Be sure to find all places that controller does anything and only have it happen if IsMine

#

Usually what you are describing is a controller not designed for networking not knowing it should be hands off on dumb clients

#

IF they don't advertise their product as being Photon friendly, then they haven't done any of that work for you

weak plinth
#

It's the network character that is "almost" rubberbanding

#

I might have some old interpolation code left somewhere

#

so the Observed Component of PhotonView is supposed to be empty right?

jade glacier
#

yeah, may want to start from scratch if you are pretty deep in making a bunch of test code

#

it should just consist of... move the object on the authority... let the synctransform replicate that out. and that is it.

#

The only issue being if that controller code doesn't know to be hands off if its not the authority

weak plinth
#

Nope, the network entity is still twitching aound

jade glacier
#

have you modified their controller code?

#

to not do what it wants to do if not the authority?

#

An easy test just to see if things are working, is remove that controller entirely... build out the project... and move the object in the editor by hand dragging it around the scene

weak plinth
#

Ah will do

jade glacier
#

That should replicate very smoothly on the build client

#

unless your internet connection to PUN is just awful, but that isnt likely the case

#

Other test is just open up the PUN example and see how smooth that is

weak plinth
#

There seems to be some fluctuation in my ping at the moment

#

but will try the Demo_Scene

jade glacier
#

The sample scene uses my own controller so if that is jerky, you are dealing with some really nasty internet noise.

#

if its smooth, then its just that controller you are trying to use misbehaving most likely.

#

keep in mind too, that the editor is notoriously crap, run two builds to see a more realistic view of things

weak plinth
#

I think my issues were related to the Sen Every X in NetMaster

#

I forgot to add that singleton so it spawned and sent every 1 instead of 3 in the demo

jade glacier
#

needed to send more or less often?

#

its default is every tick, which can be a bit much for photon relays if you have a high tick rate

weak plinth
#

I increased to 3 and it seems better, atleast when moving the characters manually within the editor

jade glacier
#

the lower your net rate though, the more induced latency you will introduce, so its a balance with networking

weak plinth
#

is that related to the PhotonNetwork.SendRate and SerialiationRate? Should I touch those?

jade glacier
#

nope, this totally circumvents all of that

#

Where are you connecting from and over what?

weak plinth
#

24/1 ADSL from sweden to amsterdam

jade glacier
#

DSL can be barfy here in the US, not sure about there

weak plinth
#

I do have some issues as my ping to google jumps from 35ms to 150

jade glacier
#

Was the demo scene smooth?

weak plinth
#

but increasing the send every X from 1 to 3 helped alot

jade glacier
#

sounds like you were just pushing too high a tick rate there yeah

#

if you run default physics timing, that is 50 ticks a second

#

does a send every 2 work?

#

that makes for a 25 per second (depending on your settings).. which is in a reasonable range for a net rate

#

The big thing with networking is to try to do everything on the fixed, or on a fixed timing of your own.

#

the problem with trying to network things (like 3rd party controllers) that aren't designed for networking is they just do everything in Update, and have no concept of simulation

#

and that is hellish to network

weak plinth
#

there is some jerkiness with 2

#

three and up seems to be the sweetspot

jade glacier
#

Interesting, I would expect you to be able to get a higher tick rate with your proximity

#

But your connect be what it be

#

You can also change the physics rate, since fixed is tied to that

#

Does my example scene also start to have issues when you change it to every 2 ?

weak plinth
#

Indeed it does

jade glacier
#

that sounds like the upper limit of a viable net rate then for your connect to the servers

#

So that out of the way, is the interpolating looking good now?

weak plinth
#

Yeps ๐Ÿ™‚

jade glacier
#

So hopefully the code if you poke around it will make sense

#

you can use the plugin as is of course, but sounded like you more wanted to know how to do this stuff

#

so you can poke around my code to see how I went about it

weak plinth
#

It''s Time.fixedDeltaTime thats tied to the physics (and net) simulation?

jade glacier
#

yeah

#

its unity's built in fixed timing that most everything uses

#

you can make your own, but this is an asset, so I had to use that to ensure it plays nice with PhysX

#

Generally, best to not fight Unity in how it wants to do things

weak plinth
#

My fixed timestep is (default?) 0.02 or 50 ticks per second

jade glacier
#

yeah, that is default

#

Gotta run to breakfast, so will be afk on and off here

weak plinth
#

Righto - will poke you should I run into more issues ๐Ÿ™‚

void burrow
#

Hi! Anyone knows if there are any limitations to using Steam their relay servers? (Except the obvious that you are bound to their service) ๐Ÿ˜„
For example pricing, if there is any? Because I couldn't find anything about it ๐Ÿ˜ฆ

jade glacier
#

@weak plinth btw, there are some hidden constants in NetObjectLite.cs that you can futz with. I future versions I have exposed them in a ScriptableObject settings - but for the first release I locked it at a pretty typical setting.

#
public const int TARG_BUFF_CNT = 2;
public const int MAX_BUFF_CNT = 3;
public const int TICKS_BEFORE_SHRINK_BUFFER = 8;
public const int TICKS_BEFORE_GROW_BUFFER = 4;```

At really high tick rates, you may want to push up those buffer resize trigger values
weak plinth
#

@jade glacier Good to know ๐Ÿ™‚

fading apex
#

hey i am making a top-down tank game unsing unet
and i have just inplemented shooting but it is extremely laggy and synced very badly. I have tried adjusting almost every value of the network transform component. I can get rid of some of the jagged motion with interpolation but I can not fix the problem that the bullet just shoots out "too late" while moving. btw server on the left client on the right.

can anybody help me ? please
PS: its my first multiplayer attempt

fading apex
#

i have seen this idea online. i can see how it would work but i do not know how to realize it in code

jade glacier
#

If you are trying to make your projectiles into networked objects that's going to hurt @fading apex

#

Projectiles and hitscans are usually treated as events, not as objects. Since they are in most cases completely deterministic.

weak plinth
#

So how would one do that in a peer-to-peer model? I'm trying RPC's now but it does not seem to work

#

.. well it DOES work but not synchronized

jade glacier
#

you mean shooting?

#

If you send your transform info at the same time as you send the fire event, and apply them at the same time on clients, then it will appear to originate from the player at the right time relative to that player moving.

#

in a relay based setup (what I assume you are calling p2p) you typically will be going full owner authority on both position and firing things like weapons

weak plinth
#

So I need to synchronize transform syncs and RPC's?

jade glacier
#

Not sure what you have going on, but you need to have a way to replicate things

#

either by sending user inputs, or by sending the states involved

#

If you are using SNS, you can piggy back stuff on the buffer[], but that will take some digging around to sort out how to create your own SyncObj

#

But its designed for all of this, its what I use the system for

#

Anim and Transforms get synced on the tick, so you would capture weapon fire on those same ticks.

#

Its a shame this stuff I am making right now isn't out, because it does all of that for you

weak plinth
#

So everything worked normally until today. My project is based on Photon PUN, when i do a build, and open 10of those builds, i have 10 players on my server, +1 if i start play mode in editor, player normally joins, or i could host with editor, but today all of the sudden my builds can't see my editor and editor play mode can't see my builds. I even tested my backup versions from 15 days ago, 10days etc.. They don't see play mode anymore. It is like editor is no longer conected to anything even if i just did build from that same editor.

jade glacier
#

Set your settings to a region

#

The editor with PUN regularly connects to a randomly different region.

#

just type in eu or us or whatever is near you

#

@weak plinth

weak plinth
#

@jade glacier Fixed. Thank you. Idk why settings changed on its own, it was set up like that before.

jade glacier
#

np

fading apex
#

thx @jade glacier
that was extremely easy do
i kind of understand what I did but it works great ๐Ÿ˜„ thanks a lot

fading apex
#

I fixed the first problem now with the bullets
but now the barrel of my tank has a crap ton of laag and changing the values helps a bit, but not nearly enought.
it laags behind so mach that the bullet spawns in a completele different place

is there a smarter way to do the rotation of the barrel (it follows the mouse cursor btw)

stray scroll
#

Where can I find like examples of backend architecture for games, like lets say generic FPS.
My current questions;
Do they usually only one database for users, items, etc, or split them up?
What different separations do they do(login, heartbeat, database etc)? And what are usually on the same machine?

stray scroll
jade wharf
#

Player information should be separate from user information if you ask me

#

What i mean by that is do not store personal info in the same database as game info

#

Imagine if someone found an exploit and got into your game database, welp, thats a lot of user information breached

#

But if you tun a localhost ONLY database server that stores user information, then the only way a breach could occur is if there was an exploit in the server machine itself

gilded summit
#

I just came here to say I do not enjoy MLAPI at all

#

Friendship with MLAPI has ended Mirror is new best friend

stone oar
#

Another way is to just not store User information at all, but let a third party deal with that, like Steam, Epic, etc. That you only associate, say, a steam id with a user, and nothing more.

#

With the rules around sensitive user data today, that's the safest bet

#

You can then get an access token from steam on the game client that you send to your backend, and can use it on the backend as a safe access to your user's game data as well (using Steamworks API on backend).

#

The downside is that you need to support one auth pipeline for every platform you want to release on.

patent saddle
#

If you can, don't store user information. It's really easy to get it wrong, and one data breach and you're done for.

stray scroll
#

@jade wharf The interface is through php sanitizing inputs. And server code is not shared with clients. So users on DB will be localhost, if that's what you meant? Userinformation will be username, email, hash. You still think I need to put this on separate DB?

#

@stone oar Would do that, but don't want to bind the project to any third party store like Steam, Epic etc.

stone oar
#

Can also just bind a service like Google, and use them for the auth service on backend.

#

and not really store any sensitive information. The most sensitive thing is passwords and emails in combination, as a lot of users don't use unique passwords, but reuse the same ones all over the place.

#

I'd just treat it like any "backend" problem in programming. There's so much integrated these days for both ASP.NET and node.js/javascript world that its relatively easy to give the user the option to authenticate with their preferred service, whether its google, facebook, github, twitter, whatever

#

as long as you don't store passwords, you've passed most of the fuck-ups you can do with a user's data.

weak plinth
#

you've passed most of the fuck-ups you can do with a user's data.
Lmao, no

#

A user can request to have all of their data removed from your system at any point in time, by EU law

#

Just one example

jade wharf
#

@stray scroll if it is as strict as possible you might be fine

#

you never really know when someone is so dedicated, to steal

weak plinth
#

@jade wharf It's really trivial with todays framework to secure a DB

#

There's no reason that somehow your game-info database would leak information sooner than the user data

#

A database should never have direct access to the internet in the first place

vital hawk
jade wharf
#

@weak plinth thats what im sayin

#

but you would be surprised how many database source code i see binds it to 127.0.0.1 instead of localhost

weak plinth
#

Eh

#

What

#

localhost

#

Is literally

#

127.0.0.1

#

@jade wharf

jade wharf
#

127.0.0.1 listens on all interfaces

#

localhost does not

undone sigil
#

uhh, no?

#

localhost == 127.0.0.1

jade wharf
#

hence, if a port is open on the router, and a computer binded to 127.0.0.1 and at that port. it will recieve it

#

am i mistaking a another predefined?

#

hold on

#

yea im right

undone sigil
#

no

jade wharf
#

127.0.0.1 allows all interfaces

undone sigil
#

no

#

0.0.0.0 does

jade wharf
#

weird. the source is wrong i guess

#

which also means im mistaking for another predefined :d

weak plinth
#

Anyway...

#

You should bind your DB to a specific port

#

Not just... everything

jade wharf
#

im not sure if binding to multiple ports at once is a thing

#

i havent seen it if so

#

would be kinda weird

#

sending to ip:3000

#

and ip:3001

#

and have it go the same place

weak plinth
#

Why is that weird

jade wharf
#

seems redundant

weak plinth
#

No?

#

Different ports do different things

jade wharf
#

exposing more holes for no reason

weak plinth
#

That's not how any of that works

jade wharf
#

you missed the part where i said for the same thing

weak plinth
#

A webserver has multiple ports bound

jade wharf
#

a webserver is different because it uses multiple protocols

#

http https

#

80 vs 443

weak plinth
#

A protocol is not explicit to a port

jade wharf
#

isnt it explicit for webservers?

weak plinth
#

No. But your browser will use 80 for http by default

jade wharf
#

right

weak plinth
#

But you can run http over any of the 65k ports

jade wharf
#

but why would you is what i am asking

weak plinth
#

Ehm

#

The only reason you don't have to type :80

#

Is because your browser does that by default

jade wharf
#

i know

#

lmfao

#

are you not listening

weak plinth
#

I think you misunderstand a lot of things about networking

jade wharf
#

who in their right mind wouldnt make their webserver use 80 443

#

whatever you think my dude

#

i clearly have no idea after writing an entire physics engine with deterministic networking

weak plinth
#

Based on your comments in the last 30 minutes, I'll hold my heart about the quality of that, in terms of network at least

jade wharf
#

fucking kek

weak plinth
#

Or you used an existing network layer

jade wharf
#

i make one mistake of 127.0.0.1 vs 0.0.0.0 and you want to question all my experience

#

xD

weak plinth
#

Binding more ports is redundant and exposing more holes than needed

#

Apparently

jade wharf
#

binding more ports to the same service is redundant

#

and exposing more holes than needed

weak plinth
#

And yet, it's a thing that happens

jade wharf
#

http is one service

#

https is another

weak plinth
#

http isn't a service

#

It's a protocol

jade wharf
#

yikes dude

weak plinth
#

So is https

jade wharf
#

tcp is a protocol

#

http and https use tcp

weak plinth
#

And they are protocols as well.

jade wharf
#

at most i would call it a transport layer

weak plinth
#

UDP and TCP is transport layer

jade wharf
#

ok. lol.

weak plinth
#

It's not only your localhost that you are mistaken on

jade wharf
#

you arent understanding what i am trying to say

weak plinth
#

It doesn't matter. You are wrong

jade wharf
#

sure thing friend ;V

weak plinth
#

I mean, this information isn't exactly hidden

jade wharf
#

ok, maybe this is the best way i can say it.

TCP, being used as the back protocol that runs HTTP/HTTPS, which is advised to be binded to the ports 80 and 443, yes its not required, but YOU SHOULD bind them to those. is yes being used as a protocol. but it is SERVICING you the website

#

is that a good enough explanation of what i am trying to say

weak plinth
#

You should not bind them to those. Only if you are running a web server

#

You can use http/https for far more than just websites

jade wharf
#

why would you be using http/https for anything but a website

#

sounds like a lot of extra data size

weak plinth
#

Because the protocol is convenient

jade wharf
#

sure, fine use it for anything other than a webserver

#

i just wouldnt

#

jeez that was such a massive argument over something so trivial

weak plinth
#

Not really. You should be less dogmatic in these things

#

http is a protocol. Nothing more. It shouldn't be on any port

jade wharf
#

then it just comes down to a developer disagreement

#

i wouldnt use http for anything but a webserver

#

and that is just a choice

weak plinth
#

It's a very reasonable source for a rest endpoint

#

Which doesn't have to be a webserver

orchid nest
#

so i was making an fps then someone told me making it multiplayer was hard does anyone have an up to date tutorial on how to do this that doesn't use unet i was following along with this but its out of date from what i read in the comments https://www.youtube.com/watch?v=-m28axeuRNs

We start adding multiplayer functionality by setting up a NetworkManager and spawning the player on the network. โ— Download cool Weapons: http://devassets.co...

โ–ถ Play video
delicate ermine
#

ooof, old UNET is being deprecated afaik, and new DOTS based UNET is not there yet

orchid nest
#

so what should i do in the meantime just work on mechanics and backbone of the game and implement multiplayer capabilities later? would i basically have to rewrite everything when it is released?

delicate ermine
#

Yeah, that wouldn't be a good idea

#

I guess you could still use the old UNET if the project isn't too big

orchid nest
#

well each instance is only going to have 32 connected players at a max 16 players and 16 spectators

delicate ermine
#

that's pretty big ๐Ÿ˜„

orchid nest
#

sooo unet is def not what i want to look to do for now

delicate ermine
#

Well, old UNET is still here

#

Personally I'd use some third party stuff

#

I wrote some barebones networking stuff with DarkRift2, it was fun

#

buuuut it's a low-level API, so it takes time and effort to develop stuff

orchid nest
#

im looking into pun and photon right now. i barely know coding so writing network coding from scratch would be to much for me

delicate ermine
#

Yeah, maybe Photon is better then

#

Although I don't know if it's free

#

Anyway, for prototyping, UNET HLAPI would be good enough

orchid nest
#

alrighty thanks

jade glacier
#

If you do your game right, you should be pretty abstracted from the messaging layers

#

Focus while getting started on actually producing a game sim that works on a fixed tick, and consumes inputs before simulation, and stores states as a result of the simulation.

#

Most of what the networking libs should be doing is just sharing those inputs and states.

delicate ermine
#

B-but writing your own messages is fun! ๐Ÿ˜„

orchid nest
#

@jade glacier thanks for the input ๐Ÿ˜„

weak plinth
#

So, the thing is

#

There are multiple API's available, from low to high level

#

The higher level, the "easier" it is go get your project up and running

#

But at the cost of control and performance

#

@orchid nest

#

And the additional thing about FPS games is, they are extremely-real time

#

You can't have delays or inprecise handling of user inputs

#

This is one of the mechanisms they use

#

But honestly, FPS games are crazy business. They still go "wrong" for even big developers

#

It's really difficult to find a balance between fair and precise

#

You can just say f* it and manage it out of the box, but the greater the RTT becomes between clients, the more noticable it becomes

orchid nest
#

okay so i wanna try and emulate something that seems fair precise doesn't seem fun and its all about a happy medium my biggest issue is invalids. if you've ever played rust you get the hitmarker but no damage is dealt no fun lol

weak plinth
#

Yeah, but other problems arise at that point

#

So suppose you shoot someone just before they go around a corner

#

On your acreen you hit the player, so you expect damage, right?

#

But by the time the data is processed, on their screen they are already around the corner

#

So now what?

#

Are you allowing person A to shoot through walls essentially, or person A to not to damage at all?

#

Many Halo games also had and still have issues with this

#

Where you either not to damage just as someone goes around the corner, or you get shot through the wall from your point of view

robust yacht
#

Hey I have a problem can anyone help

weak plinth
#

Ask

robust yacht
#

So how do I make my game into a online game

#

How do I make it online

stray scroll
#

@robust yacht But to be honest, I think you need to expand your question a bit more, or do some research on your own at first. The most low level way to answer your current question would be to say ; "By transferring data between your users.". Then there are different ways to deal with it depending on your game. Client-server FPS, where server decided what is happening, ie. has authority, would generally take inputs from all clients, and send the world state from these inputs to the clients.

jade glacier
#

Step one: Do tutorials for a a few of the libraries so you start even thinking about networking

#

yeah
var handle = GCHandle.Alloc(packable, GCHandleType.Pinned);ends IL2CPP

jade wharf
#

if you make the computation deterministic you only have to send the inputs instead of the state

#

:v

#

for FPS you typically only need gravity, walls, and floors

#

pretty easy physics

#

even for 3d

weak plinth
#

Hi everyone! I am researching for a solution to my multiplayer mobile game. I was wondering what is your input, based on your experience, to my requirements.
The game I am developing is intended to use on Mobile, and is much like "Brawl Stars" game.
I wish to have an authoritative server of course, including matchmaking based on a logic I invent, and profile db savings (characters, skins, in-game currency, etc).
What solution would you guys recommend me among the current supported existing solutions?

#

Please @mention me so I can see the message

mellow beacon
#

The upcoming unity dots networking/multiplayer packages are very interesting @weak plinth

dapper tusk
#

anyone knows how do I build out server and client in new unity dots netcode?

stray scroll
#

@dapper tusk what do you mean build out?

dapper tusk
#

Basically I have the new networking running, but I want to have or atleast test on two devices, how can I made a client build and server build

#

because right now I can only test in editor using PlayMode Tools

stray scroll
#

Hmm, I think if there isn't an option yet at top to build. I would use the Defines for client/server then build player. But if I remember it got me compile error last time I tried, not sure if they fixed it : )

dapper tusk
#

No there is not any option there, I will try that later and see where it will take me ๐Ÿ˜„ thanks

weak plinth
#

@mellow beacon Thanks for your reply! But, when is it released?

#

All I could find is the old deprecated documentation.

#

Is the new network released? Can we use it and develop for production?

mellow beacon
#

The preview packages ship with 2019.3

weak plinth
#

Can you link me to any tutorial @mellow beacon ?

mellow beacon
robust yacht
#

Does anyone know how to make a in game kinda fortnite lobby

#

A pre game lobby

#

A pre game lobby

barren pebble
#

What is considered "best practice" when communcating stuff from the client owner object to the server, for dedicated + client-host, code wise.

for example

Client A calls a Method that should be executed on the server, for example DoSmth();

DoSmth(); gets executed on the server and calls the same on all other clients, replicating the stuff to the clients (for example, changing the name of the player)

So, Client A calls ChangeName("myNewName");

Server sets the new name for this object on the server side, and uses RpcChangeName("myNewName"); to change the name of that object on all connected clients

If the server is a dedicated server, it executes it on the server, and on all clients once, fine
If client A is also hosting, it invokes ChangeName(..) on the server side + once again via RPC on the client side

To "fix" this, would i just check for that case and then exclude Client A from the RPC call to the clients, or check inside that "ChangeName(..)" method if its client and server, so, basically hosting + self playing (not dedicated server) and just dont do it then.
but then i have some more boiler code
Is this the "unity way" of working with some higher level apis for networking?

#

If anyone has an opinion or suggestion, pls ping me so i see it tomorrow

amber trench
#

@barren pebble i would run through the Mirror tutorials to get a better handle on what to do

#

@robust yacht in game lobbies are pretty complicated, you kind of need to tackle matchmaking first, maybe start with something like Google Play's game services to see the scope of the problem

#

@weak plinth brawl stars is pretty complicated, but i think you should try to prototype using Mirror

#

@weak plinth @orchid nest unity isn't a very good platform for FPS games, you may have better luck modding a commercial game

weak plinth
#

What are you even talking about? So you are suggesting it is better to mod an existing game than even attempting to make an FPS yourself?

gleaming prawn
#

That was strange...:)

#

And FPS is such a vast genre (with different netcode strategies suiting better depending on the game: competitive low-player-count fast shooter vs battle royale vs survival games).

weak plinth
#

The guy he was responding to (Dot) wants to make something similar to Halo

#

And in that case, networking is pretty hairy

#

But ya know. Someone is saying Unity isn't good for FPS, and in the same comment is recommending Mirror to people

gleaming prawn
#

Yeah, netcode is NOT easy at all (there's no silver bullet, there's no perfect formula), but I assume this channel is for both beginners and experienced people alike (so I expect more experienced people to be able to recognize the kind of questions and write real useful comments).

#

Even if the question shows that the person asking might be underestimating the effort needed, we have a choice between three options:

  • Rant
  • Give simple, but not exactly good advice;
  • politely help that person ask better questions;
#

If we are here to help, there two valid options...:)

weak plinth
#

Anyone know if mirror networking will work with ECS?

#

It doesn't

#

yeah didn't think so...

#

You might need your own low level network stack for that

#

No idea if there are pre-made sollutions available at this moment

#

oh well, worth a shot lol

#

@jade glacier Knows a lot about pre-made sollutions

stray scroll
weak plinth
#

It uses Unity.Transport though

#

I heard that isn't all too good

barren pebble
#

Does anyone use MLAPI ?

mellow beacon
#

๐Ÿคฆ

stray scroll
#

@weak plinth For what reason should com.unity.transport be bad?

weak plinth
#

I would tell you if I knew exactly why. I just heard people say it's bad.

#

Don't know if it's true or not

amber trench
#

i try to recommend stuff that people actually use, to some extent, or at least has support from a community, for people who will get as far as a single process == a single game

#

@barren pebble it depends on what your objectives are

#

@weak plinth yeah, i think if your goal is to make a networked FPS, for example, or something like rocket league, which between those two features i've described all the top steam games except dota 2, civilization and football manager, unity, DOTS included, even 3 years from now when it is more mature, it's going to be an ill-fit for that kind of game

#

most shipping FPSes have some legacy to them, using prior commercial FPS engines, it's not at all unusual...

#

for the purpose of intellectual stimulation, yes, implementing an FPS in unity is doable, it just starts to look like DOTS to a certain extent

#

it's just an audience of, well i start a unity server process on a windows machine, and other windows clients connect to it... there aren't any networked multiplayer games that work like that anymore, except maybe paradox and civilization

#

so even for the purpose of intellectual stimulation, to learn something appropriate, it's very challenging to conform unity to modern practices

#

if you're making a turn based game, i personally think you're going to get more mileage using a web technology for your backend, i.e., use a unity client and interact with the hosted games via HTTP websockets, executing the game logic in a stateful web server

weak plinth
#

Yeah, just no to everything

#

According to this, there's either rocket league or turn based games

#

You do understand that you can perfectly make smaller-scale fps games right?
It's prefectly do-able to create an fps in unity that can host 16 players pvp, as the total traffic and cpu will be next to nothing with only 16 entities

#

And http is pretty terrible for games. Talk about eating bandwidth for no good reason at all.

#

At least suggest tcp over something like http rest for a damn game...

#

It's absolutely absurd to suggest someone isn't able to make something like rocket league, where mind you, you have something like 4-6 entities + a ball in unity

#

A server that hosts one of those games can run on a rpi

#

You are not going to require top-of-the-line performance unless you are synching many many entities, such as a large scale multiplayer game or a service that hosts many clusters of games

waxen spade
#

Rust can run 100 players fine with their setup. Sure itโ€™s probably very customized...

amber trench
#

yeah i think your'e right too @weak plinth ๐Ÿ™‚ there are lots of good choices fortunately

weak plinth
#

The more performant and real time you go, the more you want to stay away from any ML or HLAPI's

gleaming prawn
#

"it's just an audience of, well i start a unity server process on a windows machine, and other windows clients connect to it... there aren't any networked multiplayer games that work like that anymore, except maybe paradox and civilization"
Fortnite, PUBG, and so on basically every game made with UE4?
Yeah, you can build the headless server to run on linux machines, but same can be done with unity AFAIK.

#

@amber trench

weak plinth
#

There's 2 types of servers. In-engine, or without

gleaming prawn
#

I'm not saying this particular architecture (traditional clients---single-server, either using state transfer or snapshot interpolation) is a silver bullet...

#

But it's a valid approach.

weak plinth
#

And the latter is pretty rare

gleaming prawn
#

I don't have any survey to answer that @weak plinth

#

In-engine servers are vey common, yes, because of source engine, UE4, etc

#

and all the modding community over classical FPS

#

But if you think about basically every MMO, destiny, etc, these are not in-engine servers

weak plinth
#

You don't need any survey. If you don't use an in-engine server you need to simulate all the constraints for running the game somehow

gleaming prawn
#

Yes, I know that.

weak plinth
#

How do you know MMO games are not in-engine

#

Of all the MMO's out there

gleaming prawn
#

I don't know all of them of course.

#

But have some inside info on some of them (NDA prevents me from saying much)

weak plinth
#

I'm extremely doubtful

#

Without engine, you will have trouble with basic things like collision detection or pathfinding of AI

gleaming prawn
#

Well... Define engine..::)

#

In that you are right...

#

Makes 100% sense to share/reuse codebase between what runs on server and what runs on clients.

weak plinth
#

I'm extremely sure that, even very custom sollutions run at least a physics engine on-server.

#

And that's also probably all you need

gleaming prawn
#

But an "engine" to run an MMO is extremely complex, and it's not as simple as a "headless" server you build from a simgle C++ project like UE4, etc.

weak plinth
#

You can circumvent all of this, and make some really crappy solution where you let clients to the phyhics bits

gleaming prawn
#

"least a physics engine on-server."
I tend to agree with you here, yes.

#

"crappy solution where you let clients to the phyhics bits"
Depends how you do it...

#

Running part of the physics on clients is actually a benefit. This is essentially what any prediction engine does

weak plinth
#

Unless there's a physics engine on-server, there is never a good way to do that

gleaming prawn
#

To give immediate feedback.

#

"Unless there's a physics engine on-server, there is never a good way to do that"
Deterministic Predict Rollback does it...:)

weak plinth
#

Not at all. There's still a physics checks on-server to determine the rollback

gleaming prawn
#

You can argue that running a master simulation on server to achieve authority on game results is needed.

#

"Not at all. There's still a physics checks on-server to determine the rollback"
No...:)

#

Not needed... You only need the server sim (or even a deferred re-run of the game) in case you want to validade the results (and you can do this post fact)

#

Disclaimer: I'm the developer of one of such engines.

weak plinth
#

So then, according to you, how do you prevent people from walking though walls

gleaming prawn
#

The only data that is sent over the network is your input (movement intention, for example)

#

you can TRY to modify your own memory to go through walls.. Good luck with that. That's what happens:

  • on the other players machines, you're just naively facing a wall (and not going through);
  • constant checksums flag your game client as a potential hacker (in the server);
  • your game result will be ignored (or the match will be flagged for auditing/deferred validation - based on server authoritative input stream)
#

No way you can do wall hacks, speed hacks, and similar... Unless the dev does something very stupid.

weak plinth
#

I'm waiting for the rollback part

gleaming prawn
#

Rollback is local

#

It's your game client's role to rollback (the framework performs that, based on the server-confirmed inputs)

#

Rollbacks are performed based on input mismatches (server never has to send physics data).

#

That's essentially how all fighting games are done, BTW

#

At least the ones with good netcode...;)

#

Traditional client-server is just one of the safe models for netcode (it's awesome, and server well several game genres, of course)

weak plinth
#

How does the server know to confirm inputs if it runs no physics at all

gleaming prawn
#

Server doesn't need any physics to confirm input. It's all based on a synced clock (from server) constant tick-based input stream.

#

Server needs to validate that game clients send input for every tick within a configurable aggressive time-limit

#

Any client that fails to do so has it's input for a particular tick reset as a zeroed-out one (or with the same as prediction config determines, but I'm trying to simplify the explanation)

#

For physics based games, deterministic predict rollback is arguably the best solution (I'm not trying to be a know-it-all, I apologize if I sound like that).

#

IMHO, it's your game (mechanics) what dictates which netcode strategy you should use (not any preference, or tool advertisement, and not ME as well).

#

I personally like all of the different strategies. I'm particularly a fan of the Destiny's distributed model.

weak plinth
#

I'm pretty sceptical about the implications of authority in some use-cases

gleaming prawn
#

You have the right to be...

#

Would you mind giving an example?

#

Of authority issues

#

(I'm always evaluating these myself).

weak plinth
#

Person A shoots person B
Person A claims there was no wall while person B claims there was a wall

#

The server has no knowledge of physics

gleaming prawn
#

There's no claim

#

Server MAY have the physics

#

OR you can re-run the full game sim post fact (as I mentioned)

weak plinth
#

We're talking about a use case where the server has no physics

gleaming prawn
#

Well, deterministic predict rollback is a model that lets YOU decide not to run the physics on the "expensive" real-time servers...

#

But it still gives you the AUTHORITY to check match results post-fact.

#

So authority might be needed on platforms where cheating is prevalent

weak plinth
#

IE a non-physics server is not always viable

gleaming prawn
#

But you don't need to pay expensive servers to use a lot of CPU with physics for ALL matches (PS4, Switch, iOS, have very little cheating going on)

weak plinth
#

There's also the case of difficult-to-mod on consoles

gleaming prawn
#

"IE a non-physics server is not always viable"
Predict Rollback Determinism gives you this as a choice... You use it only for the matches where it is IN FACT needed... So saves you (a lot of) money.

#

I'm not arguing with you that authority is needed (in some/many cases, arguably). I agree...

#

It's just an interesting model that gives you lots of interesting tooling out of the box (full match and killcam replays are part of the engine, you don't need to implement anything crazy)

#

I'm sure there are other developers in this channel who are familiar with it.

#

The model (not the particular product/tool I work on)

weak plinth
#

The model is a pretty known one

gleaming prawn
#

IMHO, the extreme popularity of FPS games might be the reason why their particular netcode models (there are more than one, but almost always based on the classic client-server) are the ones people tend to recommend.

#

They are interesting, and certainly safe models (although more expensive). But they are far from the being best models for all game genres (or the easiest ones to work with).

weak plinth
#

There's never one-size-fits-all in networking

gleaming prawn
#

But this is just my opinion.

#

yeah

#

That's why I like so much when a team comes with something interesting and different (like destiny's distributed model)

weak plinth
#

And even in the exact same game (hypothetically), you are probably going to make a difference in model between 16ccu or 128 ccu

gleaming prawn
#

ccu or player count in a single game?

#

(at least here) we refer to CCU as the total sum of concurrent players you have in the game (not in a single match).

weak plinth
#

Assuming ccu = players in this case

gleaming prawn
#

"model between 16ccu or 128 ccu"
Assuming in a match, of course.

weak plinth
#

My point being here that there's more leniency in terms of perf with only 16ccu

gleaming prawn
#

You can also go with a model that's very fast, simple/elegant, which is snapshot interpolation (same as CS-GO and Unity's fots FPS sample).

#

But this model doesn't scale if you need 32+ players, or lots of destructible parts...

#

Then you probably goes better with state transfer (with scoping, culling, priorities, etc)

#

Which is what is used in Battlefield, Fortnite, PUBG, etc (AFAIK)

#

Overwatch (state transfer + local predict-rollback) and Apex as well.

weak plinth
#

I rather go with state transfer myself in any case because it makes more sense for me

gleaming prawn
#

It's more felxible, yes

#

But also a LOT more complicated to implement, with lots of edge cases.

weak plinth
#

Not everything has to be easy ๐Ÿ™‚

gleaming prawn
#

Yes, sometimes a forget how complicated this is. I mean, developing games (properly) is difficult. Online multiplayer is arguably 10x more difficult.

weak plinth
#

Definitely

gleaming prawn
#

Anyway, back to work here. Nice chat.

#

Feel free to ask anything about deterministic physics if you wish (not necessarily related to the product I help develop, I'm always interested in physics + netcode in general).

weak plinth
#

I have many questions. But I'm busy with 50 other things currently

gleaming prawn
#

๐Ÿ™‚

weak plinth
#

Good to know that I can ask in any case!

foggy vale
#

Hello, just arrived, got a question: is using a Idictionary o Enum and Funct a good way to implement handlers for data packets events?

#

I'm trying to find an alternative to the big Switch implementation

weak plinth
#

That's something you can do. But it's a small overhead

#

Performance wise, there's nothing wrong with a huge switch

gleaming prawn
#

IMHO you can start with that, so you can implement the features...

#

But performance-wise you'll probably end up with the big switch later on...:)

foggy vale
#

isn't the switch more expensive

gleaming prawn
#

no

weak plinth
#

Not at all

foggy vale
#

in terms of computation?

gleaming prawn
#

way faster actually.

foggy vale
#

?

weak plinth
#

Switches bigger than like 3 becomes a jump-table

#

IE it calls the method directly

foggy vale
#

jump table? doesn't ta switch have to parse always all the cases?

weak plinth
#

Instead of a dictionary lookup and a virtual function call for the method

#

No. Why would it? The values are constants afterall

gleaming prawn
#

There's a faster way, depending on the language...:)

#

use the message IDs as a pointer offset... store a buffer with the function pointers...

#

All functionr efs will be in the cache... the pointer offset (message ID) makes the jump be performed really fast...

weak plinth
#

You could make that with IL probably

foggy vale
#

interesting

weak plinth
#

But not C#. Closest you can get to func pointers are delegates afaik

gleaming prawn
#

We do that kind of thing ourselves with C# (not really for function pointers though - maybe possible with IL).

weak plinth
#

And those are virtual func calls

foggy vale
#

do you know of a good library I can use that has this approach implemented?

weak plinth
#

Yeah, you can do it with delegates

gleaming prawn
#

I don't think that is really really needed

#

You can also use an Array of functions.

weak plinth
#

But that's going to be probably a fraction faster than a switch (although it'll look more consise)

gleaming prawn
#

That's slightly slower than the pointer approach, but works in most languages.

weak plinth
#

Array of functions, you mean delegates I assume?

foggy vale
#

that's why I thought of sorted dict (with enum) and Funct<T>,<T> as value... there is no lookup if it is sortedd and the CMD of the packet is calling the respective Enum

gleaming prawn
#

For very long function lists, I'd actually do a performance test..::)

foggy vale
#

guys you are going bacjk to what i was proposing

weak plinth
#

I'm not

gleaming prawn
#

No, I'd not use the Dictionary approach myself..:)

foggy vale
#

is faster a sorted dictionaty

weak plinth
#

No

gleaming prawn
#

I doubt

foggy vale
#

then having to use a fixed lenght array

weak plinth
#

Definitely not

gleaming prawn
#

Just do a proper test with a stopwatch in bulk numbers

weak plinth
#

Array is going to beat a dict any time

gleaming prawn
#

Dictionary vs Array vs Switch vs Pointers (if possible)

foggy vale
#

I'm ok with the array

#

same idea

#

storing Funct inside

weak plinth
#

IL is likely going to be the fastest, then switch, then array, then dict

foggy vale
#

and an Enum tab as offset

gleaming prawn
#

I'd expect the pointers to be faster (but not easy/possible with C# directly)

weak plinth
#

Since the last 2 use delegates

#

And array > dictionary

foggy vale
#

you mean Ilist?

weak plinth
#

No I mean array

gleaming prawn
#

really old fashioned array []

foggy vale
#

ok so you agree this is the fastest implementation for CMD handlers? (is this the right definition)?

gleaming prawn
#

There's a very basic reason why array is faster than Dictionary

weak plinth
#

Yeah, no lookup

gleaming prawn
#

No extra function stack...

#

a Dictionary lookup is an extra function stack created... Array lookup is just a memory fetch

foggy vale
#

there is basicly no lookup in an hashtable of a sorted dictionary

weak plinth
#

A dictionary isn't 1 single array either

#

A lookup is actually a lookup

#

Array is access by index, which is just a pointer offset

gleaming prawn
#

yes, exactly

foggy vale
#

problem is that an array is fixed

weak plinth
#

I don't see a problem there

gleaming prawn
#

Do you really need to resize it frequently?

foggy vale
#

but is ok I guess

weak plinth
#

Don't you know the exact number of commands?

foggy vale
#

true not frequently

gleaming prawn
#

Because you can resize infrequently just fine

weak plinth
#

A Switch is fixed size as well

#

But to be complately fair. The performance difference is going to be negligable between all of these

foggy vale
#

a switch ius like concatenated IF statements... they are expensive\

weak plinth
#

Unless you are squeezing the last few % out of your CPU, none of these are going to matter

foggy vale
#

we are talking about managing network packets.... is a heavy bottleneck

weak plinth
#

No it's not

gleaming prawn
#

If I had a situation in which a function lookup was a bottleneck, I'd check between the array vs switch (write a few performance tests, use IL2CPP builds on actual devices).

weak plinth
#

To both of your comments

#

If distributing of packets is in any way a bottleneck in your game, you've done someting terribly wrong

#

And a switch is NOT a bunch of if statements

gleaming prawn
#

I'd not even consider the Dictionary IMHO.

#

Well, for THIS use case, I think the Dict would not be that bad on a CLIENT.

#

On a server... Another story..:)

weak plinth
#

Neither on a server, comon, let's be real

#

Not unless he's planning to run a few hundred CCU

gleaming prawn
#

๐Ÿ™‚

#

Well, I'm used to handle thousands, not hundreds, in a single machine...

foggy vale
#

thats the idea

weak plinth
#

thousands is a completely different story

#

I'm thinking you shouldn't even be touching C# nor Unity at that point if you ask me

foggy vale
#

?

gleaming prawn
#

Native/C/C++ in that case

foggy vale
#

come on you don't neet to go down do C++\

gleaming prawn
#

We have a tiered server

weak plinth
#

When you have thousands of CCU? You definitely need to go down to C++ or lower

#

If only for the more consise memory management

foggy vale
#

my guess was that avoiding the switch with a good multithread implementation gets alreaady a 10X

weak plinth
#

No

#

It's not even going to be x2 vs a dict

#

Probably not even x1.1 lmao

#

In fact, a switch is probably faster

#

Likely*

gleaming prawn
#

good multithread implementation
As well, yes... But this is not as simple as it may sound when dealing with xK ccu per machine

foggy vale
#

ok I agree the array could be better here... so shall I go on with the array instead of the switches?

weak plinth
#

There's nothing wrong with a switch

gleaming prawn
#

Anyway, for your use case an Array would be just fine, maybe even the sorted dict

#

Or a switch, lol...:)

foggy vale
#

a switch looks so bad to look at ๐Ÿ˜‰

gleaming prawn
#

Agreed..:)

weak plinth
#

And jamming a collection full of delegates looks so much better? ๐Ÿ™‚

foggy vale
#

do you guyss have a good library to suggest to get inspired from?

gleaming prawn
#

Because books say so...:)

weak plinth
#

Well, unless you use reflection to fill your function collection at startup

#

That might not be a bad idea

foggy vale
#

delegates are resolved at compile time or I'm I wrong??!

weak plinth
#

define resolved

gleaming prawn
#

the pointer is resolved at runtime, as you can set them

#

just the signature is protected by compiler

foggy vale
#

really?

gleaming prawn
#

AFAIK.

#

in C#

weak plinth
#

A delegate translates directly to a virtual function call

gleaming prawn
#

So resolved in runtime, correct?

foggy vale
#

I thought it becomes a poiinter during compile time

#

I learned something new thanks

weak plinth
#

If you are questioning me what happens during JIT, I have no idea

#

I just know that in IL a delegate is a virtual call

foggy vale
#

I mean I think is in this way by definition

weak plinth
#

So the return val and params are known

#

If that's what you are asking

foggy vale
#

thats why they are compile prooof I think

weak plinth
#

Just like delegates

foggy vale
#

an array of funct is an array of delegates pointing during compile time to the assigned Static handlers in my case

#

or I'm I wrong?

#

tahts why it gives an error during compiling

#

if there is no reference

#

during creation of the array

weak plinth
#

a delegate is a pointer to a function

foggy vale
#

exaclty... resolved at compile time

#

so no Overhead

gleaming prawn
#

You can reset it during runtime...

foggy vale
#

no need

#

in my case right?

gleaming prawn
#

no NEED, but possible

foggy vale
#

I have static handlers

#

so no Overhead

weak plinth
#

no overhead?

#

IT's a virtual function call

gleaming prawn
#

not sure if there's a C# keyword modifier that would force it to be statically resolved.

weak plinth
#

Vs a function call

foggy vale
#

so reaching the Value of an array by index is way better then using a switch... and a more clean implementation

weak plinth
#

The overhead is the fact that it's a virtual function call

foggy vale
#

you can't create an array not statically resolved in my case

#

it is not a virtual function call is a pointer

gleaming prawn
#

Yeah, that's more expensive than the difference between array and switch

foggy vale
#

to a static method

gleaming prawn
#

yes, but delegates are implicitly virtual functions

#

So they get very late binding AFAIK.

foggy vale
#

but still at compile time

#

so it doesn't affect runtime right?

weak plinth
#

virt call takes twice as long about as a normal

foggy vale
#

if we don't agrre on the fact that what ius resolved at compile time doens't affect overhead I guess the whole thing makes no sense

weak plinth
#

You keep saying this, not me

foggy vale
#

if we are not sure about this I guess I'm getting just a bit more confused

weak plinth
#

It's a fact that a delegate is a virtual function call

#

And that takes twice or more as long as a normal function call

foggy vale
#

if you are sure about this then I learned something new

weak plinth
#

Also virtual function calls cannot be inlined

gleaming prawn
#

Checked here

#

delegates, as @weak plinth has said are essentially syntax sugar for an interface/virtual functions.

weak plinth
foggy vale
#

Ok

weak plinth
#

You can see the difference between a virtual call and a reg call here

#

this isn't IL but assembly

foggy vale
#

I will defenitely read this

gleaming prawn
#

Nice ref...

foggy vale
#

do you have a ref to a god library I can read that does something similar to what I'm doing?

weak plinth
#

Not only are the 2 function calls inlined without virtual, but all of the checks and memory moves etc are gone

#

No. But it doesn't take long to make

#

I mean, it does. But that's use-case specific

foggy vale
#

there is different ways to implement it and I could not find a good match yet

weak plinth
#

The only way you are getting away with this without much typing is by using codegen

#

Like T4 templates or whatever

foggy vale
#

and crafting from 0 as I'm doing is a bit time consuming

gleaming prawn
#

And notice we're already a lot beyond the original question (dict vs switch)...

weak plinth
#

Unless you want to do delegates, in which case you can use reflection at statup

gleaming prawn
#

The late binding/resolve is an extra optimization...:)

weak plinth
#

But as I pointed out, you aren't going to need any of these optimizations

#

And if you do, better go to C or C++ instead

gleaming prawn
#

Not for message handling at least

weak plinth
#

Serialization takes infinitely longer than message handling

gleaming prawn
#

I need to be aware of these things because I have functions that are called thousands of times per TICK...

weak plinth
#

Just to name one example of the chain

gleaming prawn
#

Yes, serialization will be a much more important topic for you.

#

Specially if you plan to do scoping/culling/priorization (state transfer), or even just delta updates.

foggy vale
#

Could you advise about a very good serialization library?

weak plinth
gleaming prawn
#

Write your own

weak plinth
#

My very own ๐Ÿ‘Œ