#archived-networking

1 messages · Page 55 of 1

final depot
#

In complex enough games with an expansive amount of state per player, or very tight latency requirements, you really don't want an authoritative server.

#

RTS and Fighting games for example absolutely tank if you use a client-server architecture

misty shale
#

Yeah true that. I’m thinking authoritative in terms of reward distribution and in game soft currency purchases

#

This would be for a mobile card battler game

final depot
#

If it's turn based, you can easily get away with server authoritative

misty shale
#

I guess these games use web services rather than a client

final depot
#

It actually wouldn't be that hard to set up a HTTP server to handle it, yes.

#

Or just plain websockets.

#

Backed by a in-memory database like Redis

misty shale
#

Not turn based no but I could do a submit each time the player beats a level to see if it’s technically feasible

#

And then dish out rewards

final depot
#

Oh if that's the case, a HTTP server is more than enough

misty shale
#

Don’t really care how you kill the enemies etc

#

Yep sounds reasonable

final depot
#

Only thing you might need to do is check for is the validity of the player's claims

misty shale
#

Are the cool kids using node.js these days? Been a while since I did backend coding

final depot
#

So that if someone finds the endpoint, they can't just spam it to get the rewards

misty shale
#

Yep, I can check some basic stats to ensure it’s valid

final depot
#

Personally, I mostly do Python and Elixir

misty shale
#

Ooh yes Elixir is supposed to be nice

final depot
#

Elixir tends to be better for soft-realtime commuications

misty shale
#

Gotta run now sorry, would love to get more details

#

Maybe next time!

final depot
#

Alternatively, if you have money: Firebase

#

It's even easier since they have a Unity plugin

#

Don't even need to consider the hosting at that point

misty shale
#

Oh interesting, what does the plugin do?

final depot
#

DM me later for more info

misty shale
#

Will do thanks!

final depot
#

But a gist: It's a cloud based service backend as a service. No servers, just a plain API to hit.

#

It's sort of weird: public facing database with security rules editable directly from clients

misty shale
#

Like Parse? (RIP)

final depot
#

You just hook up clients to the database

#

And it uses Google Cloud Functions as a way to add compute on top of that storage

#

it's realtime so it should fit game needs

weak plinth
#

Websockets are p good

hollow aspen
#

I'm using WebGL and Addressables. I have SD textures on a model by default and when the game first loads, it loads HD textures and applies them to the model. Here's by bug. When the Addressable Asset is first loaded, it applies black textures to the model. If the Addressable Asset is cached, then the LoadAssetAsync call results in a error.

#

Any thoughts as to (1) why the texture from an AssetBundle is black and (2) why I get a UnityEngine.AddressableAssets.Initialization.InitializationOperation error upon subsequent loads?

barren pebble
#

Are the cool kids using node.js
would totally go for that

#

super easy to set something up with express and node.js

#

if you also use mongodb, thats totally enough and very fast and easy to setup for a prototype @misty shale

misty shale
#

I have no experience with Node, would love to get going but no idea where to start

#

I’ll also take a look at mongodb

#

Thanks @barren pebble

versed cliff
#

does anyone have any recommendations for a tutorial series on setting up a dedicated game server for a simple rts game? Apparently Unity is reworking their networking thing and there's a lot of outdated videos, so I'm not sure where to start

foggy vale
#

@versed cliff got the same problem.... I'm also wondering where to start hosting a custom made multiplayer server

versed cliff
#

yeah it's extremely complicated @foggy vale I've been looking into Nakama but I'm still not sure where to start

foggy vale
#

@versed cliff lot of money the nakama... I'm looking for a service similar to the unity hosting, free for small number of players... but that doesnt force me like unity to use UNET

versed cliff
#

apparently unet is going to be phased out though if I'm understanding right

#

so maybe playfab might be the way to go

exotic valve
#

Is it best to have each player determine animations for other players to calculate based on their velocity, or just have the client post their animator state to be replicated

gleaming fossil
#

are there any reliable character controllers that are available currently? Would love a non-DOTS controller that works with 2019.2+. All of my client side predictions end up correcting to the server position, depending on how long you run around and the complexity of the colliders in the scene

burnt axle
#

How do you manage the player prefab when using a lobby manager and network manager? They both have slots for player prefabs and the lobby manager runs in the background through all scenes. Im unsure of you are supposed to choose on over the other or use both.

misty shale
#

So I’m thinking about how I’d implement an authoritative inventory / upgrades server using a http server and DOTS. I’m thinking that I’ll have a system which periodically pings the server to query the inventory data on the server and download the data in a format such as .json.

I’d then parse the data and for each item in the json create an entity with an item component with the appropriate data set.

All client would ever do would read this local entity data and display UI based upon it.

Any time the game wants to add / remove / upgrade an item to the players inventory it would happen via a script on the server editing the player’s profile data on the server and then get pushed to the client as above.

Sound logical? Is there a different way to do this? One thing that scares me with this approach is keeping the data in sync. I’m thinking:

  • By default update data every x seconds
  • Forced update on player actions such as buying new items
  • On update delete all entities and create them from the latest data. This worries me in terms of performance / redundancy (most items shouldn’t change very often) but it’s the simplest and most synchronized way I can think of
#

Thoughts appreciated!

jade glacier
#

Seems needlessly complicated unless your inventory actually is tied to a different location than your game logic. But typically the server knows what you have, and anything clients try to do involving that inventory are subject to the server not acknowledging as having happened

#

The most typical is to put everything into your simulation, and then you just sync any of that like all other data, using delta frames and normal serialization

#

JSON is bloated and human readable

misty shale
#

So you mean just serealizing all of the inventory data and syncing it?

#

Doesn’t that make it vulnerable to cheating?

#

Like say if this was Hearthstone and players were able to trick the client into thinking they have certain cards that they don’t. They’ll then be pushed to the server, right?

jade glacier
#

JSON vs any other method doesn't matter, what matters if what clients are trusted with

#

if the server knows what everyone has, and only responds to player inputs, it won't allow anything illegal

#

hearthstone is a cardgame, so thats even more basic

#

but JSON and server auth are totally separate convos

#

JSON is a verbose way of serializing stuff, that is WAY bloated for a game

misty shale
#

Oh I think I misunderstood what you said

#

So just use unity serialization with DOTS and deltas and then let the player only officially talk to the server?

jade glacier
#

I mean, there is no way I am going to explain the entirety of how you achieve eventual consistency with networking typing here

#

but the idea is that you create a simulation and that simulation consumes a previous state and inputs, to produce a new state. You serialize the state and the inputs.

#

If you get buried in the woods of how to "send inventory" you are already down an ugly path

#

You can sloppily sync things like inventory adhoc, but you will start to run into some serious order of exec and race condition snafus

#

So typically you want to start with your simulation, and then once that basically is working, you start thinking about how to tie the various inputs and state items involved (like inventory) to that.

misty shale
#

Ok thanks for the tips! Ok ultra new to networking so I’m happy to find better ways of doing things I didn’t know about

#

Haven’t thought about doing a state simulation with a http server. TBH I thought this model only applied to games like FPS

jade glacier
#

simulation makes all game types sane

misty shale
#

Yeah just wasn’t anticipating using a constant connection to the server - will also need to figure out persistence with this model. My approach was more based on web services I guess. Will do more digging, thanks!

jade glacier
#

If this is stateless it makes things pretty easy, bit its still all basically a series of states

versed cliff
#

would a simple RTS game be better off using peer-to-peer system or an authoritative server system?

#

Because peer-to-peer can be hackable but authoritative server can cause latency issues if I'm understanding this right

misty shale
#

Peer to peer could have just as much latency depending on where they are, no?

final depot
#

@misty shale @versed cliff

RTS generally has too much state to send authoritatively. I advise a peer to peer deterministic lockstep model.

#

In such a model, everyone only sends inputs to each other

#

And every peer is responsible for their own state

jade glacier
#

Though even with determinism you still will have an authority, that authority just is the final word on what the inputs were, unless you are doing like a lockstep

final depot
#

This makes a strong assumption that your simulation steps are purely deterministic

#

If you have a client who is lying about their inputs, it only causes them to desync

#

There's no need for anyone to authoritatively establish inputs

jade glacier
#

If you are deterministic you want that

#

again, unless you are doing a locksteppy thing, but that requires either a relay or a server... which still... you have a server

#

pure p2p is not something I would ever recommend

final depot
#

How would lockstep require a relay or a server?

#

If a local client has all inputs for a frame for all remote clients

jade glacier
#

Depends if this RTS needs to keep on trucking

#

if a packet gets lost, there has to be a reconcilliation

final depot
#

It is by definition in lockstep

