#archived-networking

1 messages Β· Page 61 of 1

jade glacier
#

not screwed, you just have to do your own simulation

#

and make sure it doesn't rely on any FP math

#

Competitive FPS doesn't need deterministic

#

competitive fps is almost always some form of state transfer combined with inputs

#

and RTS doesn't typically need "real" physics

#

For state transfer, close enough can work with physics

#

You just will get more desyncs and have to resim more often

void burrow
#

But am I wrong saying that state transfer opens up the ability to cheat, which in most competitive FPS isn't a great thing?

jade glacier
#

Depends on the cheats you are talking about

void burrow
#

Imagine movement.

jade glacier
#

a shader based headshot aimbot isn't going to care about any of that

#

the mouse input shits on all of that

#

since the server has to accept any value the player gives

#

Movement hacking you can stop with state transfer just fine

#

determinism isn't about stopping hackers, its about not having to state transfer a bunch of stuff pointlessly

#

like if you have tower defense games and those towers spawn 100 ai dudes... that would be hell to state transfer

#

so for games like that, determinism lets you avoid all of that, just by doing it all with user inputs only

#

But overwatch and such are straight up state transfer, because it makes life a lot easier

#

determinism is fragile, and coding to make it bulletproof is a full time career (thus fholm and erick)

void burrow
#

But if you're using state transfer for movement as an example. (Not talking about the head rotation of a player. Just simply AWSD) then how can you make that 'cheat proof'. Aren't those solutions build around having some kind of gracefulness around the state?

jade glacier
#

What cheat are you trying to avoid there?

#

you make it cheat resistant by making it server authority

#

The server runs the sim, and produces a state

void burrow
#

Speed hacks. So a player can't move faster than any other player.

jade glacier
#

the owner compares that state with the one it had gotten for that same simulaiton it predicted for itself in the past

#

if the owner finds that the server result disagreed, then the owner has to resim and try to get back into agreement

#

A cheater can ignore that an move wherever... but the server is going to not care. On the server that player is right where they are supposed to be.

#

Server authority over movement is how you stop speed hacks

#

Prediction on the player is just for the players benefit, it is not reality

#

Determinism is way overkill to just try to stop speedhacks

void burrow
#

From what I understand in order to get those kind of results you would need to send the input from the client to the server right. But wouldn't that require determinism in order to not get a out of sync client all the time? What I thought we were talking about is having the client send it's current position state to the server.

jade glacier
#

nah, you can make it work with "close enough" determinism

#

you don't want to resim the entire world anyway just to correct a desynced player

#

that would be a hefty resim

#

Determinism brings with it a bunch of things you don't want to get into just for that

#

the big one being near constant resims

#

for resyncing a player predict, that just involves a second simple scene of just the basic map colliders, your player, and maybe a couple entities that might affect player movement (like nearby players)

#

Typically for FPS type games, the desync isn't super common. It typically comes from some other player action (like getting in your way, or bouncing you with a rocket blast), the rest of the time its just you and the static map.

void burrow
#

So basically Unity is good enough for sending inputs without having to resim all the time (except when bumping into players and those kind of things). But it isn't good enough for full determinism? At least, that is what I understand from this talk πŸ™‚

jade glacier
#

yeah, try to just keep the terms clear

#

a deterministic engine requires 100% never disagrees results from the same inputs... on any machine

#

a deterministic event, like a weapon fire just means you can exploit the predictability of that shot

#

a deterministicy simulation, means you are going to get reasonably close results. Not idea, but with state transfer its better than nothing

#

To do it well, you would really want to write your own player physics (controller code) that is actually deterministic

#

But with state transfer, you have a built in self-correction for sims going off the rails

#

I don't know what your game even is, so hard to comment on what your challenges are going to be

#

But the typical challenge with FPS games is getting your prediction feeling good

#

You also have to decide if you are doing snapshot interpolation if you are going to want to have the server rewind shots

#

You seem concerned with hacking, so you might have to go that route, though its falling out of favor with BR type games (too expensive for the server to do that, so they just give the client more authority and rely on other anti-cheat measures)

#

If you start into one of your first net game attempts worried about cheaters though, you are going to spin your wheels A LOT.

void burrow
#

I really don't have a game I'm working on, I'm just trying to understand the typical issues games run into when making game X.
Trying to understand what kind of different networking architecture's there are out there and which issues exist, and how those are 'fixed'.

jade glacier
#

Net games will fail without a marketing budget

#

Throw concerns about hacking out the window.

#

You are way too early into this to get lost in that sand trap

#

Make a good game, or even a game that works at all

#

then step back and decide if you even like making net games

void burrow
#

Well prototype isn't the good term in this case. But I made something xD

jade glacier
#

yeah, a movement test is usually where most people start

#

That typically though is something most people get done on day one

#

Now that you are talking about determinism and actual real games, you need to start thinking about simulation

#

game networking is ALL about the simulation engine, and almost zero about the messaging

void burrow
#

Which seems pretty useful as well to me πŸ˜„

jade glacier
#

yup, though information overload

void burrow
#

But you would recommend getting into simulating 'things' (players, entities etc.)?

jade glacier
#

the simulation ties into the tick engine, and how you manage time and sync in general

#

as well as how you internally create your own deterministic order of operations and such

#

The mistake most of the libs available is that they are messaging layers only, but they try to sell people on the idea that they are a complete stack.

#

actual networking looks like....

#

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

#

Messaging is easy, its just serializing and deserializing stuff

#

The actual work of networking is in making the Input and State Buffers <-> Simulation

#

messaging is only there to transfer those buffers over to other machines in a timely fashion

#

A fancy netlib with all the RPCs, syncvars and other wrappers doesn't eliminate the need for the primary engine to be in place.

void burrow
#

Alright, thanks for the information. Sounds like I'm going to spend time trying to learn that part. See how it all works etc. πŸ™‚

jade glacier
#

You can poke around my code base if you would like

void burrow
#

Would love to!

toxic lintel
#

is there an easy way to run functions on both the server and clients

jade glacier
#

You kind of have to be specific about where you want to call things, and how you want that message to propagate... and you need to indicate which net library. @toxic lintel

toxic lintel
#

unet

jade glacier
#

its server based, so the server is the hub of all things

#

meaning if as a player you want to message people, you may not. What you do is message the server... and you can set that message type up so that the server then sends that to all clients.

#

Clients are not aware of one another

#

So typically, you use [Command] from theplayer to the server.
You then in that cmdMethod call an RPC to send a message from the server to all clients.

toxic lintel
#

ah alrigt

#

so call a command function

#

within an rpc function

jade glacier
#

other way around

#

Player calls the Cmd. It executes on the server. Inside the Cmd method is an RPC call. RPCs execute on clients.

#

You might want to join the Mirror discord server, everyone there knows Unet/Mirror much better than the average person here.

toxic lintel
#

alright

#

thanks

jade wharf
#

@jade glacier about that rpc thing, i realized recently how beautifully simple it is to make a function pointer table work with rpc’s

The packet ends up looking like this
index of array of function pointers, offset of start of memory (what data to act upon) Index of stack the input had occurred

#

Gotta love it when your allocator is so solid that even the area in memory the objects are , are exactly the same

#

So it just looks like a vtable, but global, and completely functional in its structure

jade glacier
#

If you aren't doing any kind of variable packing that make sense yeah

jade wharf
#

Yup, the packet gets even smaller after compression

jade glacier
#

I assume then you are doing some kind of RLE compression on the whole byte[] rather than bitpacking?

jade wharf
#

RLE?

jade glacier
#

run length encoding

#

zip compression, etc

jade wharf
#

Oh im using this.. let me get the wiki page

#

It works better for data thats already very small

#

Zip tends to have an overhead that makes it even larger

#

Markov compression is part of the LZMA algorithm too

jade glacier
#

Sounds good.

#

I am not using any kind of allocated memory, all of my stuff is meant for not ECS scale and focuses on bitpacking in serialization - so very different animal.

jade wharf
#

Gotcha

jade glacier
#

The main benefit of hand serialization is you can inline your logic into the serialization

jade wharf
#

I know that Object is already huge, not sure if you are forced to serialize that in your stuff

jade glacier
#

so lots of 1 bit prefixes to things indicated if certain stuff was serialized or not

#

You should have control over what is included in your method - just a bit harder to bake in any serialization logic into the stream

#

bitpacking with lots of logic is going to be the smallest, but its not going to be the fastest by any measure

jade wharf
#

Ive found that if you are just smarter about when talking should happen you have more time to serialize anyway xD

#

Doesnt help for downloading large files to have a slow serializer of course

jade glacier
#

Are you trying to serialize a large number of states or some goal like that?

jade wharf
#