jade glacier
#

we talking just 2 players here?

final depot
#

Potentially more

versed cliff
#

let's say it was a 2v2 rts game

jade glacier
#

That is fine with 2 players.. one player decides to give bullshit and it just ends the game

#

16 players and one player starts spewing bullshit... the whole thing goes into lockdown

final depot
#

How would it be bullshit? The only thing that is sent is inputs

#

You don't send state, so there is no way to fake or hack

jade glacier
#

If I lost a packet from player B and my determinism needs to know what that input was to continue....

#

Until they get that to me, everything is in limbo

final depot
#

This is a case where reliable sending is indeed required

jade glacier
#

yeah, but again... how do you proceed if you stop getting updates from one of the players?

#

without an auth server to say "just run with this"... everything stops

#

That is how Quantum deals with it as I know it. The server is the input authority

#

if someone fails to send in time, the server will extrapolate the input and give that to everyone.. and that becomes the input - and the player that was losing packets needs to resim

#

without that, you have a true oldschool lockstep

final depot
#

In such a game, a disconnect is indeed fatal to the game state

#

You would just kill the entire match

jade glacier
#

which is not so friendly to more than 2 players

final depot
#

Admittedly yes, but it's not something most RTS games will have a reasonable fallback for

jade glacier
#

We are making massive guesses about his game at this point

versed cliff
#

this seems extremely complicated. I'm new to game networking 😓

jade glacier
#

networking is the most complicated part of game dev

final depot
#

And they did at it's 2 player

jade glacier
#

Start simple

#

People think I am joking when I say "Go make Pong"

#

but pong is brutal to do well

misty shale
#

@jade glacier been thinking some more about my need for an authorities inventory service. Still not entirely convinced that I should be doing a full simulation on the server given that it only needs to act as a data store and persist items between sessions

#

Authoritative*

jade glacier
#

you don't have to, but the more you go adhoc, the more hell is waiting for you down the line

#

There are no hard rules in coding. Just best practices.

#

ignore them at your own risk

#

networking + adhoc mixing of simulation and messaging = tangled race condition hell

#

If you just want to get in and make a mess and have some fun, go use Mirror and hit it with synclists and syncdictionaries

#

You will eventually hit a hard wall, but you will learn a lot in the process

#

If you have a data store, you can backup to that

#

but the simulation is not going to want those values to just be changing unexpectly out of turn

versed cliff
#

So if I understand this right, in a 2v2 peer-to-peer RTS game, everyone is sending their inputs to each other and essentially simulating the game on their own machine. One player is the host and if there's any discrepancies they will sync to what gamestate he has?

misty shale
#

I feel like there’s an assumption on your end that using a database and websocket connection is wrong, but plenty of games (e.g. Destiny) do this

final depot
#

@jade glacier wait, so you would advise against P2P even in games with very tight latency requirements?

#

I've been working on a low latency fighting game

jade glacier
#

Testing for the out of sync will also be on you, you will have to run checksums and such to detect that or else the game will just get bizarre as hell for players @versed cliff

final depot
#

and the GGPO style of rollback/frame delay with P2P actually decreased overall latency

#

Since there isn't a secondary hop to an authority

jade glacier
#

Depending how you define your "inputs"

final depot
#

It's strictly the player inputs. there is no exchanged state other than an initial configuration (i.e. random seed, character selection, etc.)

jade glacier
#

For someone who just said "I am new to networking"... I would NOT TOUCH pure P2P

versed cliff
#

what do you recommend I do

jade glacier
#

Make pong

final depot
#

Sure, but every game has it's requirements to fulfuill

#

And if the design doesn't meet the requirements, you're only going to be redoing previous work.

jade glacier
#

Making networked games is brutally hard, set yourself up for a few wins before doing your dream project

#

I mean, sure - he can do whatever.

final depot
#

I've gone from using UNET HLAPI to Photon to writing my own transport level library + porting GGPO

#

Learned a lot along the way, but wasted a bunch of work trying to approach the correct solution.

jade glacier
#

The HLAPIs can be nice as starting points since they get you right into serialization and such right out of the gate

versed cliff
#

Ok, I will start with the basics.

#

What do you mean pure P2P though?

jade glacier
#

But you are like 20 refactors and restarts away from making a serious networking attempt, so just set yourself up for a series of wins you can learn from

#

pure p2p means every player is talking to every other player

#

directly

#

with firewalls and such, that is a list of challenges to deal with

versed cliff
#

so authoritative server is easier to start with?

jade glacier
#

Server and Relays are easier and more standard - because you can call something the authority

#

so at least one location on the network you can call "real"

final depot
#

@versed cliff I actually suggest reading up on networking primers to understand the full stack first:
Gaffer on Games has an amazing set of informative articles on some key principles.

#

Then try experimenting with small examples like Pong, yes

jade glacier
#

Gaffer is toast now, trying to read it through archive is lame without the images

#

Just make small experiements of concepts

final depot
#

Alternatively, if you haven't started on the project yet. Try networking games with looser requirements.

jade glacier
#

They will teach you tons

final depot
#

Pong is a bit of a high note for netwokring as there is realtime state.

#

I would actually advise looking at some turn based games to at least get the grasp of sending messages or RPCs

versed cliff
jade glacier
#

Pong is tricky because you have to deal with an object that is constantly changing time references. Shared objects are tricky.

#

But it does run you right smack into what you are up against with networking... how latency creates paradoxes you have to learn to hide and account for.

final depot
#

And it's more of an art than a fine science, haha

#

rollback netplay has actually requried me to completely rearchitect my game

versed cliff
#

is there a tutorial you know of on how to make pong with photon

jade glacier
#

I actually know of no good pong tutorials, because it is a real networking challenge

#

there are probably some terrible ones

versed cliff
#

you'll just have to make one then

jade glacier
#

If you are after turn based, just start with a very simple card game I would say, any library will do.

weak plinth
#

Hm

final depot
#

https://forum.unity.com/threads/hourai-networking-network-backend-agnostic-p2p-transport-library.765986/

In contrast to what was discussed yesterday: here's a project I've been hammering away on for pure P2P games.

And the associated GGPO style rollback library: https://github.com/HouraiTeahouse/Backroll

#

A DOTS compatible version is forthcoming

jade glacier
#

Do you have any demo projects that make use of it?

#

@final depot

gleaming prawn
#

This is super cool.

jade glacier
#

The main concern being that it totally is riding on top of shifting sands. But since its abstracted, it should be adaptable to other relays systems that pop up

final depot
#

@jade glacier

#

It's not merged into the main line develop branch yet, but it will be used for it

jade glacier
#

cool, when I get a bit of free time I will check it out

final depot
#

You can rip out the lower level stuff if our want to

#

There is a thin connection manager and message serialization manager built a top the lobby abstraction layer

jade glacier
#

I'm pretty much locked into doing dev work for PUN2 for the next X years at the moment, but this is interesting since its related.

final depot
#

Which is bounded by some strict restrictions

#

But it's not required to use.

#

I would actually advise it's use mostly for small scale latency sensitive games

#

So things like a fighting game with max 4 players is a perfect fit.

#

The entire idea is to build small messages that are all below MTU to avoid fragmentation to minimize packet loss and repeatedly sending redundant messages to account for unreliable networks.

#

The one problem is that it is contingent on deterministic simulation

#

And I have been working on a fixed point math library to fix some of that

#

I chose this path since I am purely developing this as a hobby and not a job

#

I don't have the personal funding to set up a server cluster

#

And Steam and Discord's relay services are free

#

And the community I am developing for is small enough that I can identify my players by name

#

So even if someone does cheat and screw with others, they'll just find themselves alone in a lobby.

jade glacier
#

I do development for Exit on PUN2, so pretty sure I can't "use it" for any of that, but others here certainly could. 🙂

final depot
#

It's a shame that Google took down their matchmaking service for Android

#

I could have integerated with theirs for mobile platforms

jade glacier
#

That really is the reason abstraction of any of this is good... nice to not have to rely on any particular service for your game to exist

final depot
#

Steam IIRC is pretty solid, Valve themselves depends on the relay network for their games, and just recently doubled down with the public release of their networking sockets API.

#

Discord, I'm not entirely sure of right now, it's still in it's infancy

gleaming prawn
#

@final depot what is your goal with this?

final depot
#

The libraries?

#

or the game?

gleaming prawn
#

Yeah.

#

Are you working on this because of a game you are writing?

#

And then just sharing because reasons?

final depot
#

The libraries are funcitonally complete as is. I don't plan on adding anything other than potentially more platforms.

#

My game is purely open osurce

#

Though it leverages closed source software

#

I see no reason not to share my code freely

gleaming prawn
#

So you do this on your spare time only?

final depot
#

yeah

#

haha

gleaming prawn
#

What do you do in the "normal" time then? Lol

#

Just curious, as another deterministic fella

#

🙂

final depot
#

Enterprise machine learning work for Google

gleaming prawn
#

West coast HQ?

final depot
#

Mountain View, CA, yes

gleaming prawn
#

Cool, been there a few times...:) Have some friends around.

#

Were you ever aware of our stuff?

final depot
#

"our stuff"?

gleaming prawn
#

Photon Quantum

final depot
#

Oh yeah I was

gleaming prawn
#

It's like "GGPO on Steroids"

final depot
#

I just didn't want to pay, no offense, haha

gleaming prawn
#

fair enough... Although there are options around that...;)

final depot
#

it's a bit more than a hobbyist can handle

gleaming prawn
#

Anyway, super cool stuff.... If you feel like discussing nitty gritty details of cross platform determinism, just shoot...:)

final depot
#

And when I started the project, it was still in early development

gleaming prawn
#

it's a bit more than a hobbyist can handle
As I said, there are ways around it...:)

#

We were always interested in teams that could build great demos, etc.

#

We hired a few of them for that reason at the time.

#

It's also nice that GGPO is now around again...

final depot
#

Yeah it was the open sourcing of it under MIT that got me to port it

gleaming prawn
#

Although that is super thin, and doesn't give you anything to help you have a determinsitic rollbackable simulation layer... Also only works for small games with normally 1v1 only (no server to manage input latency and clock)

final depot
#

Actually, I found it to work well for up to 8 players

#

Which is more than enough for me

gleaming prawn
#

With no centralized clock, in 2-3min hardrware clocks drift enough to start to become a problem

#

With short games it's fine

final depot
#

There's a time synchronization module in both the GGPO and Backroll implementaions

#

well, it's up to the developer to actually leverage that callback and actually wait

gleaming prawn
#

There are two issues:

  • clock symc
  • carthesian product of messages to distribute input around (unless you design it with one being a "host")
final depot
#

That latter is definitely a problem for large games, yes

gleaming prawn
#

well, it's up to the developer to actually leverage that callback and actually wait
for short games it's fine

#

Also a problem is: if ONE player stops/slows down, all peers suffer (unless there's an input-,anagement host)

final depot
#

But doesn't that host add an extra hop?

gleaming prawn
#

It always made me curious why GGPO got so famous, because it's the simples and less generic/complete version of this... And there's prior art thats much more complete

final depot
#

Expecially when there's a relay in between that nearly quadruples latency

gleaming prawn
#

Maybe it's just the fact that it worked SO WELL for fighting games

final depot
#

It really is that latency mitgation

gleaming prawn
#

But doesn't that host add an extra hop?
For more than 2 players, the benefits are much more important

final depot
#

That's true, I can see that

#

I am making a fighting game

#

and that latency is really important for me

gleaming prawn
#

Expecially when there's a relay in between that nearly quadruples latency
That's why we actually run the server logic on the relay...

final depot
#

most of the matches I see are 1v1 anyway

gleaming prawn
#

yeah

#

Is it LAN?

#

Anyway, you have a transport abstraction, right?

#

So you can work over steam, photon or discord, I guess

final depot
#

right now the code is tailored for use across the internet via Steam/Discord (GCP)'s backbone

gleaming prawn
#

yeah, fine

final depot
#

I need to whip up local LAN code

gleaming prawn
#

Another question, what are your plans to have a rollbackable sim layer?

final depot
#

Is photon capable of just doing message relaying?

gleaming prawn
#

Besides FP math

#

Is photon capable of just doing message relaying?
Yes, of course

final depot
#

I implemented that myself already

gleaming prawn
#

Just curious...:)

final depot
#

Like GGPO, that simulation layer is purely on the developer, not on the library's end

gleaming prawn
#

We share a lot of the ideas we use with Quantum.

#

Like GGPO, that simulation layer is purely on the developer, not on the library's end
That's one extra step we made...

final depot
#

I have a seperate layer between (Fixed)Update that runs simulations

gleaming prawn
#

There are several ways... For a fighting game, it's so tiny that even deep copies work

final depot
#

Local play is a 1:1 mapping

#

Network play injects the rollback logic

gleaming prawn
#

For the rollbacks, verified/predicted states, or ring buffer?

final depot
#

Ringbuffer of states

gleaming prawn
#

There are normally only these two variants

#

yeah

#

So, deep copy on forward sim.

#

So you have the buffer of past states down to rollback-window...

final depot
#

Right now I use the same serializer for the network messagse to create a binary blob that is managed by Backroll/GGPO

gleaming prawn
#

You PROBABLY reuse that to compute input buffers for combos (being this a fighting game)

final depot
#

It's small enough ~8KB/frame or so

#

yeah definitely

gleaming prawn
#

Got it

#

8KB the game state?

#

That looks big for a fighting game... But maybe it's a complex one...:)

final depot
#

I had to do some wonky stuff with projectiles and persistent hitboxes

#

it's a platform fighter akin to Smash Bros

gleaming prawn
#

got it

final depot
#

has a lot of extra physics state

gleaming prawn
#

Interesting

#

I had to write 2 physics engines with the same philosofy...:) lol

final depot
#

Probably need to slim that down, but it works for now

gleaming prawn
#

2D and 3D

#

But it's super fun stuff to work on... I think you understand me...:)

final depot
#

Yeah, haha

gleaming prawn
#

BTW, what did you use for FP, Q48.16?

#

or maybe smaller, being a fighting game

#

no need for big ranges

final depot
#

Q16.16 and Q0.8 for inputs

gleaming prawn
#

makes sense

#

We go with 48.16 as a general solution

final depot
#

I think we maxed out our velocities at 32k

gleaming prawn
#

Same accuracy as 16.16, bigger range, 32 bit buffer for non-overflow-checked multiplication (so, fastest possible)

final depot
#

which is the only quantity that goes above 1000 on the regular

gleaming prawn
#

we only use the extra 32 bits as buffer, so we clamp between -+16k

final depot
#

Does casting to 64 bit for division/multiplication slow things down?

#

Because that's what I'm doing right now

gleaming prawn
#

No

#

We considered doing this... But already storing directly as 64 is not that much of a problem even for beefier game states

#

Goal is always to fit game state into L2 cache

#

a single cast is still one "store" on the function stack anyway...

#

If you're like me and want to avoid even those... lol

final depot
#

What I've found hardest actually was coercing Unity's animation system to work with it all, haha

#

I still haven't found a square solution yet

gleaming prawn
#

We use 3 different approachs

final depot
#

It's a fighting game, so gameplay contingent on attacks is actually tied directly to animation positions.

gleaming prawn
#

I mean, we offer 3 ways, game developers choose what to do

#

But we're a LONG way down that route...

final depot
#

I'm using playables + a frame tick * Time.fixedDeltaTime to project something righ tnow

gleaming prawn
#

We even have FPAnimationCurves, etc

final depot
#

Oof

gleaming prawn
#

We do use playables with the more "complete" solution indeed

#

Playables is a super nice API for that prupose

final depot
#

Does your animation system completely override the transform placements?

gleaming prawn
#

Our fighting game sample also uses playables to keep the anims snapped, of course. (it was built even before we had our current set of tools)

#

Does your animation system completely override the transform placements?
That's game by game

#

We offer data driven ways for the developer to export that kind of data into determinsitic data (like FPAnimationCurves, etc)

final depot
#

That's what I'm hoping to avoid, haha

gleaming prawn
#

And we offer a mecanim exporter for state transitions

final depot
#

Excited for the DOTS Animation promises there

gleaming prawn
#

So both can be combined...

#

Excited for the DOTS Animation promises there
I like the playables API. Hope they build somthing similar in use

final depot
#

I couldn't find a way to compose hitboxes and mecanim in a reasonable way so I just wrote my own state machine composition system

gleaming prawn
#

But it's a long way until they have soething our customers will trust to use into production games...

final depot
#

It's super clunky and has a nigh unusable creative workflow right now

gleaming prawn
#

I couldn't find a way to compose hitboxes and mecanim in a reasonable way so I just wrote my own state machine composition system
Well.... You found the RIGHT way...

#

Mecanim is just... not good...:O

final depot
#

HAHA

#

Yeah, found that out early on

gleaming prawn
#

I've seen amazing custom timeline editors (from a few high profile customers)

final depot
#

I'm using Timeline right now, but it's a bit clunky to use, ended up writing my own frame data editor

#

As you can see, lots of extra custom stuff crufted on top to support this game.

gleaming prawn
#