Oh that only happens once on the client, and i always serialize and pack the current tick on the server anyway

#

The serializer is already really fast as it is so i just touched it

#

Don’t touch*

jade glacier
#

If you are just byte copying from your allocated memory I would think it would be stupid fast

jade wharf
#

Well your right it is

#

:p

#

It has its own assembly subrouting that makes it even faster at copying data larger than 1mb

#

Using avx instructions

#

Subroutine*

jade glacier
#

That is kind of the backbone of the DOTS netcode stuff I think

#

For the server side you get a lot less CPU carnage in exchange for not as great compression

#

Which for like a BR, I can see that being useful

silver wave
#

but i receive the message when the player joined the server

steady kite
#

@jade glacier

#

just tested photon on a new project

#

still doesnt work..

#

2019.3.6

jade glacier
#

PUN2 I assume you mean? What's it doing?

steady kite
#

nothing

#

the scripts will literally not recognize anything

#

using photon.realtime or photon.pun

jade glacier
#

You have no errors anywhere?

steady kite
#

nope

jade glacier
#

Installed the asset from the store, and none of the define symbols showed up?

steady kite
#

nope

jade glacier
#

I'm not an actual PUN2 dev, I make an extension for it -but I am curious what is up with that.

#

So literally made a completely fresh Unity 2019.3 project... added PUN2 Free from the store... and not a peep of any kind? So where are you experiencing the failure?

#

code in VS doesn't recognize it?

steady kite
#

nopee

jade glacier
#

you have to give a bit more

#

hard to troubleshoot nothing and nope LOL

steady kite
#

I made a new fresh project again and imported it

jade glacier
#

have you tried closing and reopening everything?

steady kite
#

turns out i get this errorhttps://gyazo.com/bfed4d4ecac89fdd0b932c9cc45e0951

jade glacier
#

Might be worth googling that

#

Good old bleeding edge unity

steady kite
#

i feel like a noob.. this never happened to me before

jade glacier
#

Unity is a wreck right now

steady kite
#

okay i see

#

its an issue in the new unity

jade glacier
#

as far as I would guess, since that is the thing that has changed

#

PUN2 works fine with every previous version back to 2017

steady kite
#

people are saying it works in the newer versions

jade glacier
#

I'm trying a fresh .6 now as well

#

You got to the part where it asked for you PUN appid, or failed before that?

#

I get that same assert fail, it shoudln't matter

steady kite
#

failed before that

#

but still get that part

#

put in the id and same error

jade glacier
steady kite
#

HOW?

#

whatttttt

jade glacier
#

Might want to reinstall your Unity or something

steady kite
#

yeh..

toxic oak
#

yeah i've been using it

steady kite
#

i reinstalled everything, made sure .NET is updated and still doesnt work

#

hm

jade glacier
#

Any other imports of assets do that?

#

You can try adding the define to the symbols by hand and see if that does anything

#

As far as I know those symbols wouldn't matter for this

#

If you right click on the assets folder and force reimports and such what happens?

#

does it scan al the files in the photon directories?

#

I'm vs 2017, and its all working just fine

#

I would start by making your own quick namespace, and see if it respects that

#

next thing to look into is that maybe 2019.3 on your setup for whatever reason is not happy about the ASMDEFs in PUN2

high night
#

I am trying to make a predictive multiplayer setup.
Here's how i plan my scene setup to be:

-SyncedScene (runs in past, smooth looking)
-PredictionScene (rolls back to synced scene, extrapolates inputs, not smooth looking because of internet delay)
-SmoothedPredictionScene (PredictionScene but lerped position/rotations)

My questions:
1 - Is the 3rd scene necessary, can i have smoothness without 3rd scene?
2 - How can i disable camera on 1st and 2nd scenes and only render 3rd scene easily? Or stripping renderers is the only way?
3 - If you did something similar how did you have your scene setup?

jade glacier
#

Are you writing your own simulation, or is your simulation PhysX or some other physics engine?

#

Because that simulation engine counts as a "scene" in the context you are talking about

high night
#

@jade glacier physX, i rigidbodies and colliders
default everything

#

I am not going for 100% determinism

jade glacier
#

I typically just have my main scene

#

and then a scratch scene for resims

#

the main scene already interpolates, physx is built in and automatically does that for you in Update

#

rb.position and transform.position in Update() won't match

#

rb.position is the result of the last sim (FixedUpdate)

high night
#

I don't know, the interpolate doesn't do it for me, i think rigidbody interpolation interpolates too fast? I mean maybe it's interpolating 0 to 1 until next fixed update frame, i want it to take longer, multiple fixedupdates.

I want the interpolation to take longer because gap is often too big to cover in one frame

I remembered there was a setting that can disable rigidbody editing the transform
Guess i'll use that tomorrow

jade glacier
#

Not sure I follow

#

Fixed and Update are completely tied to PhysX

#

how it interpolates is exactly correct, unless you mean on the client side where you are trying to recreate motion

#

that you will want to do yourself with your own lerps

high night
#

so you're saying i need the 3rd scene?

jade glacier
#

nope. I think we are trying to type very complex concepts with generalizations

#

you should start with just your one scene, and get that working without prediction

#

then add prediction, and decide how you want to deal with resim when you get to that problem

#

You seem to have a lot of complex problems way too early into the process, I think you might be overcomplicating things too early in

high night
#

when a player changes its input (moving left while moving right)
its prediction on other client jumps instantly to the otherside in one frame

#

i already did those let me show you what i got

jade glacier
#

Why are other clients predicting?

#

I have no idea what your architecture is then, I was assuming a standard state transfer

high night
#

i send only inputs right now

jade glacier
#

Start with no prediction... everyone sends inputs to the server on a tick... server sends out state results

high night
#

ill send state transfers every 2 seconds or so

jade glacier
#

everyone recreates the server state by lerping between the states it sends out

#

yeah, you are doing some way atypical

#

so I can't really comment, you are kind of out in the jungle with that

#

Have you made a standard state transfer with interpolation and client prediction as a starting point?

high night
#

i can serialize states right now, but havent sent them over internet yet

jade glacier
#

Or at least are you modelling this architecture after a game you know about that does what you are doing?

high night
#

just using that for rollback right now

jade glacier
#

Yeah, you are trying to get too tricky WAY too early on

#

Have you made a working networking system with standard practices yet? Or is this your first attempt?

#

Nothing that exotic is going to work unless you really have your simulation management buttoned down tight

high night
#

with photon though

#

its got lotsa bugs

#

thats the clients view

jade glacier
#

What is the net architecture of that? pure client authority and state interpolation?

high night
#

this one i sent?

jade glacier
#

The one above

high night
#

clients have movement authority
server have arrows and healths authority

jade glacier
#

If its PUN its likely pure owner auth with state interp

#

yeah, that would be pretty standard

#

so now you are trying to make a server authority model work. Start with the standard system and get that working before complicating your life so much

#

standard practice is player inputs to server... server states to all

#

Don't be trying to send player inputs to all players unless you have a deterministic system happening. A state every two seconds is going to make some HARSH corrections

high night
#

client -> input -> server 10hz
clients <- inputs <- server 10hz
clients <- state <- server each 2 seconds

jade glacier
#

yeah, don't do that

high night
#

1 second state sends then

jade glacier
#

Unless this is like a turn based game... you are setting up for massing latency and harsh corrections with those values

#

Pick a net rate... and send inputs at that rate, and have the server send out states at that rate

#

trying to miser data to the extent you are is going to make garbage and frustrate the hell out of you

#

Get a working fixed tick state transfer going first... THEN start playing with ways to miser your data

#

Is there a game you are modelling this after that uses values like that?

high night
#

no, not at all

jade glacier
#

Oh well, you do you. I wouldn't recommend the path you are taking, but its always good to try weird shit to learn.

high night
#

@jade glacier thats what it was,
on the left prediction is smoother because applied directly

#

but other client recieves packet 10hz, its a little more skippy

#

its kinda difficult to see because of low gif framerate

jade glacier
#

The model you are making is too foreign to me to have any good feedback for you sorry.

high night
#

how much bandwidth at max should be used per client do you think

how much should it cost at max per client at max:
input transfer + state recieve

jade glacier
#

typical no worries target is byte[1000] per tick

#

and your tick rate being in the 20-120 per second range, depending on game format

#

that is for UDP

#

you are doing TCP which is a whole different animal

#

and not really recommended for fast realtime 3d state transfer stuff

high night
#

3d state transfer?!

jade glacier
#

?

#

The stuff we have been talking about for the last hour?

high night
#

hm

#

.
If i switch to some UDP transport in mirror, are my RPCs still guarantied?

jade glacier
#

you can tell them to be

#

just be careful mixing reliable and unreliable streams

#

doing that typically implies a lack of a simulation and a lack of state/input buffers

#

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

#

That is path to sanity. Throwing messages around outside of your state and input buffers starts to invite race conditions

high night
#

you use unrealiable channels for all transfers right?

#

in your favorite model

jade glacier
#

I do yeah, but I am doing something different with PUN2

#

it depends how you are dealing with lost/late packets

high night
#

that would be clients fault?

jade glacier
#

fault for what?

#

lost packets? That is the internet

#

TCP automatically retries and holds up the stream at the hardware level

high night
#

next state that client recieves will be more off from prediction i mean
and that will happen frequently

jade glacier
#

RUDP does it at the software level

#

If you don't have a tick system for state and input buffers and how they tie to a fixed simulation, you are going to just be flailing around with it.

high night
#

by saying buffer, you mean server simulating in past?

jade glacier
#

I mean a whole system you should have in place before starting in on messaging at all

#

first you have a fixed tick... that is your simulation rate

#

before every tick you collect inputs for each connecton. You then apply them to the current STATE by running your SIMULATION.

#

That produces a NEW STATE, which is the state of the next tick

#

You store those INPUTS and STATES in buffers

#

That is your history

#

and that is what gets serialized

#

Clients that are predicting store the inputs and states they used for prediction... and serialize and send the inputs the the server, which is uses to also simulate.

#

the server produces a new state (all of the values of things after simulating)... and sends that to all clients along with the tick number.

#

The owners compare the state results for the objects they predicted to determine if there is a desync

#

If there is a desync, they rewind back to the disagreement, use the server state value as the starting point for the tick where they went into disagreement... and then resim back to current by applying the history of inputs. Creating a new history that should now be more in agreement with the server.

#

I can't really type much more about this without starting to cut and paste from all of the websites that talk about this stuff.

high night
#

The owners compare the state results for the objects they predicted to determine if there is a desync they rewind back to the disagreement, use the server state value as the starting point for the tick where they went into disagreement...
Why don't client just replace its scene with server state without checking for desync?

#

Is it supposed to be an expensive operation?

#

Deserializing a state?

#

you still need to deserialize it to check for desync though

jade glacier
#

Because with latency you only know about the desync well after the fact

#

You only know that the server disagreed X ticks ago

#

You deserialize it every tick, you need it for your interpolation

#

When the tick update arrives, it has a tick number at the front of the packet. You deserialize that state in that packet into that buffer tick slot

high night
#

Oh wait, client doesn't rollback and re-simulate everytime it recieves a new state.

jade glacier
#

You really should read the gaffer docs, and look into some of the standard networking stuff done for Counterstrike, Quake and Overwatch

#

you are basically asking questions that will take me 10000 words to explain, and will require graphics

high night
#

Not really, i think i got it

jade glacier
#

You should be familiar with the standard systems before trying to do anything exotic

high night
#

This architecture is understandable though thanks @jade glacier

jade glacier
#

variations on that are what most FPS games use

#

it is standard server authority state transfer

high night
#

I guess i'll halt my architecture and turn it into this

jade glacier
#

Once you have a standard simulation in place with buffers, then you can futz with net tick rates and such

#

The simulation and buffers interaction though really has to come first

proven crystal
#

Any netcode pros in here that could help guide our team to a hacky p2p setup for a MP shooter?

#

we just need it for game play testing. nothing public. we also have a core programmer but his strengths are not in networking, he can do it but its a stressful ride. so even some guidance would be really incredible

#

willing to pay as well πŸ™‚

#

DM me if you got the goods please

#

currently trying to use photon

quasi tapir
#

Is there a callback to know when the second player joins the room I created so I can get a reference to him in my scene gameobject?

#

I want to display and compare both the players health and show it in my Canvas UI, mine is a 2d game and I can get the reference of my player or the one who creates the room, but I have no way of knowing when the other player joins the room to get a reference of him

#

I'm using photon btw

steady kite
#

use the onjoinedroom method

#

and be like

#

if(!ismasterclient)

#

yes?

quasi tapir
#

Ah will check it out

graceful zephyr
#

full 3d deterministic physics engine, here demo of the car physics

#

full rollback/prediction support for entire physics world, etc.

gleaming prawn
#

πŸ™‚

#

Suspension + tire friction models are stable already. Now it's pretty much "game design" (calibrating for different vehicle models, etc).

jade glacier
#

πŸ‘Œ Noice

weak plinth
#

this is like space age stuff compare to unity's new netcode

jade glacier
#

Pretty much. AAA titles will not be shipping using netcode any time soon.

weak plinth
#

i bet netcode won't be shipped at all

#

for the last couple of years my confidence in their ability to deliver is vanishing

jade glacier
#

They really should have started a new engine for the ECS stuff imo

weak plinth
#

I am wondering if anyone is aware of a github 'awesome' page for lag compensation with unet ?

#

It seems like this is not super difficult at first, but then when you start thinking about object occlusion and stuff

jade glacier
#

"lag compensation" by itself isn't a thing, its any number of strategies really

weak plinth
#

it starts getting computationally expensive really fast

#

ye

jade glacier
#

You are referring to client prediciton?

weak plinth
#

I was kind of looking at some code examples I could read

jade glacier
#

or extrapolating states?

weak plinth
#

no, I have that solved, that was quite easy

jade glacier
#

Or server rewind?

weak plinth
#

server rewind

jade glacier
#

yeah, its gets a little heavy

weak plinth
#

So, I can keep a list of object states in a circular buffer

jade glacier
#

For mine in the past with phsyx, I kept a layer reserved for just those operations

weak plinth
#

oh thats a good idea

jade glacier
#

But with 2018.3 you can have a separate physics scene

weak plinth
#

to check for occlusions ?

jade glacier
#

and I populate that with really lightweight copies of networked objects and terrain colliders

weak plinth
#

oh nice

#

that is such a good idea

jade glacier
#

Then, you just move and active the objects you are testing

#

recreate the shot, and return the results

#

basically its a scratchpad physics scene

weak plinth
#

amazing thank you, thats a great lead

jade glacier
#

np

weak plinth
#

actually, I found an article I can share

#

that is simular

#

My objects are not physics based at the moment

#

but this solution is starting to take shape in my mind

jade glacier
#

then no need for anything physx scenes, you should be able to handle that all in your own sim

weak plinth
#

thank you so much

#

I think I could handle the occlusions in physx scenes?

jade glacier
#

are you using physx?

weak plinth
#

not at the moment, its all code based movement and no physics

jade glacier
#

you mean not physics based meaning no sim, but you use the colliders for tests?

#

like all CC based

weak plinth
#

I use colliders yeah

#

and raycasts for tests

jade glacier
weak plinth
#

oh wow, thank you so much @jade glacier

#

I am going to read/study for a bit

#

theres a lot to think about with this problem, it feels deceptively simple πŸ˜„

jade glacier
#

There is a bunch of other files, but that is the one that kicks it oof

#

I have a bunch of components that connect the real objects to their ghosts and such, for easy back and forth for the resims

weak plinth
#

and then do you resimulate at time X?

jade glacier
#

I don't use time for networking, just ticks

#

Though for rewinding shots, you may need to come up with fractional times

#

But if your weapon fire all happens on a tick simulation, then you should be able to recreate things using the tick states alone

#

The server rewind consists of knowing how many ticks the player is living in the future in their prediction. Which makes it a very simple rewind operation.

weak plinth
#

awesome, thanks again! this is exactly what I want

stray scroll
#

In the game I'm making you're a character who can use consoles on a spaceship to control different stuff, like steering, guns etc. Currently I'm trying to give the client who wants to use the console prediction on the object it is using, e.g. one control controls the spaceship itself as a pilot. Now to predict this, which is basically driven as a dynamic body with forces, I would need to only step this object when I do prediction, comparatively to character controller which deals with collision right away in my case. Anyone who've done this or could give some ideas how to solve this problem?

#

I'm using the DOTS physics as well.

jade glacier
#

I don't know the actual answer for you, but I always break the problem down into who is the input authority... and who is the state authority

#

If you are predicting your physics locally, all the usual rules of prediction should apply. You record the inputs in a struct that is the same that is used locally and on the server. The server I assume is the state authority, so on the player side it should be recording the state results for each predicted tick... and if the server state comes back in disagreement, you resim that object.

stray scroll
#