I mean, CUSTOM

#

Not the Unity timeline

final depot
#

Ohhhh

gleaming prawn
#

Most bigger studios don't use any of the half-baked standard solutions..

final depot
#

It definitely wasn't easy, though not like there's anything that currently exists for these use cases

gleaming prawn
#

Which are fine for toy projects, small indie games, etc

final depot
#

I mean, if you have the man power to do so

gleaming prawn
#

Yeah

final depot
#

This game is literally just me coding it and a bunch of other hobbyists with spare time

gleaming prawn
#

I'm a bit aprehensive, DOTS has still a LONG way to be usable in production.

#

Not even close yet

final depot
gleaming prawn
#

But the animation is snappped to tick accurate using playables (simulation is tick accurate with synced clock to within 1ms or so)

#

The third screen is an overlap of the two clients...

#

Recorded simultaneously (both clients from the same machine, but server ping is stated)

#

So no direct connection between them (inputs go through server)

final depot
#

Interesting

#

I'll take note of this, I don't think I'm doing any in-Playables snapping

#

Only through the time state (it's a ushort that I just multiply by Time.fixedDeltaTime to get the playable time to evaluate at)

gleaming prawn
#

You can see some quick "ghosting" when there are input mispredictions, which are quickly solved

#

and the two games play almost the same pixels...

final depot
#

For input prediciton, do you just assume the last seen acknowledged input is held?

gleaming prawn
#

If you fix the anim state + anim time, you ARE snapping

final depot
#

Or do you have more complex prediction algorithms?

#

I've been considering doing some real time machine learning to learn the local player's input patterns, then using it as a sequence model to predict it on remote clients.

gleaming prawn
#

For input prediciton, do you just assume the last seen acknowledged input is held?
Either this, or DonÄt predict at all... The developer has the choice on a tick by tick basis to set a repeatable flag on/off

#

We NEVER needed to go more complex...

#

We considered exposing a prediction callback, nobody needed...

final depot
#

i.e. learn input patterns via local play, then ship the model to remote clients at match start

#

then use the model to predict inputs on remote clients

gleaming prawn
#

I doublt, really doubt, this could be better

#

Your company is giving this a different name... maybe they are researching this very topic

#

They call it "negative latency", fancy name... lol

#

it's just input prediction... so stadia can send frames ahead of time... I'm waiting to see...:)

#

Maybe they know enough about me because of the number of G homes I have, so I'll be surprised how well they can predict my button presses...:)

final depot
#

Haha, the marketing egg heads doing their worst

gleaming prawn
#