Mhm, yeah I think my question belongs more in physics channel. I guess my question was more aimed towards if it is common you predict these types of objects or you would only simulate on server with clients input, resulting in some delay. The thing is now that (I'm using the DOTS netcode) so the prediction loop doesn't contain any physics step, so I'm a bit at square zero of how to sim only one physics body. πŸ˜›

jade glacier
#

I would do the prediction in the main scene if possible, unless you are deterministic there is no "true" scene on the client.

#

I use the second scratch scene for resimming, but I only include things that will affect the player, like terrain and such. With the new physics though they probably are trying to do a stateless thing, but that would get pretty enormous saving entire stateless physics scenes.

#

I only can speak to pre-dots handling of this stuff

stray scroll
#

Hmm, ok. Yeah you would need to save the state before prediction, predict everything X ticks, and then guess roll back everything except the predicted entities. What I've seen so far of what they've been doing has been with character controllers and not touching anything else except the predicted entities in the prediction. But for my case I would only care about static collision as well. But I still need to know how to deal with it in the DOTS Physics .

jade glacier
#

Generally you will want to be saving states and inputs as part of any networking system anyway

#

In the case of the predicted player, its really just the transform info. Specifically pos and rot you want to keep a history of with the ticks

tawny atlas
#

Hi

weak plinth
#

@stray scroll i asked some question about physics in predicted objects (in my case i wanted to predict rockets/bullets which are controlled by the dots physics system) in the forums.

TimJohansson says that they are going to investigate into physics prediction (and i am pretty sure they will come with a good solution because the whole dots physics is made stateless for things like netcode).
So for now i think the best thing is to wait and run the physics on the server (and take the delay).

stray scroll
#

@weak plinth Think you linked wrong thing ^^

weak plinth
#

you are right^^

#

better now

#

hope this helps πŸ™‚

jade glacier
#

So for now i think the best thing is to wait and run the physics on the server (and take the delay).

Is all of this really worth doing anything at all with Netcode? That is some pretty fundamental stuff.

#

Seems like the whole thing is being beta-tested on people who need a working net engine.

#

The whole thing reads as a bit ass backwards, since a solid simulation engine is the core of real networking. And they don't have that happening yet.

weak plinth
#

So for now i think the best thing is to wait and run the physics on the server (and take the delay).

Is all of this really worth doing anything at all with Netcode? That is some pretty fundamental stuff.
@jade glacier sometimes i am asking this myself, too πŸ™‚ I was also wondering why it is not possible to run the physics systems in the prediction group of the client.

jade glacier
#

Can you not create multiple physics scenes?

#

Seems you can just do it the way we currently do it, just have a scratchpad scene for resimulation

#

where you only include the things that need to be part of the sim. It won't be fully deterministic... but as far as I know Unity Physics won't truly be deterministic anyway.

#

So "Close enough" resim is the best you can hope for anyway.

#

I am making some assumptions about the current netcode workings... I am assuming its snapshot interpolation with server auth

weak plinth
#

In DOTS you are programming everything into systems. For client side prediction they run the same system in the server and on the client. But the client runs the system several times for prediction.

#

I am making some assumptions about the current netcode workings... I am assuming its snapshot interpolation with server auth
@jade glacier yes it is

jade glacier
#

I assume you mean the client runs several times "when it needs to resim" ?

#

While not in desync, it should just be able to run the one sim... which is you pushing your player around.

weak plinth
#

yes, right know it always run its several times when a snapshot is received

jade glacier
#

The only issue being if the server comes back with a different result, and you need to rerun

#

that seems weird and not good then

weak plinth
#

The only issue being if the server comes back with a different result, and you need to rerun
@jade glacier they have not implemented that yet
In my forum post, i am asking this in my first question
https://forum.unity.com/threads/netcode-client-side-prediction-questions.813492/#post-5396892

jade glacier
#

desyncs should only happen if a non-deterministic event on the server side interferes with your player actions

#

I glanced at that article, and the answers were making my head hurt

weak plinth
#

right now they always rollback and resim

jade glacier
#

this seems like pretty basic already solved stuff

#

wtf for?

#

constant rollback and resim I expect to see in a deterministic extrapolated sim

#

I am either missing something, or there is some dumb stuff happening there

#

In the case of the player just being a single character controller... desyncs should not be that common

weak plinth
#

dont know either, but Unitys lead network developer says "We do not have any short-term plans to do this"

#

so i think it is ok to always resim πŸ˜„

jade glacier
#

Legit desync causes:

  1. blocking actions or physical blocking of your player by another non-deterministic player
  2. packet loss
#

end of list LOL

#

I suppose since this may be physics based player movement....
3) Floating point errors leading to butterfly effects

#

All of those should result in not so common desyncs

weak plinth
#

also wondering why it is not implemented, but for now it only costs performance πŸ™‚

jade glacier
#

Only thing I can see going on there is that its trying to extrapolate some other non-deterministic stuff that results from other players to try to get ahead of possible upcoming desyncs

#

But that is starting to straddle the fence on just making a deterministic system

#

It could be that the resim cost is so cheap, that they aren't caring and are just brute forcing not having to deal with any of it.

#

If you are running a giant space sim, that's going to end up being a lot of resim for a whole lot of nothing

graceful zephyr
#

The difference between what's called 'client side prediction' and 'predict/rollback determinism' is that you in client side prediction you:

  1. predict just a small part of the game (usually your character + a few more things)
  2. you get the correct state from the server, and rollback to this

With predict/rollback determinism you

  1. predict all or most of the game state
  2. rollback to a previously saved copy of whatever state is the last one which you have all inputs + previous inputs for
jade glacier
#

I don't believe they are doing a deterministic rollback... or are they for some reason?

graceful zephyr
#

who? unity? no

jade glacier
#

Assume what he says is true and its resimming EVERY time

graceful zephyr
#

resimming every time is common in both models

jade glacier
#

Trying to make sense of why netcode would always resim the entire scene with every server state arrival

#

That seems to make some assumptions about the nature of the game

graceful zephyr
#

because it leads to more accurate predictions

jade glacier
#

I can see having it as an option.Like if you want to stay ahead of the causes of upcoming desyncs

#

ie a rocket is heading toward your face

#

But if your sim isn't like that and you are just one of 300 spaceships, that kind of resim seems like something you would want to opt out of.

#

Though, with the ECS aspect, the resims may be so cheap they just opted for "just works" as the default path

graceful zephyr
#

yes, possible - i wouldn't count on the resim always being cheap tbh

jade glacier
#

That is why I am scratching my head (if its true)

#

the assumption about the game being made is kind of a big one there

graceful zephyr
#

it only resims things which are marked as part of the prediction group

#

it doesnt run the whole game X times

jade glacier
#

ahh, so it does have some degree of culling in this system

graceful zephyr
#

i.e. the systems which are part of the ClientPredictionSimulationGroup

#

it's not the entities which are culled

jade glacier
#

Then you have some decent control it sounds like

graceful zephyr
#

it's which systems are part of the ClientPredictionSimulationGroup which controls what you re-sim

#

if you put everything in there, then you predictr everything

jade glacier
#

That should be enough to make it manageable

gleaming prawn
#

Even our deterministc engine does prediction culling....:)

jade glacier
#

I would expect, since the prediction is outside of the deterministic part of the system no?

gleaming prawn
#

It is jot

#

Noz

jade glacier
#

Its the cosmetic 'best guess' to show the player no?

gleaming prawn
#

No

#

It's a super accurate guess,

#

It's a bit like the other way around

jade glacier
#

yeah, but its not meant to be 100% the final word, its just the best working guess with what is known

#

Since its predicting

gleaming prawn
#

Yes

#

But this solution is decoupled from the SIM engine

#

I mean, the culling is done on the ECS API

#

The prediction/rollback network model does not no we are actually culling

#

We are quite happy with how elegant the solution for this ended up like

jade glacier
#

I'm fuzzy on the details, but I think I have a pretty good big picture idea of what is going on

gleaming prawn
#

It's one of those thing that just make sense and fit like a glove

#

It pretty.much removes the overhead of the resimulations

#

So that is not a problem at all...

graceful zephyr
#

prediction culling just means only entities which are within X radius of somewhere (usually where u looking) is whats predicted

#

and then only the entire sim runs during 'verified' frames (ie,. where u have all input)

jade glacier
#

Makes sense. I assume the final history though is always done with a full sim (when all inputs are in)

graceful zephyr
#

correct

gleaming prawn
#

Exactly

jade glacier
#

I see all of the prediction stuff being "whatever works and is fastest", since there is some flex there

gleaming prawn
#

It's the details of how we implemented this that imho ended up so clean

#

Because of the decoupled nature of the several layers

jade glacier
#

Of course, not trying to minimize your work at all

#

just trying to mentally draw an accurate picture

gleaming prawn
#

Tbh, the culling was not a lot, lol

#

It's a massively important and cool features

#

Feature

jade glacier
#

I assume you give the devs all kinds of options on how to handle the predictions

#

anywhere from everything, to nearly nothing

gleaming prawn
#

But implementing it just made sense after everything else that was put around by Fredrik

jade glacier
#

One day I hope to use it

gleaming prawn
#

Yes, besides the area of interest "automatic" culling, we also give options to flag entities as not cullable at all, options to manually full out based.on other things, etx

jade glacier
#

My "Build your physics based space/air fighter and duel with it" game would love that system

gleaming prawn
#

Lol,.funny you say that

jade glacier
#

Working up to that yourselves?

#

Or just making some premade flight models to go with your vehicle sim

gleaming prawn
#

We have a pretty nice model similar to Eve's

#

That we iterated a lot over a couple of months

jade glacier
#

I started there when fredrick was making his space thing, and then I added airfoils

gleaming prawn
#

This was.personal

jade glacier
#

and ended up with a complete flight system and building system... but no networking that would be good for it

#

Fun stuff. Too bad I will never actually get to make a game πŸ˜›

graceful zephyr
#

you guys are confusing the two projects

jade glacier
#

I think he was just mentioning the other one

#

though the vehicle stuff seems like it should be included

graceful zephyr
#
  1. i have an old (late 2017/early 2018) space sim project thing - what @jade glacier talks about
  2. erick and i have built a space flight eve thingy recently
jade glacier
#

ah, three things

#

Just for kicks, or is the eve thing to help build up some library stuff for devs?

graceful zephyr
#

nah personal project MMO thing

gleaming prawn
#

In a shelf somewhere currenrly

#

The vehicle stuff is officially for quantum

jade glacier
#

excellent

gleaming prawn
#

It's to be given to all customers

jade glacier
#

Any plans to make flight model stuff as well?

gleaming prawn
#

Like an asset

#

We have a few studios working on that

#

But no plans to make a default flight model for now, no

#

Looks a bit too much game specific IMHO

jade glacier
#

Was a lot of fun building mine, learning how to properly deal with drag and angular momentum an such

#

Though that is more just about making a more proper physics lib

#

PhysX cheats on rotation in ways that makes sim kind of garbage

gleaming prawn
#

Like the space eve thing, we ended up with a custom physics model (both very specific and also simpler solver)

#

Yes, exactly

jade glacier
#

Does the eve flight model use something of a Star Wars physics model?

#

(sort of like there is air... but not)

graceful zephyr
#

this is the eve thing

gleaming prawn
#

We did not use quantum default 3d solver

jade glacier
#

yeah, that looks like Star Wars physics

graceful zephyr
jade glacier
#

"thick" space LOL

graceful zephyr
#

yeah

jade glacier
#

That was where I started, and then factored in face area, and distances from center of gravity to create virtual drag and lift

gleaming prawn
#

Yeah, it has "ether"

jade glacier
#

ended up with basically an unstallable wing

graceful zephyr
#

this is in no way intended to be realistic

#

just to play nice

jade glacier
#

yeah, that was where I was going as well

#

realistic is not fun

gleaming prawn
#

Yeah, although we used AOA, not with a wing model, etc

#

But it was enought to render a standard drag solver useless

jade glacier
#

The wing code ended up being reasonably cheap.

#

The benefit of it vs just a prepacked "value" for drag is that it responds to wind direction

#

it will weathervane and such

#

and center of gravity changes the flight character

gleaming prawn
#

No wind in space in our case, lol

jade glacier
#

Of course

#

Different use case

#

mine was more for making your own PlanetSide2 type dogfights

#

So it consists of engines that aspirate or are rockets, and the option for manuvering jets in conjunction with wings

gleaming prawn
#

Interesting

jade glacier
#

It was an offshoot because of the model I made to do the starwars stuff

#

but once I added the plane surfaces lift and drag, it became fun to explore

#

So I messed with gravity and air density and it made for a very interesting game idea

gleaming prawn
#

Is it local?

jade glacier
#

on this guy the red cynlindars are rocket engines, so like the ones on the wing tips let you "slide" and the rear engine is thrust vectoring.

gleaming prawn
#

This should work with quantum turnkey

jade glacier
#

Yeah, that's local. I didn't touch the networking because it needs to be server auth

#

OR quantum yeah

#

I pretty much stopped work on it. Fredrick was just releasing Quantum and I was like "fuck this, I am NOT writing netcode for this thing when something can just be used for that"

gleaming prawn
#

Yes, you'd be able to just port it as it is

jade glacier
#

yup, that was my expectation when I stopped work.

#

Then I got buried in this SNS stuff

#

I had a rudimentary workshop view as well for placing the servos, motors, wings, etc. That part requires no networking, since its all offline.

gleaming prawn
#

Wright flight program

#

Or, the "Wright" stuff

jade glacier
#

with GUNS

#

The real goal is a mech warrior type game, only with flying machines

#

Though I am not dumb, I will never make it. A game like this needs half a million to be real

gleaming prawn
#

Then it has to be slow, don't use a real flight model, lol

jade glacier
#

Its totally not real

#

a real flight model would make creating working planes WAY too hard for the average person

#

and the speeds would be too great

#

So it largely is based around low gravity, and high air density

#

Similar to what Planetside 2 flight feels like

#

lots of hover duels

gleaming prawn
#

You know what is even more difficult?

#

Bike and motorbike physics

jade glacier
#

yeah, not touching that

gleaming prawn
#

Try to understand bike counter steering...

jade glacier
#

Way smarter people than me out there like you guys doing that

stray scroll
#

And I simply use an interpolated movement from high thrust less rotation, to less thrust a and and more rotation and planar movement (based on velocity) x)

gleaming prawn
#

:)

jade glacier
#

I am just a pilot and grew up on flight sims... so I get flight models. Vehicle models are too much voodoo

gleaming prawn
#

Do you have a license?

jade glacier
#

For basic stuff, the PhysX model is fine. But it does get in your way if you try to start adding proper angular moment and forces

#

Yeah, though haven't flown in like a decade

#

I got up to my Multi-engine rating

gleaming prawn
#

Oh, cool

#

I just did the first initial experimental lessons, enought to put my hands on a single engine rv9

jade glacier
#

fun fun

gleaming prawn
#

Tons of

jade glacier
#

I recommend a flight lesson to anyone. Its not that expensive, and they let you do a LOT if you come somewhat prepared

#

I took one heli lesson, and he let me do it all

gleaming prawn
#

Exactly my experience, I studied a lot before

graceful zephyr
#

i wont even set foot on a plane unless my life depends on it πŸ˜„

stray scroll
#

Why would I risk someone elses life like that xD

jade glacier
#

No need... that's why we make games πŸ˜›

graceful zephyr
#

just look at the drama over spain right now

gleaming prawn
#

Lol

graceful zephyr
#

as in literally right now this very moment

gleaming prawn
#

Oh, not informed

jade glacier
#

christ, do I have to open a news website now?

#

News is for lewzers

graceful zephyr
#

boeing 767 lost a landing gear which flew right into an engine, and now they need to make an emergency landing with 1 engine down and not all landing gears

jade glacier
#

Year off to a bad start for Boeing

graceful zephyr
#

they can not catch a break

stray scroll
#

It already landed?

graceful zephyr
#

no its circling

jade glacier
#

I would love to see that video, to see how a landing gear comes off... and then manages to go forward and up into an engine

graceful zephyr
#

to empty fuel tanks

#

@jade glacier think they lost the front landing gear?

jade glacier
#

and the sun is now down?

graceful zephyr
#

or one of them, or parts of them

stray scroll
#

My news source says it landed 19.10 from a source of Reuters

graceful zephyr
#

@stray scroll oh, my source said planned landing is 19.30 πŸ˜„

#

Β―_(ツ)_/Β―

jade glacier
#

ah, PART of the landing gear

#

looked like a pretty clean landing

graceful zephyr
#

oh its alraedy landed? swedish news is out of date then

stray scroll
#

I checked dn.se πŸ˜› @graceful zephyr

jade glacier
#

I just watched the vid on independent

graceful zephyr
#

you swedish?

stray scroll
#

Yea

graceful zephyr
#

had no idea

jade glacier
#

Fucking swedes are taking over

gleaming prawn
#

No front landing gear is normally easier

#

In tricicles, of course

graceful zephyr
#

@stray scroll which part of sweden?

stray scroll
#

Sadly couldn't attend the Meetup at Game Habitat, just moved to Spelkollektivet

jade glacier
#

The landing gear seemed to be intact anyway, just something came off of it and that hit the engine

graceful zephyr
#

@stray scroll oh you moved in there?

#

ur not "that" far away from me

#

like 200km i think

stray scroll
#

Yeah, previously lived in Karlskrona, but now staying for a year at least. Ah, what city?