But the answer is there:

  • we either repeat, or just don`T (controlled by dev tick by tick)
#
  • never needed more than that.
#
  • in the past we had input "prediction" filling both forward and backwards... because we can receive input confirmations our of order
#

that didn't help... so we stripped it out... Just unnecessary complexity

final depot
#

I might try it if people deem the rollbacks too visually jarring

gleaming prawn
#

I might try it if people deem the rollbacks too visually jarring
you calibrate this giving them the option to play with a bit of delay... that's what GGPO does

#

What we do is give a lot of options to developer:

  • he can decide to run a bit of input delay (per client);
  • he can use a bit more interpolation (we have an error based interpolator that works super nicely for the views)
wispy glen
#

Hello. I'm trying to create a multiplayer First Person thing, and I'm just making it basic for now.

I have a FirstPersonController Prefab that spawns when you load in, but how can I make two FirstPersonControllers be able to see eachother

jade glacier
#

You have a networking library you are working with?

solar garden
#

How do you make up for lag on other clients than your simulation ? as we all have different lag how to be sure you won't lets say shoot at a past enemy position ?

gleaming prawn
#

welcome to favor the shooter mechanics...:) This is a whole topic on itself. I assume this is something like and FPS.

#

Quick answer: store a buffer of hitbox positions of every character on server... when you receive a shot command from a client, use the positions proportional to that client's ping to query hitboxes as they were in the past.

#

But this topic is super super complex... Multiplayer libraries like Photon Bolt, Source Engine or UE4 have these things built in to help you...

solar garden
#

Yeah but frop the source engine i know that they interpolate the position of the enemies now is it predicting or late interpolate is the thing i dont understand

gleaming prawn
#

Entites from other players are interpolated on your screen... Your own character is predicted/extrapolated with your local input (so you don't feel the server lag)

#

This is the general "rule" for an FPS.

solar garden
#

What do you mean by interpolated like just from the updating of the positions ?

jade glacier
#

Players see other networked objects that are in the past

#

So every clients own entities love on the future

#

The past you see arrives as ticks and gets buffered

#

And every tick, you advance what frame in those buffers is currently being consumed

#

Interpolation is to lerping from the last consumed frame to the newly consumed frame

#

So the world looks smooth and not like a slideshow

#

Net latency, buffers, and interpolation all produce latency. But when you number all of these ticks, the server can easily reconstruct the world as the player saw it

#

That is what CS does, it knows how many ticks in the future each client is existing, and rewinds the world to match what a player would have seen when firing, and then recreates the shot to verify it

solar garden
#

ok but thats on the server if everyone is in the past like i am a client shooting at someone i'll have to shoot further than the the model because of the latency + lerping righ t?

jade glacier
#

Locally you shoot at what you see

#

that is where favor the shooter comes in

#

a player's view of reality is wrong, but that is ok because this is the opposite of deterministic

#

You shoot at what you see, because the server will do the work of re-arranging the furniture to confirm your shot (IF you go that route, it is a bit expensive and not something games with lots of players do)

#

To do it, it requires your game to have pretty inexpensive physics/simulation code, since the server is going to have to constantly be rewinding and reconstructing a simulation world to test shots... so if its bullet-hell that is going to be brutal on your server asking it to verify every shot like that.

#

If you are building around PhysX, you probably don't want to go this route

#

Bigger games lean on other methods, like just testing the general plausibility of a shot, or not testing at all an just trusting the client

#

I don't know all of the methods employed, but its a pretty creative field

graceful zephyr
#

@jade glacier A for effort.

#

😄

#

that you have energy to explain this every day in here lol

jade glacier
#

I try to limit it to once a week now 🙂

#

And heya @graceful zephyr

graceful zephyr
#

hey o/

jade glacier
#

Presenting to Christof and Tobi in like an hour

graceful zephyr
#

ah best of luck

jade glacier
#

The stuffs all working, just NO idea how to present stuff online, so going to be messy using discord screen share pretty much

#

I can invite you in if you are curious at all @graceful zephyr

graceful zephyr
#

im waaay to busy

#

sorry

jade glacier
#

Another big push under way?

graceful zephyr
#

well

#

always

#

😄

jade glacier
#

No worries, no benefit to me having spectators LOL

#

I just have talked you to death about this stuff for 2 years

weak plinth
#

@jade glacier Good luck on your presentation

jade glacier
#

Thanks man

gleaming prawn
#

Lol, you should invite others...

jade glacier
#

They already know what's in it - so its not a sales pitch or anything stressful. I'm just a bit scattered on how to organize it into something that isn't painful to listen to me explain

#

Its good practice, because once its beta, I have to figure out how to explain it to users

weak plinth
jade glacier
#

Done

solar garden
#

Wait you are doing a presentation ?

#

Is it online ?

gleaming prawn
#

He was...:) yes

#

not online, top secret.

graceful zephyr
#

super mega secret

#

we have to send agents after you if you heard it

#

dial 555-FBI

#

quick

jade glacier
#

SWAT will storm in though if you do

solar garden
#

At least job will be less borring then 😄

#

come in guys

jade glacier
#

I was just showing my Alpha to other Exit guys. Hopefully will be an actual Beta sooner than later that I can share in the channels

#

@solar garden

solar garden
#

Yeah would be cool keep us updated

jade glacier
#

I'll definitely be letting people know when its in Beta here in the channels. Going to need people trying to break things and coming up with wish lists.

weak plinth
#

@gleaming prawn I"m struggling with something in my head...

#

How do I serialize/deserialize structs if they are all different types and have nothing in common?

#

I can't use an interface because that will cause boxing

#

So, I have some network manager where I send a different lot of inputs

#

What would these methods/collections look like?

#

It's easy with interfaces.... But I have no clue how to do this with different types of structs.
How do you guys do this?

#

And then there's also the question of some things not working on, say Xbox?

jade glacier
#

If they are unmanaged you can cast the pointer

weak plinth
#

What do you do with structs?

#

Ugh, I think I need a break. I'm probably looking the completely wrong way at this..

final depot
#

Is casting a C# struct to a buffer safe (disregarding the buffer overflows)

#

The endianness of numeric types is not enforced by neither IL2CPP or Mono

jade glacier
#

I cast it to a type I know it is, but that let's me have a generic delegate

#

The delegate takes an intptr for structs

#

By casting, I mean I am casting from intptr to what I know the struct is

#

It's an odd use case though, it's part of my code gen

#

Makes little sense for other use cases

graceful zephyr
#

@final depot endianness depends on target architecture, not compiler/runtime

#

@weak plinth not sure what problem you're having

gleaming prawn
#

Me neither. As we stated a few times, we do cogegen and the code ends up being type aware for serialization. We have a single Serialize(...) signature for all structs, etc, but more for convenience, as the customer might use that for other purposes... But our game state serializer is just a long list of type-aware calls to serialize...:)

#

Well... It WAS at least...:)

#

In quantum 1.2.x

weak plinth
#

I don't know how it can be type aware?

#

I'm supposed to use some kind of buffer to buffer the states for predict/rollback right?

#

What type do I put in there?

#

And suppose I rollback to some index of this buffer, how do I know what type of struct this is?

gleaming prawn
#

you need meta-data that places the data of specific types into certain offsets...

#

Then your serialization code can go through the buffer as pointers to the specific types...

weak plinth
#

Like... with a big switch or?
I don't know if I follow

gleaming prawn
#

Anyway you want... There are a few ways...

#

example: keep a collection separately with a struct to represent the entity instances...

#

then, yes a big switch would do

weak plinth
#

Does that Serialize method in the structs do the actual serializing?

#

In your case?

final depot
#

@graceful zephyr @jade glacier yeah I was talking in terms of casting a struct directly to a message buffer pointer.

#

It's generally unsafe to do so

graceful zephyr
#

@final depot if you don't know what you're doing, yes 😄

#

but it's not inherently unsafe in and of itself

#

just if you're writing code you shouldn't, then yes... it's unsafe

final depot
#

I would call it unsafe: any integer value larger than 1 byte will get mangled if the endianness doesn't match on remote machines.

graceful zephyr
#

@final depot running into a non-little endian today is fairly rare tbh

#

all modern devices most people are using are little endian only, or little endian by default.

final depot
#

I still regularly see it on ARM machines

#

which includes quite a few mobile platforms

graceful zephyr
#

eh. no. ARM is little endian by default, and was little endian only originally, but can be put into bi-endian mode

#

unless you're dealing with extremely old android phones, like android 2-3-4 era stuff, then they're all gonna be little endian

#

ios/android/xbox/ps4/switch/pc can all be assumed to be little endian

#

for all intents and purposes

final depot
#

If you are safe to make the assumption, then by all means go ahead. But I don't exactly control the exact deployment enviroment of my projects.

graceful zephyr
#

well, you kinda of do - the only platform this in theory could be a problem on is android, and modern unity versions can't even build to android versions so old that it could be a problem

#

but sure if you are exporting an android project from Unity 4.x or something, yeah you might have to care

final depot
#

That makes the assumption that the only remote you are communicating with is on Unity.

#

Which for most people, may be a safe assumption.

graceful zephyr
#

no, the assumption i would make is that the remote im talking to is on x86 or at least modern server/desktop-ARM CPUs (which both are little endian)

gleaming prawn
#

In our case, that assumption is fine.

#

We run outside of Unity (our server stuff)

#

But it's lil endian anyways

weak plinth
#

@gleaming prawn Is there a good way to automate dirty flags?

gleaming prawn
#

Maybe FHolm has a suggestion in this.

final depot
#

Maybe my view is biased. Google still supports older Android phones, and our messaging standard (Protobuf) is resilient against these kinds of platform differences. 😛

gleaming prawn
#

For Google this is a requirement, definitely

#

We can be super efficient by assuming a few things...:)

graceful zephyr
#

In the context of Unity, now a days you don't need to care about endianess

gleaming prawn
#

Look at the native collection framework fholm put together. It beats original .net's in a few cases just because it doesn't have to deal with objects.

graceful zephyr
#

@weak plinth what do you mean by automate dirty flags?

gleaming prawn
#

About dirty flags @weak plinth I'm not dealing with this right now (not a requirement in quantum)

weak plinth
#

Say you have a struct with 8 fields, and you only want to serialize the ones that have changed

gleaming prawn
#

I assume you mean a Boolean that would switch to true everytime data is modified in the struct

graceful zephyr
#

@weak plinth go through and compare to a previous copy of it

#

i.e. a shadow copy

gleaming prawn
#

Of... AND a flag

#

with the bits indicating WHICH fields

weak plinth
#

A shadow copy 🤔
Where would this live?

#

Does this mean you have every struct double in memory?

graceful zephyr
#

yes how else are you going to detect changes

gleaming prawn
#

I assume the shadow copy would be more efficient in the long term than having Properties set the flags

weak plinth
#

I was thinking properties, yes

gleaming prawn
#

Does this mean you have every struct double in memory?
Just double is super fine...

#

We keep a full rung buffer...:)

#

ring

graceful zephyr
#

shadow copy is the easiest way

#

can do the property way also, bolt does it like that

weak plinth
#

Where would this copy live though?

graceful zephyr
#

some memory you control

weak plinth
#

And at serialization, you compare and set the flags?

graceful zephyr
#

no done way before that

weak plinth
#

Is there some example of a predict rollback system out there?
So I at least have some sense of direction

weak plinth
#

@gleaming prawn
This means for games that push the limits of a computer’s processing power; or MMO games where there can be hundreds of players simultaneously connected, the chance of a single player dragging down the performance of the game session is high.

This article is talking about predict rollback

#

What DO they use for large amounts of clients then?

gleaming prawn
#

server

#

this is a no problem

#

There's no way one client can delay the inputs of everyone

#

The server has a very aggressive timeout system for inputs...

#

Quantum is not GGPO...:)

#

Just play battlelands royale @weak plinth . 32 players on mobile shitty networks..::)

#

pretty big battle map also

#

For MMOs it's a different story... It's NOT that one single palyer could affect everyone... It's more that bandwidth stops being small (because you cannot CULL input)

#

So there's a threshold in the number of players where it starts to make more sense to use state transfer with very aggressive culling + scheduling...

#

And there's a range (in player count) in which both state transfer AND deterministic rollback both work nicely... this varies game by game.

#

But of course predict rollback is NOT a silver bullet, not even close...

graceful zephyr
#

@weak plinth you mean determinstic predict rollback or client side prediction for normal networking?

gleaming prawn
#

Oh right... Lol

graceful zephyr
#

@weak plinth for normal fps style networking with predict-rollback for client side prediction, you can look at unitys fps sample

gleaming prawn
#

Maybe that is referring to traditional client-server predict/rollback for lag compensation

#

Which has absolutely nothing to do with deterministic predict rollback (people confuse those two a lot)

weak plinth
#

I assumed this would be client side prediction?

gleaming prawn
#

Yes, but it implies in the server rolling back for lag compensation

#

I'd need to see the full article just to understand what that is refering to

gleaming prawn
#

Ok, so this is just Naive GGPO

#

Not a problem for us...:) This is "deceiving" to say the least... IMHO

weak plinth
#

What's GGPO?
I'm trying to find some source for this

graceful zephyr
#

GGPO = Good Game Peace Out

weak plinth
#

I'm hearing so many different terms and I have no idea where to look

graceful zephyr
#

predict/rollback tech used for fighting games

gleaming prawn
#

without a server acting as input management/batching

#

P2P style...

#

GGPO definitely only works in low player count cases... Actually is only super good on 2 player games.

weak plinth
#

So, say I have a use-case like Diablo. You suggested predict rollback

#

What if I keep increasing the CCU?

#

Should the model change at some point?

gleaming prawn
#

CCU in the SAME game instance? Or total CCU

#

CCU is normally a business-term

#

for the total player count

graceful zephyr
#

diablo style game can be built with deterministic lockstep, deterministic predict/rollback or regular fps-style networking

gleaming prawn
#

yeah, it gets into one of those cases I mentioned several solutions work

weak plinth
#

CCU in the same game instance

gleaming prawn
#

Depends on a few details, but up to 24/32 should be fine with predict/rollback... Up to 64 fine with lockstep...

#

Just out of my head... It depends on other factors

weak plinth
#

@graceful zephyr @gleaming prawn I need to focus in on one implementation. What would you recommend? Especially someone with my knowledge (ie, very limited)

graceful zephyr
#

standard fps-style networking

#

no determinism

gleaming prawn
#

And how good you are (that's a demanding game, you need to know what you are doing no matter the netcode, lol)

#

@weak plinth limited knowledge? Then use Bolt...

weak plinth
#

I mean, granted that I want to learn this as well

graceful zephyr
#

build standard fps style networking then

#

delta compressed snapshots or eventual consistency

#

determinism doesn't teach you anything about networking

gleaming prawn
#

Determinism is somehow easy if you are building the GAME... But the tech behind is NOT simple...:)

graceful zephyr
#

or very little at least

weak plinth
#

Well, I am planning to actually make something too, yes

gleaming prawn
#

networking wise it is simpler than FPS style

weak plinth
graceful zephyr
#

the code? yes.

weak plinth
#

Ok, that should be a very good starting point then

#

How many CCU in one instance would this handle? Ballpark numbers?

graceful zephyr
#

it was built for 16 player competitive game

weak plinth
#

And this still works with input/state right? (As do all games I think?)

gleaming prawn
#

it's full snapshots

#

every tick

#

so it doesn't scale to much more than 16

#

or complex games with big game state... But super good codebase to LEARN...:)

graceful zephyr
#

@weak plinth go through the whole source code, and fully understand it, once you do that... you'll have a good understanding of classic delta snapshot networking stuff

gleaming prawn
#

It's the simpler classic client-server that is also top-notch (recommended for competitive FPS, etc) AFAIK.

weak plinth
#

Big game state would include a lot of AI?

graceful zephyr
#

that's like asking how long a piece of string is

gleaming prawn
#

🙂

#

game state size depends on your game

#

it's YOUR code

#

you should know how big it is...:)

#

That code transfers the full game state every tick (with delta compression on top)

#

How much does delta-C can reduce that in average Fredrik?

graceful zephyr
#

@gleaming prawn a lot, like 90% or something

weak plinth
#

I think I'm better off understanding this FPS sample first before I can judge how big the game state is

gleaming prawn
#

so considering you need to transfer 10% of your full game state every tick, you need sizeof(gameState) * 60/10

#

so 6* game state

#

as download bandwdth (not counting serialzation performance, delta compression performance, etc

#

I can judge how big the game state is
This is your game's state, not the FPS sample's

#

The FPS sample game state is super compact and made to fit that strategy perfectly

weak plinth
#

I know, but I don't have a clear idea yet on what a game state includes in total

gleaming prawn
#

That's why normally you also start (when creating a game) by clearly defining a model+simulation (that's decoupled from the rendering aspects)

#

Because THAT model is your game-state

#

Then you can also decide (based on other requirements as well) if you need state transfer, snapshot interpolation, lockstep determinism or predict rollback determinism...

#

BUT, Just check that sample, it teaches you proper custom-made snapshot interpolation

weak plinth
#

Yes, I will. Thank you both for the advice @graceful zephyr @gleaming prawn

graceful zephyr
#

np

misty shale
#

I think I figured out how to keep things in sync between my web server (http) and the ECS inventory data on the client.

Thinking that I’ll keep a profile version number and ping the server frequently checking the version number. If there’s a mismatch pull down the whole profile (json) and then import to entities / components

#

That’s the easy version, the more advanced one is where I only send the diff 🙂

#

For simplicity I was thinking of doing it via REST at first

#

But I guess I could use web sockets afterwards

jade glacier
#

@graceful zephyr Happen to know off the top of your head the best place to insert my traffic sniffing into the Photon Realtime code? The goal being to capture all of the overhead and not just what I am handing the transport.

gleaming prawn
#

@stiff ridge knows that...:)

jade glacier
#

ah yeah, he is online - will ping him @gleaming prawn thanks

#

And good morning/evening

graceful zephyr
#

Sorry I do not

jade glacier
#

No worries, didn't see Tobi was online - will harass him

#

and good afternoon/eve. Ever find some PID code to steal? @graceful zephyr

gleaming prawn
#

I found some

jade glacier
#

👌

#

No official dev server that I know of for cross Photon discussions

#

But I am PMing Tobi

vital hawk
#

my bad (removed the message before your reply), I see that you're not their staff 😄

jade glacier
#

I contract with them, but I am not an employee nope

weak plinth
#

@jade glacier I'm sorry if I'm asking this again.
But what's THE easiest way to separate game from sim?

#

I need to know how I can have someone else implementing game mechanics without making multiplayer impossible in the future

jade glacier
#

If you want to restrict yourself, just literally limit yourself to an input struct and a master Simulate() method that everything conforms to

#

avoid having stuff in Update() and FixedUpdate() throughout the game

#

So basically EVERTYTHING related to the simulation gets buffered, and derrered

weak plinth
#

So all the input goes into this "central" Simulate method?

jade glacier
#

yeah, that is a good way to keep yourself from scattering your simulation stuff into hard to control places like MonoB Fixed/Updates

weak plinth
#

How do I apply these inputs to the sim then?

jade glacier
#

They all get buffered or queued rather than immediately applied

#

and your simulation only looks at the buffer for inputs for the frame it is simulating, and the previous state results

#

and that produces and new numbered frame of state results

#

Think like PhysX

#

FixedUpdate is actually just a "last chance before simulation" callback

weak plinth
#

Where would the things go that normally go into fixed?

jade glacier
#

You want a pre and post simulation callback

weak plinth
#

Suppose you have a uhm... attack mechanic with a cooldown

jade glacier
#

They can either go in fixed, but they just add themslves to a que or buffer...

#

or you create a whole update manager of your own

weak plinth
#

Normally I'd throw that in the fixed

jade glacier
#

so nothing happens until the callback fires for that phase

weak plinth
#

I think I saw something like this in that FPS example

jade glacier
#

Very possible

#

deferring stuff brings sanity

#

you want very distinct timings, and deterministic orders of serialization where you can make that happen

#

The deterministic order is pretty easy in monoB land for a gameobject

weak plinth
#

I'm trying to visualize this in my head...

jade glacier
#

since the order of GetComponents<> always will come out the same on all machines

#

There is no easy answer, because how you tackle keeping your sim clean is largely on you

#

But you basically want every input to land in a frame id'd buffer

#

and every state to be isolated into a frame bufferable form as well

weak plinth
#

But there's still going to be quite some stuff in (fixed)updates right?

jade glacier
#

So the simulate when it is called is just grabbing the inputs for that frame... and applying that to the previous state... and that produces a new state

weak plinth
#

Just not the inputs...

jade glacier
#

You can put stuff in fixed, just be aware that its going to be very hard to track the timings or order of that stuff

#

which is where deferment comes in

#

if you collect your inputs all over the place ad hoc in FixedUpdates... you will want to bring some sanity to that in creating your input struct

#

How you do that... is up to you

#

but you want to produce some form of a struct or class or whatever that you feed to the sim as your inputs

weak plinth
#

Hmm

jade glacier
#

You can be less restrictive

weak plinth
#

But this "sim" is the Mono's themselves also?

jade glacier
#

but for that I recommend an update manager

#

because if you don't have a monolithic sim, and your sim is actually all over the place in MonoBs and such, you will want to enforce a strict deterministic order of exec on all of those things

#

For example... first move all objects... then apply animators... then trigger weapon fire... etc

weak plinth
#

Sounds like ECS 🤔

jade glacier
#

you don't want player one to move... then maybe fire... then maybe change its animator... then player two change its animator.. then fire... then move

#

you end up with race condition hell

weak plinth
#

You know, this all sounds very complicated 😂

jade glacier
#

The point is to remove the complexity

#

and replace it with strict and deterministic as possible

#

But this is why we say the simulation part is 90% of networking

#

messaging is... who cares

weak plinth
#

Is there an easy switch between SP and MP?

jade glacier
#

nope

weak plinth
#

I mean, if you have a game that supports multiplayer

jade glacier
#

design for MP always

weak plinth
#

Is there an easy switch

jade glacier
#

yeah, going from MP to single is much easier

#

single to MP... rip

weak plinth
#

I assume that games like Borderlands (or whatever) where a peer is a host

#

They use exactly the same code for sim?

#

Just... internal?

jade glacier
#

I believe borderlands single player runs itself like a MP game, but I can't say that for sure

weak plinth
#

I'm thinking that's the easiest way to do it

jade glacier
#

Typically yeah, if its going to be MP, design for that, then you are just disabling some stuff for single. But the simulation is the simulation

#

so its going to look nearly identical

#

good games should all use a strict simulation

weak plinth
#

But how should I see this, are you running 2 different "things" in single player?

jade glacier
#

MP or not

#

people sticking game logic in Update need to be slapped

weak plinth
#

You mean... 95% of people that work with Unity?

#

Literally every tutorial online

jade glacier
#

yeah, Unity is guilty of encouraging it... because its an easy start

#

but it creates so much pain down the line

weak plinth
#

👋

#

Probably why this is so difficult to understand for me

jade glacier
#

Getting good at isolating out a tick based sim is useful for lots of aspects of game dev

weak plinth
#

I can imagine less spaghetti

jade glacier
#

and opens the door for other stuff non MP... like smooth rewinds, replays, game saves... reduction of race conditions... less frame rate dependency and hitching... and so on

#

and of course determinism. Never going to get that using Time.deltaTime

weak plinth
#

So you're saying that, professional games are not at all developed like Unity is portraying?

jade glacier
#

Even Unity doesn't recommend what the tutorials show

weak plinth
#

Lmao

jade glacier
#

There are a LOT of things in the tutorials their devs are pretty appalled by. Its a tale of two game engines in one.

gleaming prawn
#

You mean... 95% of people that work with Unity?
Literally every tutorial online

#

yes

weak plinth
#

Well, where can I find tutorials that actually show what I need

jade glacier
#

Unity is quick and accessible.. but there is a price for that.

weak plinth
#

Because I'm literally used to the "bad" way

#

That's all I've seen/read/heard

gleaming prawn
#

Well, where can I find tutorials that actually show what I need
Learn C..:)

jade glacier
#

But Unity also has a LOT of very correctly done stuff going on internally

weak plinth
#

I'm semi-competent with C currently

gleaming prawn
#

Tutorials...

jade glacier
#

ECS is going to be where the two worlds collide... painfully

gleaming prawn
#

Most of the modern tutorials are targeted at non-professional devs. So full of bad practies

jade glacier
#

ECS + easily accessible.... not a fun thing to try and make

gleaming prawn
#

Not saying those guys don't KNOW... They just don't SHOW, because the audience needs simple things

jade glacier
#

exactly

weak plinth
#

So, is ECS one of the good ways?

#

I don't mean DOTS

#

Just.... ECS

gleaming prawn
#

You have correct stuff on GDC videos, on old gamasutra blog posts

jade glacier
#

Everyone has the same experience... you try unity and go "wow, this is fun and easy"... then you come to these channels and everyone is like "OMG, your code is garbage"

gleaming prawn
#

On some papers (the one on the Tribes networking model, for example)

#

Or in good code like Source Engine, etc

weak plinth
#

I think 1 good example would help me immensely. Just to get a clear idea of what we're discussing here

gleaming prawn
#

Everything from Carmack is also good (the super neat ideas of his old code, etc)

weak plinth
#

I'll write these down

jade glacier
#

Doom, Quake and CS are pretty much the history of snapshot

weak plinth
#

You reckon that unity fps example is correct?

gleaming prawn
#

yes

#

At least the networking part

#

Doom, Quake and CS are pretty much the history of snapshot
This

jade glacier
#

I have yet to be able to even run it... laptops don't like that FPS sample

weak plinth
#

Well, I'm concerned about the non-network part as well

gleaming prawn
#

There are a few good videos from the Overwatch Blizzard team

jade glacier
#

The Overwatch talk is a good one too for the current interpretation of it yeah

gleaming prawn
#

there's another one on their ECS model

jade glacier
#

Even without the ECS part, there are great takeaways

#

like the buffer management through sim rates, and just the whole importance of deferrement

#

the biggest trap I see in networking is people don't defer

dapper spindle
#

Anyone able to recommend a library which allows for player hosted servers and has reliable UPnP?

jade glacier
#

Messaging <-> Buffers <-> Simulation people break that model right out of the gate, and let Messaging and Simulation touch one another directly... and its race condition hell

gleaming prawn
#

reliable UPnP?
Reliable = works 75% or less (for UPnP)

#

if using STUN based punch it can go up to 85-90%

#

@dapper spindle Steam would be reliable (because it falls back to relay)

#

And it punches... Super well. almost 90% success rate

dapper spindle
#

I am not really wanting to use steam. To clarify I don't mind if users have to port forward its just the libraries I have used so far have all seemed to not work.

weak plinth
#

😮 Diagrams!

#

I will surely read this when I have a bit more time! Thanks

gleaming prawn
#

To clarify I don't mind if users have to port forward
You then accept that a great part of the player will just not play and be angry, right?

jade glacier
#

Port forwarding manually was an accepted practice in 1996

weak plinth
#

That's the benefit of something like xbox

#

They use 1 port for everything

gleaming prawn
#

That's the benefit of something like xbox
XB doesn't allow you to do ANYTHING... It don't pass through cert

#

It has a nice library (Teredo)

weak plinth
#

I mean, for the user 🙂

gleaming prawn
#

and then they accept certified providers (like us and others)

weak plinth
#

You port forward 3079 (I think) and all games work equally

jade glacier
#

XBox I don't see being excempt from the whole punch issue

gleaming prawn
#

for the developer to do his own thing is super complicated

dapper spindle
#

I mean, port forwarding has become a lot easier at least thats what I remember.

jade glacier
#

the issue isn't the xbox... its that everyone has a router at home

gleaming prawn
#

Port Forwarding is just NOT a good practice... It just doesn't work

#

🙂

dapper spindle
#

Well it does

jade glacier
#

asking users to log into their wifi router, and forward a port.. and then lock their game devices IP to a fixed IP....

gleaming prawn
#

Alone at least

jade glacier
#

not going to happen

gleaming prawn
#

I mean, doesn't work in PRATICE

dapper spindle
#

Well i mean Minecraft does it.

gleaming prawn
#

If you expect your home users to configure port forwarding, then fine

weak plinth
#

@jade glacier Well, it depends I suppose

jade glacier
#

If the game is a runaway success sure

#

people will do anything you ask of them

weak plinth
#

There is a plethora of games where the norm is user-hosted servers

gleaming prawn
#

User hosted servers != solely relying on UPnP and Port Forwd

weak plinth
#

But if I had to manually port forward even half of my games on steam, I wouldn't even use that platform

jade glacier
#

but for an unknown game to be like "hey, try me... but first here are 200 lines of instructions on how to reconfigure your firewall...."

#

in 2000 that was acceptable because people largely existed outside of firewalls... and anyone gaming was savvy with the ways of the internet. in 2020 the average user doesn't even know what an IP is

weak plinth
#

I guess the majority of home routers has upnp enabled?

dapper spindle
#

Literally: Open router control panel > go to firewall > add forwarding rule > type in some numbers > select your device.

#

Done

jade glacier
#

Not that simple

weak plinth
#

I wonder about the statistics on how many people you can reach with upnp and nat traversal

jade glacier
#

dynamic IP

#

oops, you restarted your device... go do it again

#

Anyway, not here to debate that

weak plinth
#

Open router control panel

jade glacier
#

if you think your users will port forward... go for it

dapper spindle
#

I mean at least in Britain nearly all ISP routers automatically make your devices IP static when you assign a port.

weak plinth
#

Oh shit, what's my username/password

jade glacier
#

"open router" LOL

#

yeah

dapper spindle
#

Oh its on that sticker on my router.

jade glacier
#

I'm savvy, and I have to burn 15 mins whenever I have to go into my wifi router

weak plinth
#

Time to enter some random generated 20 character string

#

Because some dev is too lazy to properly make his p2p game

jade glacier
#

You do you though, not saying its not possible

#

just that as a biz model... not going to fly

weak plinth
#

I agree

dapper spindle
#

2 minutes. It literally takes me 2 minutes to do it.

weak plinth
#

Unless we are talking about user hosted servers

jade glacier
#

Then do it

weak plinth
#

No-one is going to use this product

#

I can imagine the steam reviews already

#

People have hundreds of games to choose from

#

What makes you think they will choose yours granted that they can't even play it online out of the box?

jade glacier
#

yup, its not 1996.... people aren't going to dick around with the modern equivalent of Kali

weak plinth
#

Can't play with my friends atm because I have to port forward

#

Fuck it, we'll play something else

jade glacier
#

You CAN however offer an option for self hosting

#

for the hardcore

#

but that should not be the only conduit. It should just work with punch and relay for new users

weak plinth
#

There are games that are client-server exclusively

#

Like Minecraft

#

And Space engineers

#

Etc. etc

dapper spindle
#

Are people really that lazy to spend 2 minutes port forwarding.

jade glacier
#

yup

weak plinth
#

It's either single player, or client-dedicated server

jade glacier
#

depends on the people

weak plinth
#

I'm not too lazy

jade glacier
#

but the average steam/google/apple user... will try your game... be like WTF... give it 1 star... uninstall

weak plinth
#

I just don't want to clutter my router with port forward rules for random games

#

If I have to port forward for a game like borderlands

#

Fuck it, not happening

#

Not punching random permanent holes in my firewall just for some random game

dapper spindle
#

Ok I can go the punch route but still, any networking library I have tried still wont work in unity.

weak plinth
#

Look for the compatibility that Unity has

#

IE anything in standard 2 works with unity

gleaming prawn
#

Punch needs a server to do signaling

#

STUN servers only provide reflexive addresses

#

So you are asking for a service (maybe google has something, but AFAIK they only have public STUN servers, not signaling stuff)

#

Maybe I'm wrong

weak plinth
#

How to dc websockets client side 😋

gray pond
dapper spindle
#

Any suggestions for something like Lidgren or LiteNetLib

jade glacier
#

if you are working with a transport, just be sure to abstract it out so you aren't overly entwined with it

#

Same for any library, try to avoid hardcoding it into your simulation and such

weak plinth
#

Lidgren is pretty bad afaik

dapper spindle
#

I can use Lidgren, Just doesnt work in unity

weak plinth
#

I'd avoid it

jade glacier
#

So its an easy swap later when you know what you are actually needing

weak plinth
#

There's an entire article floating about how someone tried to use lidgren for their product

#

And ended up rewriting most of it

#

Because it was poorly implemented with very poor performance

#

If I can advocate for a transport, It'd be ENet

dapper spindle
#

Hmmm, I saw quite a few recommendations for lidgren.

jade glacier
#

You'll go crazy trying to pick the perfect library

#

which is why I suggest abstraction

dapper spindle
#

Less the perfect one more one that works

jade glacier
#

just make it easier on yourself later to change your mind

#

its a good practice anyway to keep that layer isolated

dapper spindle
#

Oh yeah it's pretty easy, I set up a chunk before even testing to see if it would work in unity.

weak plinth
#

@dapper spindle The problem is that there's many people that lack sufficient knowledge to determine if something's good or not (me included)

#

So to those people, if it works for them = good

jade glacier
#

Messaging <-> Buffers <-> Simulation Just keep that Messaging part connected by the thinnest thread

weak plinth
#

That's why things like TCP still get brought up in gaming as a good option

#

Disclaimer; there are use cases for tcp in games, but they are minor

#

Anything real-time, preferably not

graceful zephyr
#

Eh

#

I mean games like eve use tcp

#

@weak plinth

dapper spindle
#

Eve doesnt have to be exact though

graceful zephyr
#

I meant in regards to realtime

weak plinth
#

@graceful zephyr How do they manage to make TCP function?

#

Without jittering

graceful zephyr
#

TCP doesn't cause jitter by just being used

weak plinth
#

No, TCP causes jitter by resends

#

I don't know. It seems strange for games like those to use TCP.
Dealing with resends and stale data

#

Maybe there's a good reason that I don't know about

graceful zephyr
#

Simplicity and throughput @weak plinth

weak plinth
#

Throughput? Isn't UDP throughput going to be better?

graceful zephyr
#

No

#

Not even close

weak plinth
#

Does this "requirement" for throughput have to do with the large-scale of the game then I assume?

graceful zephyr
#

usually yes

weak plinth
#

One of the things that I've taken away from the past few days conversation is that game networking has a milion different use/edge cases all with a different outcome

graceful zephyr
#

mhm

#

:p

#

'networking a game' is a problem with many many different solutions

weak plinth
#

I currently have the image in my head that one specific use case has one ideal solution. But that's probably not the case

graceful zephyr
#

well

#

i mean, it depends on how specific the solution is

#

if you're talking about an RTS, then the ideal solution is deterministic lockstep, if you talk about an competitive FPS then the ideal solution is delta snapshots with client side prediction, if you talk about fighting games the ideal solutions is deterministic predict/rollback @weak plinth

#

so yes there are ideal solutions

#

but thats in the broadest possible sense, sure someone could come up with an competitive FPS that delta snapshots might not be good for, etc.

weak plinth
#

I think it's currently best for me to heed your advice and study that FPS example

graceful zephyr
#

yes

weak plinth
#

Erick told me about some useful sources as well

#

That paper on tribal networking seems really good

graceful zephyr
#

tribes you mean

weak plinth
#

Yes tribes 😄

graceful zephyr
#

tribes uses an eventual consistency model

weak plinth
#

Do you know of a source that gives some idea about models out there?

graceful zephyr
#

no

chrome flint
#

Hey guys, can you help recommend a multiplayer tool I can use for a simple FPS game? Just two players who shoot each other.

I guess my priorities are that the network allows for fluid movement/actions and then second priority would be ease of use

somber drum
#

lots of simple fps kits using photon that you can get setup fairly easily, pm me if you need an example of one i can link.

solar garden
#

What are called the ways of networking where you send inputs to the server and the one where you send a whole snapshot thing ?

rapid girder
#

I have a unity project that uses PUN2 for RPC's. Problem is, I really need a server to store permanent info on (player accounts), and maybe to handle the matches themselves too (hack protection). I think I can't do those within PUN.

What services do you recommend?

graceful zephyr
#

@solar garden Those two are not mutually exclusive

solar garden
#

ahh

weak plinth
#

Hack protection, first of all, obfuscate ur games dll good

#

Or make layers of protection before working on anti cheats inside game

gleaming prawn
#

being honest:

  • care about this only if you already have a game... successful one...
  • if you don't have one, start by choosing a networking strategy (because they are going to have a big impact on the gameplay, and you need one that fits your game)
#

And if you are thinking about wallhacks and aimbots... Obfuscation is of very little help... Most of these hacks are done in the video card driver (adding outlines, or spotting for the aimbot at the vertex shaders).

weak plinth
#

Obfuscation is done many times to prevent easy stealing of software

weak plinth
#

Now thag i think of it what erick said is right

#

That

#

Ez af u can check about files size and shit

jade wharf
#

C# obfuscation is a joke

#

obfuscation of code in general i would call a joke

#

anyone dedicated enough will figure it out

#

or has a software that deobfuscates it with a push of a button

weak plinth
#

Yah deobfuscation is ez aswell

#

There are enough deobfuscators out there, that can do the job for most of obfuscators

#

But its just an idea

#

You just gotta be creative and create diff layers of security

gray pond
#

wallhacks and aimbots
Apparently these apply to client-trusted games?

#

Maybe I'm missing something, but client shouldn't know anything about the interior of a building unless it's practically in the door

#

it should just be an empty hull at a distance...nothing in there to be outlined.

#

I'll admit I don't know really how aimbots actually work without altering the client source

weak plinth
#

Same

#

Also it doesnt have to be client trusted when they can dump the source

gray pond
#

I don't see how having the client source would be helpful, really. client only knows what server tells it, and server doesn't tell about things that aren't near the client or would be occluded.

#

I just watched a video where apparently some sort of wall hack allowed the player to pass through a barred window. As far as the server's concerned, that player is still in the room, and isn't going to tell the client about anything outside that room. It will keep telling the client where the player should be, and will continue to apply player inputs as if the player is still in that room, ramming into walls. If the "molested" client ignores the position update, the player will find himself in a very empty scene.

weak plinth
#

Any and all data the client has can be used to cheat

#

And unless you plan to make the most overly convoluted system ever to only update the client with data they can actually visually see

#

And MAGICALLY achieve this complete bug free

#

Seeing other players through walls based on position data is available

gray pond
#

You're missing my point entirely

weak plinth
#

But imo, trying to prevent that kind of stuff in networking. You're doing stuff in the wrong place

gray pond
#

client does not know about entities the server can easily determine it shouldn't know about

weak plinth
#

Define "easily"
And also define how this "easily" can in no way be used for things like aimbots of wallhacks

gray pond
#

player A is in the street. Server knows that. Server says nothing about what's in the buildings...no spawn messages, no position updates, etc.

weak plinth
#

Player B is just about to walk around the corner where A is

#

Going to be an interesting case that 🤔

#

Also, going to be some juicy overly-convoluted system

#

Or are you planning to let the server check every frame for every player vs every other player if they can see ANY part of their character? 🤔

#

Playercount ^2

gray pond
#

If you're referring to close range, aimbot is no real help - target is too close to miss regardless

weak plinth
#

Assumptions

#

Bad ones at that

gray pond
#

ok stop a sec

weak plinth
#

And you have no idea what kind of benefit you can get if you see before-hand if someone comes walking around a corner

gray pond
#

I'm not going to spend hours with a 5 year old picking corner cases

weak plinth
#

Ok, so you come up with a flawed idea

#

And when I point out flaws? You call me a 5-year old?

#

👌

gray pond
#

I'm saying that some of this stuff I'm seeing in videos about aim bots and wall hacks are impossible in a server auth game - they must be trusting the client a LOT

weak plinth
#

Anything that a client knows, they can use

#

People use client side software to try and prevent this

#

Or are you someone that builds DDoS protection in your games as well?