graceful zephyr
#

i live on the eastern part of vastra gotaland

#

little shit town in the middle of nowhere

gleaming prawn
#

Woodcity

graceful zephyr
#

so yeah farm country πŸ˜„

#

but i like it out here

#

if redneck music is your thing

#

gonna remove that thumbnail lol

stray scroll
#

Haha, how have I never seen these before

graceful zephyr
#

@stray scroll they have a show on SVT even, "uti byggda"

stray scroll
#

Will check it out πŸ˜› Can't say Spelkollektivet is in the middle of somewhere either, but it's cheap and dev people around^^

graceful zephyr
#

yeah i know where it is, it's really in the middle of nowhere

#

how many ppl in that town like 2000 ?

#

πŸ˜„

stray scroll
#

think like half? x)

graceful zephyr
#

lol

jade glacier
#

So is the entirely of Exit ever going to all get together an put out a playable for profit tech demo? @graceful zephyr @gleaming prawn ?

graceful zephyr
#

you mean a game?

#

dont think ever

#

but idk

jade glacier
#

Makes little real business sense

#

But would make a lot of happy devs LOL

gleaming prawn
#

Alone, no

#

We do not have any expertise in game design, meta gaming, etc

#

It's not what we do

jade glacier
#

Yeah, that would be the catch. Would require a lot of non-networking peeps

gleaming prawn
#

Yep

jade glacier
#

Seems more like it would take a joint venture with some indy group good at everything but netcode.... but then it just becomes a distraction.

#

However, the upside if done correctly is massive - per titles like Fortnite. But the risk is also pretty high for all that distraction.

#

And a hard case to make to any indy group, because they already get the Exit tech at a reasonable price... why give up ownership for the tech they already have access to.

weak plinth
#

fholm should try make quantum for unreal, if its good enough tim sweeney will buy him an island

#

better then making games

jade glacier
#

I dont think Unreal has a good deterministic engine. I would expect an eventual UE release of Quantum

graceful zephyr
#

@weak plinth lol

gleaming prawn
#

Does this island help with solving entity traversals?

#

If not, I bet Fredrik will pass

graceful zephyr
#

@gleaming prawn too much of an internal joke lol

gleaming prawn
#

Yes

high night
#

I implemented this:

client    -> inputs  ->   server buffer (waits) -> server    (10hz)
client     <- state  <-                            server    (10hz)

When client recieves a new state, checks if its newer than latest state and replaces (i didn't think a buffer is needed here?)

#

.
But i've been thinking about this example:

In a realtime fps game: 
- clientA clicks and shoots one bullet
- server recieves multiple inputs in last tick, simulates, sends state
- on clientB, in the recieved state, input of clientA shows that clientA didn't click that frame
- either clientB doesn't render gunshot effects or some spagetti code has to be implemented to render the gunshot effect

How would you know when and where to spawn the gunshot effect?

jade glacier
#

That sounds like you are using an unnumbered Queue for your buffers

#

you will want a ring buffer or some way to number those if you aren't

#

Only glancing at your block of text, but it implies you aren't strictly controlling your ticks

#

whatever exact inputs you use on the server, you use locally

#

applied in the exact same way

high night
#

queue holds inputs with their time values
server gets inputs at time = t uses them, dequeues them
t is a frame in the past

#

..

whatever exact inputs you use on the server, you use locally applied in the exact same way
yes

jade glacier
#

No idea what t is in this context

#

but you will be dealing with the players history

#

The servers timeframe is the only true timeframe

#

and players will have to correct if the server comes up with a different result

high night
#

server runs a scene at T, everybody tries to render T + 10frames

jade glacier
#

That's a bit nebulous what that means sorry

high night
#

that 10 frames of delay is when the server gets to pick up all the inputs players sent

jade glacier
#

I keep having to guess what people mean in here, and I keep guessing wrong

#

so unless I fully understand the question, I'm going to avoid answering

#

Players should simulate with whatever tick makes sense based on their buffer size

high night
#

Server does not immidently act when its recieved an input,
I made pretty much sure of this:
Clients local simulation will be the same as servers* simulation

jade glacier
#

They can tell the server which server tick they were using as the world around them

#

But that is mostly just so the server can send back its state results using the same numbering

#

Server does not immidently act when its recieved an input, That is correct yeah - you want that buffer

#

The clients simulate with whatever tick... it doesn't actually matter

high night
#

i do have that buffer, but though different means to what you are thinking i'm guessing

jade glacier
#

Are you rewinding shots on the server or doing any server resim?

high night
#

thats the only such buffer i have and its on server when recieving inputs

jade glacier
#

If the server is doing no rewind, then it doesn't care what timeframe each player is in

high night
#

if we are not talking about predictions and whats displayed on the screen,
server does not roll back and resim

jade glacier
#

It just pulls inputs from the buffer and lets players know its results

high night
#

yes

jade glacier
#

You will want some way to sort out on the player which frame the server was using for that player

high night
#

umm

#

players send inputs with frame number attached

#

server state also is sent with frame number

jade glacier
#

yeah, then the server just needs to attach that number to the returning state sent to the player

high night
#

nobody is lost in time

#
In a realtime fps game: 
- clientA clicks and shoots one bullet
- server recieves multiple inputs in last tick, simulates, sends state
- on clientB, in the recieved state, input of clientA shows that clientA didn't click that frame
- either clientB doesn't render gunshot effects or some spagetti code has to be implemented to render the gunshot effect

So, do you render that gunshot or leave it be?

jade glacier
#

Unless you are trying to sync inputs to all, you would just go with whatever the state is from the server

#

since that is the only actual "fact"

#

I don't get on clientB, in the recieved state, input of clientA shows that clientA didn't click that frame

#

why is there an input in the state?

#

inputs are inputs... states are states

high night
#

its a single input

jade glacier
#

input = cause
state = results

high night
#

1 frame input

jade glacier
#

Your server state should reflect that the gun is firing that tick

high night
#

i serialized current inputs of characters in the state

jade glacier
#

Sounds like a path to hell

high night
#

ah, tick based approach

jade glacier
#

you should pick a lane... you are using inputs... or you are using states for server -> clients

#

you can do hybrid stuff, but it gets a bit advanced - and should be for good reason

#

just serialize the weapon with a 1 bit bool. ( assuming you are bitpacking) that indicates "Fired"

#

or like a byte, if you subdivide your net ticks, to indicate which which subdivisions bullets fired on

high night
#

if i send a state for every 5 frames, i have to look at each frame if gun had Fired==true?

jade glacier
#

Then you may want to subdivide things that need to be subdivided

#

like use a byte as a bitmask with each bit indicating which subtick you actually fired on

#

I still think you keep trying to outsmart yourself here

high night
#

[from server] maybe i could send something like these each tick instead of sending state

inputs0, inputs1, inputs2, inputs3, inputs4, state0 tick 0

inputs5, inputs6, inputs7, inputs8, inputs9, state1 tick 1

jade glacier
#

all of these attempts at saving data are adding layers of difficulty in getting a basic working starting point

#

Why are you sending inputs to all clients?

high night
#

nevermind that

#

its already working, i have the base point you said i should have first

#

just no graphics and game build on it

#

Why are you sending inputs to all clients?
@jade glacier
because in those frames there will be the information when the client fired its gun

jade glacier
#

Which again... is blurring the lines between input and state

high night
#

.
projectile will be replaced with new info in server state just after all these because projectile is going to be something that gets to be in the state
but gunshot effects, knockback effects, everything will be there
while otherwise they would require spagetti

jade glacier
#

I wouldn't recommend that, you are starting to make spagetti before you even have a working engine

#

I'm not sure what the question is at this point?

#

How do you go about making a complex mix of inputs/states and skipped transfers? With a lot of tangled code.

high night
#

[inputs since last sent state] + [state] 10hz sent by server

jade glacier
#

State should be the only real information, it is the complete result of the last simulation

#

be it in one memory block, or scattered across components in ring buffers

high night
#

yes

#

but i don't want to include visual effects in that

jade glacier
#

Nor should you

#

effects are the results of the state

#

if the state inidates "I fired my gun", then the effects responds to that state

#

A trigger pull is not a state

#

it is an input... it may or may not result in a fire event

#

the packet may get lost, the gun may be out of ammo, the player may be dead before it fires

#

the input itself is meaningless

#

The gun firing is a state

high night
#

Can you suggest me any source code to read a little bit that does these stuff?

#

Creating states that can serialize these instant events

jade glacier
#

No source code I know of, but there are lots of videos and pages on the topic

high night
#

Particularly interested in how a character serializes

jade glacier
#

you serialize the transforms and the animator mainly

#

For the serializaton stuff you can look at the stuff I am doing for PUN2 with SNS

high night
#

from where does the information that "a fire effect should start" gets in the state?

jade glacier
#

Added a link to the pre-beta to the doc as well

#

main code of interest there would be in SyncTransform and SyncAnimator @high night

#

Keep in mind that is NOT server authority code. That is all client to all state transfer

#

But the serialization of the states are the same as they would be for server auth

#

from where does the information that "a fire effect should start" gets in the state? When you consume the state that has the flag for "This gun fired"

#

Or more accurately, when you finish the interpolation of that state

#

If you want your shots to line up correctly with the shooter

#

And in the case where you have subframe ticks, when that subdivision tick occurs

high night
#

public class SceneController : ISerializable
{
    public int sceneTime;
    public int sceneIndex;
    public Scene scene;
    public PhysicsScene physicsScene;
    public SyncedObject[] syncedObjects;
    
    public SceneController(Scene scene, int sceneIndex){}

    public void ApplyInputs(List<InputWrapper> inputs){} // inputs objects in the scene at scene time passed in
    public void UpdateScene(float deltaTime){}    
    public void Serialize(BinaryWriter writer){}  // write self into stream
    public void Initialize(BinaryReader reader){} // read stream, become that state
}

Control flow in a scene flows trough this class
4 methods control everything, publics are only for read
Initialize and Serialize calls Initialize and serialize on scene objects.

#

.
SceneController.Initialize creates a state at current "sceneTime" of that scene

#
public class Character : MonoBehaviour, ISerializable, IExternallyUpdates ,ITakesInput
{
    CharacterInput input; // in here trigger holding info is stored for current frame
    public float health;
    float maxHealth = 100;

    public void Initialize(BinaryReader reader) // called from SceneController.Initialize
    {
        input = new CharacterInput();
        input.Initialize(reader);
        health = reader.ReadSingle();
    }
    public void Serialize(BinaryWriter writer) // called from SceneController.Serialize
    {
        input.Serialize(writer);
        writer.Write(health);
    }
    
    public void TakeInput(BinaryReader reader) // called from SceneController.ApplyInputs
    {
        input.Initialize(reader);
    }

    public void SyncedUpdate(float deltaTime) // called from SceneController.UpdateScene
    {
        health += 1 * deltaTime * 50;

        Vector3 movementVec = input.GetMovementVector();
        movementVec.y = movementVec.z;
        movementVec.z = 0;
        GetComponent<Rigidbody>().velocity = movementVec * 250f * deltaTime;

        inputvec = movementVec;
    }
}
jade glacier
#

Not sure what the question is?

high night
#

You see how state can only store what happens in one frame?
And I try to use 1 state to recreate what happened 5 frames

jade glacier
#

You will need to create masks/arrays or whatever if you want your frame to represent tick subdivisions

#

What timing does your gun actually fire on?

high night
#

CharacterInput.shoot : bool ?

jade glacier
#

and the gun is likely going to need to be its own serializable thing, unless the gun is a permanent part of the player

high night
#

think of it as permanent

jade glacier
#

or in this cast BitArray or something if you are subdividing

#

How is the actual gun fire initiated though

#

typically that will be on the tick

#

or a Fixed or whatever your sim timing is

#

your state result will contain weapon for for that tick, or some subdivision

#

you then would deal with that in your interpolation/snapshot code

#

if all weapons fire on the tick, then just when you hit the end of interpolation (when you pull a new frame, you execute the events in the state of the previous target frame)

#

snapshot interp involves always having two frames you are interpolating between in Update()

#

And you consume new ones in Fixed

high night
#

if all weapons fire on the tick, then just when you hit the end of interpolation (when you pull a new frame, you execute the events in the state of the previous target frame)
@jade glacier
I think what you are saying is essentially what i was saying here:

inputs0, inputs1, inputs2, inputs3, inputs4, state0    tick 0

inputs5, inputs6, inputs7, inputs8, inputs9, state1    tick 1

Except i called "input" to some of the data you call "state"

jade glacier
#

as long as those aren't just a copy of the player input structs

#

because those aren't confirmed weapon fire, they are player "requests" to fire

high night
#

its like a character state, but i call it input
character.firing = true

on client;
client can set character.firing true, can send it to server

on server;
server simulates, character doesn't shoot because out of bullets
sends out state that contains the info that character can't shoot and still tries to shoot (character.shooting = true)

#

.
I think it will be fine

jade glacier
#

I would avoid using that term then, because that's going to confuse anyone you are talking to.

#

Inputs are inputs, states are states

high night
#

so clients directly set states* in your terminology

jade glacier
#

If it came out of the simulation... its a state

high night
#

states i mean

jade glacier
#

They are just states then. You just have subdivisions

high night
#

probably a character stores a movement vector where its walking now
you call that state

and its owner client can directly set it

#

and send to server?

#

.
What do you exactly call inputs?

#

The information that client sends server most likely

#

.
in my case it's
Character.input
which contains
bool shooting;
Vector3 movement;
Vector3 look;

#

.
and i also have that as a state

#

these values are used for extrapolation too

jade glacier
#

That's sounding a bit more like player authority

#

unless you mean on the server

#

you can store your state as whatever you are making use of

high night
jade glacier
#

where is that from? No clue what they are trying to say there

#

move vector I think they are referring to the asdw inputs

#

look you generally take from the client at face value, no point trying to treat that as a regular input

high night
#

and this is the thing i believe will fix my issue
and also believe is pretty much same as your solution

#

i made this on paint

#

.
look is where client is facing, moveVector is ASDW

#

its not actually a vector though

#

its a get/setter that controls bools

#

.
@jade glacier
if you remove the text "inputs" from this second picture
i believe it becomes what you were telling me

#

that bitmask / subdivision stuff

jade glacier
#

Depends, it might also just be saying it sends the 5 previous inputs

#

to make it loss resistant

#

for UDP its standard to send a short history in case a packet got lost

high night
#

nah not about loss resistancy

jade glacier
#

inputs are usually pretty tiny, since each input is 1 bit

high night
#

i mean if this is what server sends at 10 hz

and clients send the blue box at 10 hz

all the information needed will be recieved

#

.
everybody will be able to reliably recreate what happened every tick (including gunshot effects that you don't serialize)

#

every 5 frames

#

if deteminancy doesnt break in 5 frames
even if it brakes, important stuff are included in state

jade glacier
#

Give it a shot

graceful zephyr
weak plinth
#

you have a special gift fholm, too bad quantum is out of reach for most devs, must be fascinating source code

graceful zephyr
#

@weak plinth thanks... do note that i didnt build the FPS, obv i built a substantial part of quantum itself, but FPS done by two colleagues of mine

jade glacier
#

I wouldn't say Quantum is out of reach of most devs. The monthly pricing is way less than any team would end up paying for a developer to build and maintain their own custom netcode.

It's just out of reach of hobbyists who aren't trying to make an actual product or have any kind of business plan or expectations of actual paying users. It eliminates the need for what most people in the networking channels are doing, which is spending months to years trying to create a working mp game and become proficient at making networking themselves.

round yarrow
#

@weak plinth you can try quantum one month for free just chat with the photon team, maybe you get access. So you can study the fascinating source code aswell πŸ™‚

jade glacier
#

I am one of those people, and I only keep doing dev work because I happen to be making some stuff for Exit now as well. But if I make my own game, I will be using Quantum for it if the architecture makes sense.

round yarrow
#

I think the problem Quantum has is quite simple.
It's a marketing problem. The technology is fascinating and should be presented to a similar extent on youtube and co.

Only gameplay is not enough to see what is going on under the hood.
A good way would be a playable demo were you can simulate the network delay ... that would be fun to watch :)
And cats πŸ˜›

graceful zephyr
#

@round yarrow We've purposefully kept it as a premium product, and we're already drowning in requests so πŸ™‚

weak plinth
#

@jade glacier most of unity base are hobbyists, indie, none AAA, so its would be better for exitgames if this premium asset was in unreal engine where the top dogs are if that's where they going with it

graceful zephyr
#

not that easy πŸ™‚

jade glacier
#

Most of the Unity base if they want to do networking need to learn finances to be honest

weak plinth
#

must be dreaming the day they will add C#

jade glacier
#

you can make a hobbyist SP game and stick it on a store and move on. MP games require constant cashflow, as they have constant costs. MP and Hobby don't play well together.

#

I mean, nothing wrong with building hobbyist net games, just for the point of pride

weak plinth
#

thats unity's problem for not providing the netcode they need, but the base expect everything out of the box

jade glacier
#

But the model isn't conducive to zero cash projects in ANY way.

#

Unity isn't really about hobbyists. They make their engine accessible to hobbyists as a money loser in the hopes that a percentage of those devs come up with a winner and become paying studios.

#

And they REALLY are banking on the asset store

graceful zephyr
#

quantum and unitys netcode solve two different problems tho

#

also, one being ready and used in production the other... not, well.. different problem

jade glacier
#

Unity wants networking in the engine so they can check off a box for their IPO imo

weak plinth
#

doesn't make sense why they do subscription model if that the case

jade glacier
#

Not because there is some glorious future in making a generic networking component for Unity

#

ECS once done, can and should make networking problems easier

graceful zephyr
#

they are betting hard on dedicated server hosting because it will make them money

jade glacier
#

But they are trying to solve networking problems on a moving target

graceful zephyr
#

which is why its the 1st one they went for

jade glacier
#

I suspect the only one they could sell as not being a massive waste of time yeah

graceful zephyr
#

they own multiplay, multiplay hosting unity games with 1 button click means people will use it and pay for it, etc.

jade glacier
#

They are going to get lapped (and are being lapped) by independents like Exit

weak plinth
#

good luck with that

#

how many years they build ecs ?

graceful zephyr
#

3 (?) so far

jade glacier
#

The concept of what they are doing is fine on paper IMO

weak plinth
#

its another engine within an engine

jade glacier
#

but the whole netcode thing is now tied to DOTS development, so they are stuck in the slow lane while that gets unborked

#

Meanwhile, you can pay like $1000 a mo or whatever Quantum goes for now and have a working title out before the end of the year.

graceful zephyr
#

additional benefit you dont actually need to write any networking code for it to work in multiplayer...

#

it's not a small benefit

jade glacier
#

Its massive

graceful zephyr
#

build a split-screen game which works online automatically

jade glacier
#

I have been writing networking code for like 4 years now, and I would still drop it all overnight and use Quantum for any actual products I planned to make for real.

weak plinth
#

i'm afraid the ecs stuff won't take off.. less then 1% of devs uses it ? they will add shiny new features only with support for it

#

and just leave the rest of the engine dying like a dog

graceful zephyr
#

pretty much what they are doing atm

weak plinth
#

and you know it won't work

graceful zephyr
#

i mean the ECS stuff will probably 'work' in the end

#

but it's like... they took it one step too far with the performance by default, burst, etc. IMHO

jade glacier
#

that is why there is a lot of talk among devs about Unity likely having seriously borked itself for a long time to come

weak plinth
#

in 6-8 years ?

graceful zephyr
#

performance in ECS is not good without Burst

#

And you cant make all code 'burstable'

#

debugging 'burst' code is horrible, etc.

#

yes performance in ECS w/o burst is better than MonoBehaviour, sure

#

but that's not a high bar

jade glacier
#

And meanwhile all of the low hanging fruit fixes that could be done to make MonoBs better are off the table.

weak plinth
#

i've stopped looking at examples they put my pc to crawl

graceful zephyr
#

i've mostly given up because it's constantly being sold 'as the next big thing that's ready', but whe you go to use it and build stuff

#

you keep running into "oh this isnt ready", "oh this is broken", "oh this package is incompatbile with this other package", etc.

#

so I just gave up

weak plinth
#

if they spent the money on converting to .net standard it would be much better, no need to use dod for everything

jade glacier
#

I can't even imagine trying to write an networking asset for the store based on any of it

#

Which means the asset store is going to be fragmented

weak plinth
#

any ecs assets at all in the store ?

graceful zephyr
#

unity 2019.3 is .net standard 2.0 by default

#

.net core tho, that's different

weak plinth
#

thats what i meant

#

get rid of mono

graceful zephyr
#

mono/il2cpp need to die, its so much work dealing with them

#

there are rumors floating around

#

about them moving to .NET 5

#

eventually

weak plinth
#

if any worker left not working on dots stuff

graceful zephyr
#

lol

jade glacier
#

I would not want to be working there

weak plinth
#

its open space office

#

the worst kind πŸ™‚

jade glacier
#

the chaos right now when it comes to feature expectations and promises vs the fractured state of the engine, it must be like more meetings than coding trying to decide on how to proceed with most things?

weak plinth
#

every package update destroys another package, so its obvious there is chaos

#

i think this man said it best

jade glacier
#

ooh, hope that turns into a popcorn twitter war

#

LOL at the two replies

steep wolf
#

yeah lmao I noticed

weak plinth
#

he is smart as fuck, don't know what they can answer to that

jade glacier
#

"I make an engine... no one is asking for that shit"

weak plinth
#

lol

stray scroll
#

Talking ECS or DOD?

graceful zephyr
#

ECS specifically

#

fwiw i agree with Sweeney here

jade glacier
#

Its some pretty good shade

graceful zephyr
#

also FWIW i have built a system which ensure full thread safety without the programmer having to do anything, and every entity having access to all state of every other entity, etc concurrently

#

using it for my prototype MMO backend

#

it doesn't require explicit threading via jobs or similar, everything is automatically run in parallel

weak plinth
#

amazing

jade glacier
#

That would be a useful part of the engine πŸ˜›

weak plinth
#

also state it doesn't require crazy packages

graceful zephyr
#

this is not for quantum tho

#

this is for a backend for an MMO im working on privately

weak plinth
#

sounds it came long way since slimnet days

graceful zephyr
#

lol yes

#

thats almost a decade ago

#

goal is 20k Players and 512k NPCs in a shared world on one machine

#

.net core 3.1, server is not in unity

weak plinth
#

🀯

graceful zephyr
#

30hz update rate

weak plinth
#

a thing like that eliminate spatitalos's business model

graceful zephyr
#

so far all tests have worked out

#

can have 20k simulated players moving around in a full world with their CCD character controllers in ~1.7ms

#

also simple interactions with NPCs like shooting 'bullets' at them and shit for now

weak plinth
#

making a game or selling to photon ?

graceful zephyr
#

i don't make games, i make tech and sell to people

#

it uses a custom 'physics' engine i made also, and such

#

all 100% multi threaded, without any locks, semaphores, etc. and just a few interlocks (5 total interlocks per thread per update)

weak plinth
#

thats better then wobes network sample with 5k moving players

#

will be fun to watch videos of tests

graceful zephyr
#

wobes is a nice guy, we talked a lot πŸ™‚

#

or well, talk a lot

weak plinth
#

saw that thread, seems smart

graceful zephyr
#

oh no i mean discord πŸ™‚

weak plinth
#

must be crazy talks in private

graceful zephyr
#

we have a discord server that a lot of networking coders hang in

weak plinth
#

really there are few people in unity community who are very talented, unity should have drop money on you guys to fix their stuff, even only in a form of c# packages

graceful zephyr
#

Β―_(ツ)_/Β―

#

unity has plenty of talent internally

weak plinth
#

yea i see that

#

btw how many messages per second does 20k players has ?

graceful zephyr
#

600k in/out, combined 1.2 million per second

weak plinth
#

mind boggling

graceful zephyr
#

goal is to do 600k in on one core, and 600k out on another core

#

so reserve 2 cores for the sockets

#

but not fully decided on all here atm, current work target is the socket layer

weak plinth
#

@jade glacier I'm sorry to bother you again, but how do you update your ghost scene when a player joins or leaves ?

jade glacier
#

I have a component I put on objects that should have lightweight copies that ties them to their ghost counterpart

#

When that "Haunted" component awakes on the object in the main scene, it handles telling the ghost scene to make a lite copy of itself.

#

And when it gets destroyed tells the ghostworld to destroy its ghost

weak plinth
#

oh nice

jade glacier
#

you can look at the code for it in my PUN2 stuff

weak plinth
#

and then you perform rewinds on your ghost world?

jade glacier
#

This one currently does nothing, its there for future use. In the past I have used it for server rewinds as well as prediction resims on clients

weak plinth
#

I came up with a DOTs type solution, but it doesnt handle player player collisions with lag compensation

jade glacier
#

This is all MonoB and PhysX based

weak plinth
#

I was afraid a full resim for every fire event, or player-player collision would be computationally expensive

#

but your solution also allows for simulating slow projectiles into the future

jade glacier
weak plinth
#

amazing, thank you so much

jade glacier
#

For my previous work, server rewind only involved the player shooting, and any players it claimed it hit

weak plinth
#

and sorry for all of the questions, I'm slowly figuring this out

#

hopefully I can return the kindness some time

jade glacier
#

It was a little extra data to have the client send the ID of the person it claimed to hit, but made the server work a lot less since it knew exactly what to rewind

weak plinth
#

nice

jade glacier
#

Its very likely those files will have dependencies on my networking, so I doubt they will just work without producing a wall of errors on import.

gray pond