#archived-networking

1 messages ยท Page 43 of 1

stuck void
#

oh no this is with pvm enemies, not other players :P

#

so the owner is the server

jade glacier
#

ahh, so you need determinism ๐Ÿ˜ƒ

stuck void
#

yeah, but I cant have it be too complex that would take up too much resources as its going to be hosting a relatively large number of players

jade glacier
#

I don't know the specifics of your game, so really can't say... but since you are making a game and not an engine... you have all kinds of avenues for cheating the networking system

stuck void
#

yeah the simplest way I could think of was just removing the hitboxes on the abilities on the client side entirely and the server tells the client when it gets consumed/hits something, I could probably squeeze that in into 2 extra bytes on some existing messages

jade glacier
#

not being pvp also makes things a bit easier

stuck void
#

yeah pvp is something I'll tackle on a much later date

jade glacier
#

Its still going to be history that the player sees around them

#

because everything is interpolated on the past, and not extrapolated

stuck void
#

yeah, but at least the projectile will visibly be consumed even if its slightly off your client side hit box, rather than merrily flying away out of view despite you taking damage

jade glacier
#

@graceful zephyr do you have a default sample game scene you use for any of these tests? Or are they pure data streams atm?

graceful zephyr
#

the previous prototype was almost fully built out

#

all ran in unity

#

had a small game, etc.

#

but this prototype is all .net code/console stuff atm

jade glacier
#

@stuck void It won't be consumed immediately, there is latency to the server saying "Oh that missile hit you btw"

#

so locally it still is going to miss you, but there will be a corrected explosion in a location different from where you cosmetically just saw that missile

stuck void
#

yeah, but at worst it would realistically be half a second after it flies by, which wont be noticeable on projectiles that arent too fast

jade glacier
#

Slowing things down is a pretty common way to deal with it... another is you CAN extrapolate projectile speeds to account for RTT

#

you can have missiles fly faster on the player side for a few ms to catch up with the RTT delta

#

since you can safely extrapolate objects that move in a predictable path

cosmic atlas
#

with my client-authority system, a client only tells the server if the client's character received damage if the character actually received damage on their screen
for every other client, if a projectile hits a player, it just displays a cosmetic blood/particle effect, but does not send any message back
not realistic, but something something indie dev life

jade glacier
#

which.. projectiles are

stuck void
#

I guess, but in my game most projectiles are going to be relatively short range, so it wont make much of an improvement compared to something like an fps where you have long range stuff

jade glacier
#

@cosmic atlas he already is server auth, so he is just sorting out how to hide the fact that the player is seeing history

cosmic atlas
#

aye

jade glacier
#

@stuck void Every little bit helps

stuck void
#

yeah this is just for fixing up visual disrepancies on the client

jade glacier
#

you can also do some client side rewind to guess if that shot had hit them when it is fired....

#

because the player knows where they were 100 ms ago....

#

they will know if that rocket hit them... and if so, you can cosmetically alter its path toward the player

#

makes for some weirdness, but you won't see rockets that hit you fly by like misses

stuck void
#

might be worth a try

jade glacier
#

They will just magically be dead on target

#

ive seen that in games, and it does get weird because like a stream of bullets for example will all be lagging behind you... then suddenly they start shooting out of the enemy right at your face and hit

#

3rd option... rewind the player and determine how much they missed by.... fire locally cosemetically at an angle that gives a similar miss

#

this is all client side rewinding

#

for cosmetics

#

not easy stuff, but giving you some options

stuck void
#

hm but on second thought, it wouldnt make that much of a difference compared to the server telling the client when its hit, since its not very fast paced

jade glacier
#

The advantage of that 3rd method is you get a realistic sense of how close the enemy is to hitting you

#

and actual hits don't seem like they came out of the blue

stuck void
#

its 2d as well so it wouldnt be a noticeable improvement as in 3d

jade glacier
#

I would make it without any of this....

#

and just decide when you are playing if the cosmetics are bothersome

#

and THEN work on some of the cosmetic cheats

stuck void
#

ye I think I'll just go with a simple server telling the client when it hits tbh

jade glacier
#

yup, should always start there anyway

stuck void
#

main issue is when the projectile never hits at all on the client

jade glacier
#

see the actual problem you are trying to solve before going crazy with it

stuck void
#

a bit of delay and it hitting slightly beside the player wouldnt be that big a deal I reckon

jade glacier
#

nor will it, client sees history. As long as the client is moving, it will feel like you are dodging everything

#

Just remember that you can extrapolate projectiles with RTT and get them into sync with the player view reasonably easily

#

ie they fly faster out of the barrel on the clients scene

#

doesn't solve everything, esp at close range

#

but can bridge the gap in reality a bit

stuck void
#

might only be useful for a very small percentage of attacks for my game, since majority of them will almost always land in close range and travel fairly slowly

#

ill try the simple way first, see how it goes

jade glacier
#

the slow movers will be the easiest to fix with extrapolation

#

just make it first yeah, then decide what looks unacceptable

#

I paste that often it seems, for this topic

#

the slow movers change color so you can see the stages

#

Its the reverse of what you are doing but same concept... the projectiles actually change speed two times in order to get them locally in sync with the server

#

it can be pretty subtle, but makes a lot of difference

stuck void
#

yep had another test, looks like I'll need some extrapolation too

jade glacier
#

If you have an average RTT value it's pretty basic algebra

#

One train left the station at X... Another at Y... How fast does train B have to go to catch up with train A in Z seconds

cosmic atlas
#

depends if the train has to send ack packets or not

jade glacier
#

It's all unreliable.. regardless this is all rough anyway

#

Can't be perfect, it's just trying to be less wrong

#

@stuck void Another option on that front is to rather than accel and decel projectiles, is just start them already on their way... so on the player side they originate x milliseconds already along their path

#

That will look a bit disconnected from their shooter, but that will make them nearly 100% in sync with the players timeframe

#

That would be the easiest to implement for testing. The speed change basically is just lerping toward that end state

jade glacier
#

Also, if these are ai, you can transmit their intentions, which can be extrapolated without needing full deterministic

cosmic atlas
#

in Overwatch (depending on the weapon), client instantiates a fake projectile immediately, then when it gets the proper position from the server, fudges the position into place properly

jade glacier
#

Yeah, my guess is most do that. That was my choice for my first networked game without even knowing how others do it. It's kind of the obvious choice.

#

I used the average RTT to come up with a slower initial speed as well, so when the server confirm arrived they would be very close

jade glacier
#

Some parts of Overwatch are deterministic no? I REALLY need to go look into how they do things.

cosmic atlas
#

Not sure

graceful zephyr
#

@jade glacier its close to deterministic/they try to be deterministic on the prediction of the player

#

but only on that part

#

my background serialization thread idea isn't going to work, or well it would technically work but it's going to be too much annoying shit to deal with for the users of the lib

#

need to figure something else out

jade glacier
#

Requires too much strict setup of their data to conform with it?

graceful zephyr
#

yeah

#

and it gets too complicate to add user-serializable data

#

like if someone just wants to send some random C# class or something

#

crap like that

#

it gets too hard

jade glacier
#

What's your current goal with this stuff? Like how many players/net objects?

graceful zephyr
#

100 players with 100k objects

#

at 60hz

jade glacier
#

Comparatively, where does Bolt start to crap out?

graceful zephyr
#

bolt scales fine up to 50 players or so

jade glacier
#

I take it that this second thread doing the serialization is pretty critical get getting up to those numbers

graceful zephyr
#

@jade glacier well, i figured i would spend my energy trying to get max single thread performance, like being able to share simulated entities, etc.

#

it's a much better avenue with potential higher payoff

#

like being able to serialize an entity once and then have most connections being able to just copy that update into their packet

#

it only works when the delta compression lines up of course

#

but for most entities, when they are serialized every tick, it will line up

jade glacier
#

It seems like trying to make it user friendly is going to be at odds with trying to do 100/100K on a separate thread.

I would assume with any system with that many entities you would be leaning heavily on interest groups vs a unique serialization for every connection?

graceful zephyr
#

oh well i absolutely need interest groups

#

but a lot of connections will still share entities they are interested in

#

like if you have 5 players fighting each other

#

in one area

#

that would normally lead to 5*5=25 unique entity serializations total

#

but if i can serialize those 5 player entities once, and then copy the state for them into each of the 5 packets

#

that's a x5 reduction in time spent serializing data

#

copying the data from a serialization buffer for each entity is easy

jade glacier
#

yeah, the thing I am thinking off would be totally game specific

graceful zephyr
#

and is much cheaper

jade glacier
#

like in a 5 v 5 sending only two streams, one for each team... and all the player on the same team getting the same exact stream minus some header mods for their particular connection related info from the server

graceful zephyr
#

yeah

jade glacier
#

That is so totally game specific though, don't see how to write that into an engine

graceful zephyr
#

well, i do :p

jade glacier
#

I suppose by creating groups that things can belong to, if all of the groups match... then they get the same serialized stream

graceful zephyr
#

ye

#

also since the memory is read only during the serialization process

#

i can in theory spin up several threads to serialize each packet for each connection if needed

#

yeah screw the background thread idea, it's too heavy

jade glacier
#

Can always revisit it too

graceful zephyr
#

if i were building something for a specific game

#

i'd go for it

#

but its too convoluted for the average user of the lib to deal with

jade glacier
#

yeah, it sounds like making a friendly generic system is just going to make the entire library unusable... just for the edge case of that one giant space sim

graceful zephyr
#

also there's a non zero chance i'd spend a lot of CPU just fiddling around bytes between the threads, negating a lot of the benefit

jade glacier
#

It really comes down to what you are making, and who you are making it for

#

There is what the market needs... and there is what tickles your pickle to see if you can make it ๐Ÿ˜ƒ

graceful zephyr
#

there's other issue also with the bg thread model

#

like minute little issues in how to deal with entity destruction, etc.

#

plus not doing the background thread idea lets me re-use more of my existing code so there's that also

#

like.. a whole fucking chunk more code, easily 6-7k LOC i dont have to trash and rebuild

jade glacier
#

Its all above my pay grade... all I can say is give yourself a minute to think about the end game for whatever you are making is

oak flower
#

@jade glacier Could we please keep the language less edgy. At some point swearing just becomes gratuitous. ๐Ÿ˜ƒ

jade glacier
#

Sorry, forgot this was the official unity discord @oak flower

oak flower
#

Thank you ๐Ÿ˜„

graceful zephyr
#

@oak flower I dont wanna be that... guy, but where did he swear? and even if he did in passing in a conversation online... are people really expected to back to re-read conversations so they can feel insulted over things that were said when they were not there.

oak flower
#

I've removed that line. It was a bit off topic ๐Ÿ˜ƒ

graceful zephyr
#

@oak flower And since when is masturbation a curse/swear word?

oak flower
#

It depends on the context.

graceful zephyr
#

No it doesn't, it's not a swear/curse word, and in the context it could not be interpreted as a swear word even if you try REALLY hard.

vital hawk
#

I'd guess that goes on keeping the place friendly for people at all ages here

jade glacier
#

My context was in terms of coding, not the actual physical act... to be clear. ๐Ÿ˜ƒ

oak flower
#

We are not discussing how human body works. And it didn't have any relation to the #archived-networking ... Yep ๐Ÿ˜ƒ

graceful zephyr
#

I'm all for having a nice and welcoming place, but this neo-evangelical shit of not allowing simple words like masturbation, literally something everyone does... is just... give me a fucking break

#

And not even in bad context, just as an analogy to what i was trying to achieve

#

Gimme a fucking break

oak flower
#

It is arbitrary. But I would draw the line on swearing for the sake of swearing.

graceful zephyr
#

Its. Not. A. Swear. Word.

#

And even if it was, so what? goddamnit, lets nazi mod the shit out of every channel and have everyone sign a code of conduct while we're at it lol

#

Anyway I ground my axe enough, time to do other stuff

prisma spade
#

Well in context he was more referring to the discussion being for the purpose of just a self serving fantasy rather than concrete results. Out of context it is a rather mature word to use

jade glacier
#

I am a bit confused as well as to how and when it became a bad word. It hasn't been since like the mid 80s.

#

But whatever, can move our chat elsewhere.

oak flower
#

Looks at the channel name A bit of digression. The word doesn't have to be a swear word to be used as swear. In Hebrew for example, there are no swear words. But as you can guess there are plenty of words used to swear. Just the matter of context. (If you want to follow up on this please take it to #497872469911404564 . I should've had...)

graceful zephyr
#

Part of being a good mod/admin is to know when letting things slide because someone obviously didn't mean anything bad by something as it was just said in passing, great way to piss of people who spend time and effort helping others in here is to mod every line that's written.

jade glacier
#

I honestly don't care. I'll try to make an effort to not type anything above PG 10 in here, but if I forget... oh well.

prisma spade
jade glacier
#

nice!

graceful zephyr
#

@prisma spade nice, how long before thats rolled into unity?

#

and will it propagate to il2cpp also?

prisma spade
#

il2cpp shouldn't have the issue iirc it was isolated to "new mono on windows"

graceful zephyr
#

well wouldnt il2cpp use the mono libs for this just cross compiled to il2cpp?

#

depends where the issue was of course

#

but i've had massive issues with socket performance on mono in Unity

#

like it completely shitting the bed when you're doing async accepts on a tcp/ip listener socket

prisma spade
#

as for propagating the fix to unity I'll have to look into that... when I get it into a release I'll update here

graceful zephyr
#

after around 1k accepted connections it just... blows the whole socket out of the water, performance degrades on the whole machine, response times for even established sockets skyrocket

#

you can get around it by using a synchronous accept in a separate thread, but that still only brings me to around 1500 accept connections

#

before it completely craps out again... so ยฏ_(ใƒ„)_/ยฏ

#

.NET proper easily does 30k concurrent connections with identical code base

#

i think it has to do with mono using managed threads for the *Async callbacks, but well

#

i never looked deeper into it

#

now sure you could say whos going to have thousands of concurrent connections to a single instance

#

propbably... nobody

#

but it obviously plays a role much earlier as overall performance is not good even when staying far under the limit of where it starts having issues

jade glacier
#

It would definitely seem to indicate an underlying problem with it

graceful zephyr
#

yeah i just gave up and moved on, as i dont really do much tcp/ip networking, was more of an exercise to see how far i could push it

prisma spade
#

Sorry stepped away for a moment.... what platform were you seeing this on @graceful zephyr ?

graceful zephyr
#

windows

prisma spade
#

and you see it with il2cpp and mono ?

graceful zephyr
#

only tested on mono so far

#

didnt bother with il2cpp

prisma spade
#

ah okay

graceful zephyr
#

i mean i am using a 32 thread machine to test this, and .NET proper will basically saturate every open port on my machine without breaking a sweat

jade glacier
#

@graceful zephyr So not making much progress with all the chit chat, but what I am mostly trying to sort through is how the clients deal with the adjustments in fixedupdate rates and to my destructive changes to latency in my attempt to break things....

The issue being that while the server can keep the same frame id offset and tell the clients to nudge themselves to conform... if the clients pick a starting frame number offset and that for whatever reason no longer gives an ideal buffer, there is no way to realign without a hard offset change,

When I do a hard change, I have to sort out if I want to shift all of the frames, copy all of the frames, or just clear my masks and start the buffers up again as empty.

If that wall of text makes any sense.

prisma spade
#

4.x mono has the race condition that that github pr resolves... Which can cause a thread to get stuck on a blocking call

graceful zephyr
#

@prisma spade are you not using mono 5.x on latest 2018.3.x releases already?

#

@jade glacier actually i cant make sense of the problem ur describing

#

or im not quite following

jade glacier
#

LOL, yeah didn't think that was going to be comprehensible

graceful zephyr
#

@prisma spade or did you mean mono 4.x as ".NET 4.x"-mode in unity?

jade glacier
#

Basically, nudging the client works for the server.. .but nudging the server isn't a thing. If the buffer the client is keeping isn't a good size, I have to do a hard adjustment of either dropping frames or adding frames. Not sure that is any better.

graceful zephyr
#

@prisma spade but I would assume that IL2CPP will use the same mono-socket-libs as mono would?

prisma spade
#

Sorry I was talking about framework version

graceful zephyr
#

@jade glacier slow down the client then? gah im not following

#

@prisma spade np, yeah this was .NET 4.x mode in 2018.3.2 i tested on

jade glacier
#

@graceful zephyr no worries, just thinking out loud anyway

graceful zephyr
#

mono in both build and editor

prisma spade
#

right yeah they share the same underlying windows socket code. So that makes sense

graceful zephyr
#

@jade glacier what im not following is how its not possible to re-align the client without a hard offset change?

#

@prisma spade and while il2cpp generally (for me) performs better than mono, just in raw CPU usage.. the CPU isn't even close to saturated here... sitting at like 4% cpu usage or something for Unity when this is running

#

@jade glacier if you reduce/increase the fixed delta time it will move faster/slower

#

and re-align itself

jade glacier
#

The only time nudging is the client in order to get as tightly synced to the servers requests... If the client suddenly finds its buffer is like 2 or 3 ticks too big I can't tweak the fixed rate.. because that is being managed to conform to the servers requirements. The client has to hard remap its tick offset is the only way I currently see.

#

@graceful zephyr

graceful zephyr
#

oh right

#

im talking about a fully auth environment here

#

where this only goes one way

#

client=>server only

jade glacier
#

yeah, the server is unflinching, so really this situation is just if the client chose a bad offset at the start and needs to rethink it. It shouldn't happen often, or ideally at all

#

but I want it to be bullet proof enough to survive me turning 300ms of fake latency on and off

graceful zephyr
#

hmm yeah

#

i dont have a pre packaged solution for you sorry

jade glacier
#

Didn't expect you to have the answer, just thinking out loud since I'm clearly not getting any coding done today ๐Ÿ˜ƒ

#

@graceful zephyr

compact bramble
#

Just a small note about the samples for Unity's Alpha networking on github, they use the wrong { brace format that the rest of Unity no longer uses (including when making a new default file)

#

(and other samples do have on new line, but indented by author personal preference instead of Unity's house-style)

#

I'l assume it'll all get fixed once it goes out of alpha

weak plinth
#

yeah it'll probably get cleaned up. i didn't see code style consistency for anything from file to file, down to variable casing, even within the same project. i assumed it was some dudes coding at full speed

graceful zephyr
#

morning o/

stuck void
#

@jade glacier managed to get my projectiles nice and accurate by piggybacking ability collision data on damage messages paired with extrapolating, just have a minor issue where the hit is missed at point blank range if the projectile hits on the server before its spawned on the client, but thats easily fixed with a buffer that temporarily holds recent serverside collisions on the client :)

#

took a fair bit of tweaking since the player can crouch with zero delay so its almost like a teleport, but it seems to be working with perfect accuracies at upwards of 400ms, so its looking pretty good

jade glacier
#

Nice

weak plinth
#

hey guys!
I'm using UNET in Unity 2017.4.19f1 to interconnect multiple Oculus Go.
I'm using the NetworkManager and I've got some issues.

One of my Go is setup as a network Host (server+client) while the two others are clients. Sometimes, they are able to connect instantly (I use direct IP connection with static IP address setup on my router) and sometimes one of my Go can't connect. When registering for Disconnect messages ( NetworkManager.singleton.client.RegisterHandler(MsgType.Disconnect, OnDisconnect);), it states "Timeout" as the last error message, and then I got a NullreferenceException when trying to read the message (ErrorMessage error = netMsg.ReadMessage<ErrorMessage>();)

#

FYI, connecting through the Unity Editor on my PC gives the same result than with Oculus Go

#

What is weird is every time I reboot my router (TP Link Archer C50), the connection is made instantly on first try

jade glacier
#

What are you doing for setting the connection IP with that setup? are you trying to go out through the firewall and back in? Or doing some kind of NetworkDiscovery?

#

@weak plinth

#

It sounds like you are using the internal IPs hand entering them?

#

You are direct connecting to a fixed ip on the local lan right?

#

It does sound like your router might be doing something funky

weak plinth
#

I did try to use the NetworkDiscovery. The broadcast were working, but it gaves the same result than direct connection after a few attemps. Since restarting the router solves the issue everytime, I started to think that broadcast/discovery might be flooding the network and somehow the router would blacklist it (rebooting = cleaning the blacklist). I disabled the broadcast and used direct connection, but the issue still occurs

jade glacier
#

If you are having a problem with hard typed ips... you will have a problem still with discovery I would think

weak plinth
#

I did setup my router so that it deliver a static ip address to my Oculus Go host, so I force my clients to always connect to that IP

#

Yes, but it was the other way around since I started with broadcast

jade glacier
#

Hard addressing local lan ips should be as bulletproof as it gets... if that is failing you have something wacky happening

weak plinth
#

I'm setting the network address, then NetworkManager.singleton.StartClient();

jade glacier
#

I am sure you aren't messing that part up.. setting an ip and connecting is pretty straight forward

weak plinth
#

I thought it would return a NetworkClient != null only when connected, but it appears it is not true. So I was checking .isconnected property afterwards, and when the router is freshly booted it is set to true, otherwise it is false. After a while I get the OnDisconnect event but can't read the message

jade glacier
#

if your machine is suddenly not getting those messages through, you have some network level weirdness it sounds like

weak plinth
#

do you think it's hardware related? I might try with another router

jade glacier
#

I got nothing for you, anything transport or below is black box to me

#

but it does sniff as sounding hardwareish

#

That is a very straightforward thing you are trying to do

#

lan connect by IP should be pretty problem free

#

Your program isn't creating a massive flood of packets or anything by accident?

#

that might be shutting down the ports or something?

weak plinth
#

Is is event based so I don't think so. So only thing that is sending packets continuously is the Oculus Go controller (i'm syncing the rotation)

#

yield return new WaitUntil(() => NetworkManager.singleton.client.isConnected); is the only way I found to listen for successfull connection event...

jade glacier
#

You could comment out all comms, and just see if things connect and stay connected with nothing being sent by you

#

just to eliminate that you might be doing something unintentional that isn't tossing up an error

#

You want a callback for when the connection has been made?

weak plinth
#

what's weird is let's say the Oculus Go Client nยฐ1 is blocked and can't connect, the nยฐ2 can if it didn't connect recently

jade glacier
#

you derive the NetworkManager class for that

#

and override the callbacks

weak plinth
#

oh ok, thanks for the tips

jade glacier
#

There are no callbacks available with UNET like that, its annoying that way

#

You have to capture that stuff by deriving NetworkManager

weak plinth
#

Good to know

#

It's true the documentation is not really straightforward

jade glacier
weak plinth
#

Well, I'll investigate and hopefully find the issue. I'll come back to tell you in case it's Unity related somehow, or if it was because of my router

jade glacier
#

But for yours, you can just derive NetworkManager on your own, and override the callback methods to get OnNetwork events

#

more instant that polling .isConnected every update

weak plinth
#

IOnStartClient is your list of registered listeners for that specific events, right?

#

List<IOnStartClient> iOnStartClient , I mean

#

Seems that you register interface as listeners, in addition to direct callback

#

Ok I'll derive from NetworkManager and see what the callbacks give as information

#

thanks again

#

Do you think it might be that a connection from Oculus Go 1 is not properly closed on disconnection, and that when trying to reconnect the host rejects the request as it thinks there is still a connection ?

jade glacier
#

There are two methods to subscribe to the events is all, its a generic callback wrapper so its just covering both cases

#

I like interface callbacks better, but they don't work for static classes, so I also added callback delegates for those cases.

#

@weak plinth Possible, even though I do a lot of networking, my knowledge of how things work transport layer and below is mostly just guessing

#

I deal more with the higher level api stuff above the transport

dusk kayak
#

does the new networking system support the relay sever system? I don't want to have to forward ports for MP

jade glacier
#

New networking system is just a twinkle in unity's eyes at the moment. It's just a transport last I saw. @dusk kayak

jagged radish
#

So there is no new info about the new network system?

#

I'm tired to get a lot of warnings about being deprecated and not having a new option xD

gray pond
#

@jagged radish Have you looked at Mirror as a replacement? Unity isn't even planning to replace HLAPI. They're just doing an LLAPI.

vital hawk
#

well, their fps sample is using the new transport setup, but that's like vertical slice of actual game

#

UNet has been given more time too

#

they didn't cut it out yet

jagged radish
#

@gray pond mirrror? No idea, it is too different?

vital hawk
#

I'd expect more news on the Unity's networking at GDC (starts in ~5 weeks from now)

gray pond
#

It's very similar...the components and API are mostly the same @jagged radish

vital hawk
gray pond
#

NO

vital hawk
#

it's literally the same thing

gray pond
#

We'd like people to start with the asset store version

vital hawk
#

oh wait, you don't have like stable releases on github?

#

"This is a bleeding edge release. "

#

that release list looks like master branch

gray pond
#

It is auto built from master, correct

vital hawk
#

also tags are weird

#

why don't you have like same releases as on asset store

gray pond
#

and I'm the wrong guy to raise git issues with - I don't run that

vital hawk
#

there are tons of releases and tags but not ones that would matter

gray pond
#

please save your rant

jagged radish
#

I just need to NAT punchthrough and send messages xD

vital hawk
#

yeah, I'll save the rest but still think that's not how you should use github

gray pond
#

NAT is added to the UDP transport @jagged radish

jagged radish
#

Y don't like commands, SyncVar etc.. I engineered my code to send a few messages per second

#

Cool, I'll check mirror out then

gray pond
#

We separated out the various transports as components @jagged radish so if you just want that part, we can cover you there too.

#

TCP, UDP, WebGL, and Steam

jagged radish
#

Wow it's great, in my last multiplayer game I was using Unet with a nat punchthroufg plugin and steam for matchmaking

vital hawk
#

why would you need separate punch through if you use steamworks?

#

I thought steamworks handles that for you

jagged radish
#

You can punch thorough with steamworks but didn't want to depend only on steam

jagged radish
#

Wow, the migration guide is super ez

#

XD

gray pond
#

especially if you're not using the full spectrum of Mirror / HLAPI

jagged radish
#

I'm just using NetworkIDs, NetworkManager and manage all the data in NetworkMessages

#

Commands and ClientRPCs generates a lot of overhead

#

And in a RTS game it would be unmanageable so many commands and clientrpca

#

Mirror seems very very good

gray pond
#

Star ratings and positive reviews are always welcome ๐Ÿ˜ƒ

#

@jagged radish

#

While you may still be right - we've done a ton of work on streamlining how Cmd's and Rpc's work

jagged radish
#

I'm thinking really hard into changing right now

gray pond
#

there's still alloc, and we know that

jagged radish
#

Oh yes, but I'd rather compress all into little messages and send it

gray pond
#

over the next weeks we'd like to get some profiling done and see what can be done. We've got a few things in front of that that will make doing so a lot easier.

#

Mirror's actually pretty smart about combining messages and bytepacking

#

e.g. if you change 3 SyncVar values in one tick, that'll be 1 msg

#

Your point remains valid, of course...just saying we're making it better ๐Ÿ˜ƒ

jagged radish
#

That is cool , unity's send one msg per syncvar I think

gray pond
#

I promise Mirror is not just a flip of Unet

jagged radish
#

Oh yes yes, I believe you

#

I'm thinking seriously to change the networking system

gray pond
#

Good! - As I said - if you need help, come to our Discord and ask!

#

Were you using Unity's services, or Lobby?

jagged radish
#

The invitation link has been deleted :(

#

I was using Steam Lobbies to know the IPs and matchmaking and then doing the nat punchthrough

gray pond
#

wtf?

#

I tried again and it immediately vanished - sent by PM

jagged radish
#

Maybe a bot is deleting the links to other discords?

#

Cool

gray pond
#

It's linked on the AS and Github too

#

I actually still see the first one - strange

jagged radish
#

I can't see the first one, that's weird

#

Now I can see it

#

Wtf

#

I talked with my buddy, yes, we're switching xD

odd rover
#

Sorry, but it's a policy in this discord to not allow other discords because Unity can't control what content is being shared in there. ๐Ÿ˜ƒ

#

But I can vouch the Mirror Discord is ๐Ÿ‘Œ and quick googling should find it!

jagged radish
#

Ooh ok, sorry!

gray pond
#

Tag me when you get there

solar garden
#

Hey sorry to bother but i have question i am learning to use unet so i made a game where you can host a server and join it with an other client, the two players works fine, but i have a problem with collisions, my two players can spawn rigidbody balls but i made them instanciate to the players position so when a player spawns them it raise the player up because of the collision problem is that if i do it on the server/host the player will raise into the air but on the client side it wont, on the server view we can see the client raise when he shoot but then he will interpolate back to its true position client side

gusty pumice
#

Hey guys, are there good resources for having a deeper dive into game networking ?
I've played with Photon and Unet for a couple of years. Read a couple of articles, blog posts and seen GDC talks about some of the popular concepts like client side prediction, ghost reckoning, etc...
but I need something more solid and informative about models\architectures and building a networking library. know what I mean ?

alpine oriole
#

@gusty pumice you might be interested in Kevin Kaymak's youtube channel. He uploads tutorials for making custom network solutions with unity.

gusty pumice
#

thanks @alpine oriole, seems a nice channel

jade glacier
stray scroll
#

Anyone know if there is more than the multiplayer repository with ping sample and FPS project to get into the new network layer? Any like basic text documentation or more samples? Some of the concepts are a bit weird right now.

untold plume
stray scroll
#

Thanks @untold plume , not sure how I missed that : )

gusty pumice
#

thanks @jade glacier, yea glen is awesome

untold plume
untold plume
#

new unity networking is interesting, but unfortunately for now not supports websockets

jade glacier
#

Its also just a transport last I looked.

untold plume
#

yep, it's only transport layer for now, also there are no specification for it ๐Ÿ˜ฆ

#

but the way they did it is quite good IMO

earnest wave
#

hey all i'm trying to focus on my games PUN networking today, get a few things fixed up

#

there's a few things that havent' been working out right for me, maybe yall have more experience with it

vernal remnant
#

Tobias is pretty responsive on the forums if you drop a message there as well

earnest wave
#

oh cool thanks

#

well i'll just rant here for now and then if nothing else that'll give me a summary to copy/paste into the forums

#

i thought i'd outline my general goals here and then how i actually make that happen is flexible

#

first off the game structure.... it's maybe 10-20 players at a time on a fairly large map of an island, like a shrunk down fortnite scenario basically. teams exist in squads of 1-3 players in size, there may be a solo only mode of same concept (10-20 teams of 1 person). On this island is also many monsters and enemy AI's. Players all fight against other teams and the monsters

#

Combat isn't exactly the focus of the game though. Really it's all about collecting these stones that are laying around, of which there are currently 50 of, randomly positioned at the start of each match... Currently i keep the position synced up on all clients by pulling the random position from a universally seeded random number (based on the room id), so everyones stones are in the same place. The stones don't move unless someone has picked one up, then it is in their inventory until they can take it to a big ring in the middle of the map, and when they throw or carry the stone through the ring, they get a point for it

#

if a player takes damage before they have put the stone through the ring, they drop one or more stones depending on how much damage they took

#

at that time the stones are laying where they dropped and can be picked up again by any player

#

the game is over when one team has gotten so many stones through the goal that no other team could catch up, so if there were two players, and 50 stones, the game is over when one player gets 26 stones

#

a lot of that is already functional but i'm not super happy with how its handled

mossy river
#

that sounds pretty cool!

earnest wave
#

hey thanks!

#

there are also loot chests around, with items that users can equip to improve their attacks / armor / mobility etc

#

when players die they drop their inventory

mossy river
#

are you making the game all by yourself?

earnest wave
#

i am yes

mossy river
#

wow

earnest wave
#

would you like to see a screenshot?

mossy river
#

I would ๐Ÿ˜ƒ

#

you must be pretty good haha

earnest wave
#

not really just obsessed

mossy river
#

who is doing your art?!

earnest wave
#

that's the island, it's a remote alien world

#

i am

mossy river
#

whut!

#

how

earnest wave
#

i am more of an artist than a programmer actually

mossy river
#

dude that looks amazing holy flip

earnest wave
#

for real?! wow thank you so much!

#

here is a little video clip from before i dressed up the terrain as nicely as you see above

#

it doesn't really show game play i was just trying to demo some new explosions

#

so giant monsters like this are around, and they are also picking up these stones

#

to get stones that a monster is holding you have to kill the monster

mossy river
#

that looks so cool!

earnest wave
#

wow thanks man ! i'm so glad you like it

#

i've been working on it so hard th elast two months

#

it's going to be a mobile / pc game

mossy river
#

mobile?

earnest wave
#

yes

mossy river
#

will phones be able to run that?

earnest wave
#

yes but some of the detail may be reduced

#

want to hear how i'll make phones run that?

mossy river
#

yeah sure

#

sounds interesting

earnest wave
#

ok so in the video, you see 'just terrain', no clutter

#

in the still image, you see terrain + clutter

#

the craggly rocks etc on the side of the cliffs, that's clutter

#

the terrain is actually just a big static mesh

#

not a unity terrain

#

i wrote a custom shader for that and phones can handle it just fine

#

so just the static terrain on a phone, not a problem... 30+ fps all day no problem

#

now all that clutter tho, that'd be a problem

mossy river
#

so for how long have you been programming?

earnest wave
#

very long time. I'm old

#

30+ years

mossy river
#

"old"

earnest wave
#

well i guess it's relative, but i feel old... anyways

mossy river
#

could you teach me some thing when we both have time maybe?

earnest wave
#

of course

#

i like to share techniques and help people

#

so ok, about putting this on phones

mossy river
#

yeah

earnest wave
#

to make that static terrain mesh, what i do is have two versions of the island, a high mesh version (3 million polygons) and a low mesh version (about 100k polygons for the whole place with caves)

#

then a mesh collider that is about 15k polygons

#

eventually i'll have a script carve the whole place up into chunks too, maybe like 8x8x4

#

so each chunk will be maybe 2-4k polygons with 500-1000 polygons per collider chunk

mossy river
#

that shouldnt be a problem for phones right

earnest wave
#

the high mesh version gets baked into the low mesh version

#

not at all

#

so blender takes all the nitty gritty detail of the high mesh and renders it as a normal map and ambient occlusion map of the low mesh

mossy river
#

yeah at my internship we are also making a mobile game so I hear the artist talk about the polys a lot

earnest wave
#

its less of an issue than it used to be but its still real important

#

so ok i can take a 3mllion poly mesh and show it to the user in realtime as 100k mesh (which phones also handle pretty much fine even without being chunked up)

#

but right now that 3 million mesh looks like yous aw in the video, kinda empty and very rounded off, like melted butter a little

#

then i staple lots of clutter to it, and it looks more real. the rock chunks especially

#

so what i'll do is, from unity, export every single bit of rocky chunk i added as one big giant OBJ file

mossy river
#

isnt clutter also pretty expensive for performance?

earnest wave
#

yes

#

and what i'm about to describe will eliminate most of it

#

so one big OBj file of many rocks, rocky chunks of cliff, that kinda thing

#

no trees / grass though this is just the things that are basically ground

#

then inside blender i will take the 3 million poly version of the terrain and 'shrink wrap' it to those chunks of detail

#

so it'll push out the terrain to match all those detail chunks

#

then i'll do the same for the low detail version, and now both terrains will basically resemble what you saw in the first pic

#

then i will render the high mesh version down into the low mesh so it makes a fancy normal map and occlusion map of it

#

and boil the low mesh version down into an even lower mesh version and that will be the mesh collider that all users use regardless of platform

#

so now with that new terrain mesh, i can show the same basic environment to mobile users, but they won't need 90% of that clutter

#

so mobile users will get that version of terrain, and most clutter removed.

#

desktop users will still get the original terrain + separate mesh clutter the way you see in the pic because that does look better

mossy river
#

but you will be using a mesh collider? I guess you kinda have to with such a huge object

earnest wave
#

and it should all run very well on mobile

#

yes but it'll actually be about 100 mesh colliders

#

one per chunk of terrain

#

each chunk will be about... maybe two acres in size

#

so whats that about 100ft x 100ft, or maybe 30m x 30m

#

i think i'm off on the sizes there but you get the idea

#

it won't be just one giant mesh collider

#

does that sound like it'd work to you?

#

i think it'll work fine

mossy river
#

sounds like it would work

#

yeah had to put some colliders on weapons and tools for my internship

earnest wave
#

it should look like basically the same place too

mossy river
#

but I had to avoid using mesh colliders

earnest wave
#

yeah they're generally kinda overkill

#

i might be able to avoid using mesh colliders for a lot of the overworld

#

just use an elevation map or something

#

but there are a lot of caves too

#

huge caves all through that place

mossy river
#

well if it works with mesh colliders that should be fine too right

earnest wave
#

seems like it

mossy river
#

its kinda lowpoly ish

earnest wave
#

even mobile handles terrain + one big mesh collider just fine as is

mossy river
#

at least not highpoly xD

earnest wave
#

its the clutter thats the issue

#

so with rock reduction like i mentioned, clutter should be reduced to basically grass + trees for mobile

#

the grass i'll use a special lightweight shader for, and make it optional so user could turn it off entirely if they want

#

the trees aren't really that taxing, it's not exactly a forest

mossy river
#

is it hard to make a shader?

earnest wave
#

most of the trees don't even have leaves and thats intentional

#

yes gotta say, kinda is

mossy river
#

i mean we have shadergraphs now

earnest wave
#

some people have an easier time with it though, you should try it out

mossy river
#

but that isnt optimal i suppose

earnest wave
#

i'm kinda old school

#

i do everything like i just escaped from the mid 90s

mossy river
#

hahaha

earnest wave
#

so ok, you're up to speed on my basic outline now yes?

mossy river
#

yeah I think so ๐Ÿ˜ƒ

earnest wave
#

great ok, thanks for listening

#

now what i want is better multiplayer

mossy river
#

multiplayer also sounds difficult to do

earnest wave
#

so what i'm doing now relies heavily on PUN transform views

#

and raiseevent calls

mossy river
#

what is PUN?

earnest wave
#

uh oh!

mossy river
#

Im kinda new to programming haha, im programming for 2 years now

earnest wave
#

cool it's the Photon networking library

#

haha hey welcome to programming dude!

mossy river
#

haha thanks

#

its way easier that I always thought it would be

#

I was like

#

its gonna be 0010101010

earnest wave
#

oh man its like, great for all kinds of things in life too

#

if you can fix a buggy program, you can apply that to all kinds of buggy stuff in life that has nothing to do with programming

#

cause its the same basic process

mossy river
#

I mean it also helps to think about solutions

earnest wave
#

exactly

#

hey miki

#

hows going

#

i know a lot of the people here from another server jorrit

#

me and miki been chatting for months now

#

so ok i need some people with PUN experience to advise me on some stuff

#

if any should come around please ping me and we'll chat

vernal remnant
#

what do you actually need

earnest wave
#

ok i'll outline it

vernal remnant
#

It began talking about your game theory and then branched off into switching to mobile platforms

earnest wave
#

each game has a 'gameReferee' class, and that is responsible for spawning those stones, awarding points for conversions, keeping track of who is currently holding stones, and sometimes respawning the stones if something happens where their position resets

#

so i'd like that gamereferee to be scene owned

#

and to have an array of 50 stone objects and to upkeep their basic status/position data through serialize view, constantly

#

their status would be an int and represents either 'sitting on the ground', 'already converted', or 'in the posession of player #X'

#

also sometimes their status is 'in mid air'

#

since they can be thrown

mossy river
#

can't you just make an event for when the status changes?

earnest wave
#

yes probably

mossy river
#

use the one too many pattern

earnest wave
#

i'm trying to get this planned out a little more solidly

mossy river
#

should work great for this right?

earnest wave
#

maybe! sec lets see what squiggly-marks-name thinks here

vernal remnant
#

So your rules are contained in your GameMode, which will only want to exist on server, you will have to attribute all your game mode stuff with [server]

Individual stones you might need to do client side prediction

earnest wave
#

squiggly what should i call you

#

but if its PUN, there's no server, right?

vernal remnant
#

Other stuff looks like you only need players to know the state of the stones

earnest wave
#

there's 'masterclient'

vernal remnant
#

ah ye its in that bs style

mossy river
#

so 1 player hosts the match?

earnest wave
#

correct

mossy river
#

or am I understanding it wrong

earnest wave
#

well sorta

#

it's weird man

#

one player and sometimes that player changes

#

mid game

vernal remnant
#

I think there are still server RPCs but they are more 'running on master client' which can be altered by the main player

earnest wave
#

i'm not worried about cheating at this point

#

i just want it to function and then i will worry about that

mossy river
#

yeah I get that haha

#

having a server sounds easier tho

earnest wave
#

side note, i need a 'lootManager' that basicallyd oes almost the same stuff as the stone manager

#

yes much easier

vernal remnant
#

start small by synchronising the states, the smaller the better (probably an enum)

earnest wave
#

well thats where i'm having issues

mossy river
#

no state machine?

earnest wave
#

state synchonization with PUn is mostly through 'serializeview' sequences

#

which sorta pass the data around in a big circle

#

and for me, its not working

#

it should be, i'm doing what the tuts/docs/samples say to do, but its not working

#

so because of that i'm doing it another way, with 'raiseevent'

#

which is... similar but not as good

#

if i do this with serializeview it could easily track / synchronize the status / position of all those stones all the time, no problem

vernal remnant
#

Would you get away with defining [PunRPC] and forcibly pushing out the information?

earnest wave
#

maybe for everything but the 'stone is in midair being thrown like a football' status

vernal remnant
#

If its actually being thrown you can sync up their physics state

earnest wave
#

cause the rest is basically one int, stone is either at its spawn point or its in a players possession

#

well i'm trying to avoid using physics for this as much as possible

#

i pre-calculate the physics from positions / directions / velocities that are all the same on every client

#

then progress through those precalculated paths by time, and it keeps everything the same

#

i need @indigo current in this convo ๐Ÿ˜„

#

he's the PUN master

vernal remnant
#

almost sounds like old replication in directx

mossy river
#

but what is the exact problem again? cause it sounds like you can just make a one too many pattern right?

earnest wave
#

could you explain one-too-many pattern please i don't know that one

vernal remnant
#

I only refer to that for relational databases

mossy river
#

yeah I don't know how multiplayer exactly works but you could still use it on the main host right?

#

ill look for a good definition btw

earnest wave
#

lol pun is such a pita

#

it's its own animal

vernal remnant
#

I dont think theres much for an authoritive server in unity

#

other than spatialos

earnest wave
#

lotta general MP practices just don't apply with it

#

i would actually prefer this 'no server' appraoch for now

#

i have... no money

vernal remnant
#

Yeah, more recently server architecture has been hot seat client masters

earnest wave
#

can not afford a server

#

i will need funding before i can really ramp up my networking

#

to get funding i must release a working version

#

even one that only supports one game at a time, that'd be enough i think

vernal remnant
#

stick with pun then

#

spatialos is pretty much an engine itself

earnest wave
#

well the good news is i have almost all my networking stuff bottlenecked through one main 'NetSplice.cs' file

#

so the idea there is i can shop around for networking architectures with minimal recoding

#

ok i'm going to get into my code here

#

i think i have half a plan jelled out here, i'm just going to start over with my stone manager

#

this shit is busted and i need to fix it

mossy river
#

The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.
It is mainly used to implement distri...

#

they also mention the one too many pattern briefly

#

but I cant really find a better definition

#

head first design patterns is where i got the pattern from, amazing book

earnest wave
vernal remnant
#

C# has the actual code for it you would just have to implement it, i think it has other patterns as interfaces as well although getting wrapped around one would require a bit more than just a simple code

mossy river
#

yeah in the book they mention that java has some libraries as well but they still think its sometimes better to just make it yourself

vernal remnant
#

properties are a very basic example of observer

#

changing them raises their set method

#

but thats off topic

earnest wave
#

wow i hate the PUN docs

#

PhotonView component docs are... where... i have the class ref here but it's not actually explaining what any of these settings are in the component inspector

#

like what is 'Observe Option', seems super important

#

maybe this? public ViewSynchronization Synchronization;

#

all the CHM has about that is that it is an enum. two hits in the whole class ref doc, no further info about it

#

all the other properties have comments about them in the PhotonView.cs, that one has nothing

jade glacier
#

Is it a reference to the channel used?

#

yeah, at a glance its just indicating the reliability, though not sure how its implemented without digging into it

earnest wave
#

well i found this

jade glacier
#

its all C#, so you can just trace that enum to see where it leads

earnest wave
#

but i need to open the inspector editor to actually see what that option is accessed as

#

i think it's that syncho var

jade glacier
#

its basically the reliability channel it looks like

earnest wave
#

trying to figure out why i get OnSerializeView calls if i'm the master client, but if not, i don't

#

i should at least get them to recieve data even if i'm not the master, right

#

aaaand unity crashes on me

jade glacier
#

I would assume that depends on the replication settings

earnest wave
#

such a pain in the ass

#

it's a scene owned object

#

i want one component as a referee to the game

#

that manages the state of game objects in my case 'stones'

jade glacier
#

Scene owned by default become MasterClient owned I believe

earnest wave
#

right now it just needs to send an array of 50 ints each update

#

right

#

so if i'm the master client, i do see data sends in the debug

#

if i'm not the scene owner, i get no data sends or recieves, nothing

jade glacier
#

makes sense. The targets are indicated by the options flag

earnest wave
#

why wouldn't i get receive data events tho

jade glacier
#

Would have to have to code open in front of me. I generally do all of my own raiseEvents with PUN, so I don't have much experience with the PhotonView and RPCs

#

outside of I just pull the ActorId and EntityId from PhotonView, and don't use it otherwise

earnest wave
#

the only sucdess i've had so far is with raiseevents

#

those work great for me

#

also transformview's

#

but i really want to figure out OnSerializeView

jade glacier
#

You can look at what transformview has in it, its using OnSerializeView

earnest wave
#

just makes no sense to me

#

i just wish i didn't have to unravel all this stuff, seems very counterintuitive

jade glacier
#

What component is doing the syncing right now thats not working?

#

And you are sure that your clients are all in the same room right?

earnest wave
#

ok i'm getting data receives now that I changed observe option to 'unreliable'

#

yah we can move around and see updates

#

that parts working but its based on transform view

#

me and the other clients can fight to the death thats all fine

jade glacier
#

If you have your channel to off.. I would think it wouldnt send anything

earnest wave
#

no its not off, it's 'unreliable' now

jade glacier
#

Not sure why the choice for defaulting that to off

earnest wave
#

it was 'unreliable on change'

#

apparently it's... extremely unreliable

jade glacier
#

ahh, nothing was triggering the change in your code probably. Not sure what it uses to trigger the delta

#

unreliable on change seems like a pretty useless mode to me

earnest wave
#

it's extremely unclear about that

#

'something changed'

#

well, things were changing

jade glacier
#

either I want Reliable if its a rare event... or I want to spew it regularly with unreliable

#

I'm actually chatting with the writer of it right now... like me to convey your dissatisfaction LOL

earnest wave
#

no it's a lot better than anythign i've written like this i just wish the docs made more sense

jade glacier
#

It definitely doesn't hold your hands, esp with PUN2 - almost nothing tutorial wise and such yet

earnest wave
#

ok so my array of 50 ints is synchronizing but only if i use 'unreliable' which is updating them all every frame

#

which is... acceptable for testing but not practical for runtime

jade glacier
#

you'll want your own scheme for organizing and culling that most likely

earnest wave
#

yeah i was thinkinga bout a 'dirty' flag

jade glacier
#

PUN offers this stuff as basic wrappers for people who have no idea what they are doing

#

But for moving big states, you really want a whole serialize/deserialize scheme of your own

earnest wave
#

so player picks up a stone, marks it locally on the master, sets the array as dirty witha bool, and if that bool is tripped in the onserializeview, it writes the data to everyone else

jade glacier
#

with your own handling for prioritization and partial sends and such

earnest wave
#

but i'm not sure how that works out with 'unreliable'

#

like if i only send it once, and not everyone got it, whats up then, i don't know

jade glacier
#

That kind of stuff never "just works" - it always requires you to come up with the communication schemes for them and how conflicts resolve out

#

because you will have client prediction on the one side... and the server reality on the other... no matter what the scheme

earnest wave
#

or... no server, as the case may be

jade glacier
#

So you either need a reliable method of making sure certain events get through, or a design that is tolerant of eventual consistency

earnest wave
#

can you get the author in here maybe? or me around there, and they could help clear some of this up? I swear once i get a basic framework setup i will leave them alone i think i just need a reliable way to keep one objects arrays synched up and i have the rest sorted out

jade glacier
#

yeah, I mean there is no "answer' for most of this - you have to decide where and how you want to handle your desync

earnest wave
#

and i sort of have it i just want to make sure i'm doing it right before i double down on my approach

#

cause i'm about to add a bunch more arrays for stuff like loot status, monster status, bullshti like that

jade glacier
#

I had tobi join a few days ago, but I think he is too busy and just checked out of discord

earnest wave
#

i don't blame them

jade glacier
#

He can't answer those particular questions anyway

#

those are very game specific, and not specific to PUN

earnest wave
#

if i wrote photon i'd avoid discord like the plague too and i'd never let anyone know who i was

#

sure i'm just looking for a best practices kinda thing

jade glacier
#

I don't think he actually has any issues with discord, it just was quiet when he joined. I think he was hoping for more lively convos with fholm and I, but we both vanished

#

PUN is pretty much just a transport... its just requires a slightly unique approach because of the relay server instead of an actual game server

earnest wave
#

relay server = master client, yes?

#

thats the next big question mark for me

jade glacier
#

Well, PUN is a HLAPI on top of the photon transport... but you likely want to skip over most of what PUN does for you on the HLAPI side

#

relay server is the in between server

earnest wave
#

how do i make sure that if master client disconnects mid game, everything keeps chugging along

#

it seems like it's trying to just make that auto-magical

jade glacier
#

basically Photon with PUN uses a relay rather than punchthrough

#

so all clients can talk to all clients... through the relay

earnest wave
#

which is fine by me but i'm not sure i'm playing ball correctly with the magic yet

jade glacier
#

rather than the server model... where all clients talk only to the server

earnest wave
#

i see

jade glacier
#

So in PUN the Master can ACT like the server... but its def not a server

#

its just a client on the same wheel of spokes as any other client

earnest wave
#

seems like... why not just have a server

jade glacier
#

everyone talks through the relay to everyone else

earnest wave
#

keeps server load down?

jade glacier
#

Because then you have to host game logic on a Photon server

#

and this is to avoid that

earnest wave
#

right so this way game logic is client side

jade glacier
#

they do that, but this isn't that

#

The PUN model is all about having clients cohost

#

and being serverless

#

Master exists so that you can designate one client as being the authority of some things

earnest wave
#

ok diff question then

#

how much data can i sling around every OnSerializeView before its a problem

jade glacier
#

but you don't want to lean on that too hard, because that Master is 2 hops through the relay away... so laggy and consumes bandwidth

earnest wave
#

a few bytes, 100 bytes, 1000 ints, what?

jade glacier
#

I was just pushing 2K bytes over my wifi in a test a couple days ago

earnest wave
#

i mean that seems like a lot more than i actually need

jade glacier
#

Not recommended, thats abusive to clients, data costs... mobile...etc

earnest wave
#

i really need it setup to only send data when it needs to, not every update

#

99% of that is redundant

#

almost all of the things i'm updating don't move

jade glacier
#

yeah, it will be on you to trim down your serialization and prioritization to as thin as you can

earnest wave
#

they just get picked up and very rarely, thrown

jade glacier
#

but for testing you can be pretty bloated

#

I would avoid drowning yourself in network optimization too early

#

because most of that work will keep getting tossed

earnest wave
#

yeah thats my plan right now

#

just anything fully functional then i'll break it as necessary to fix it better

jade glacier
#

Do think though of your data structures efficiency

#

and how well it will trim down

#

The structure will be hard to change later

#

but compression is pretty easy

earnest wave
#

ok waht about this as an approach to onserializeview

#

first thing i send or receive is an update descriptor, just a byte that says 'this is the kind of update to process'

jade glacier
#

Just be aware that all OnSerializeView is is an automated RaiseEvent op

earnest wave
#

so if the byte is say, 1, that means 'full update, going to get a big bunch of arrays'

jade glacier
#

If you already know how to raise events... I would just stay there

earnest wave
#

and if byte is 2, that maybe means 'only updating stones status'

#

raise events is working great for me

jade glacier
#

I would use bits for flags like that

earnest wave
#

i figured serializeview as more performant

jade glacier
#

you can use enums

#

and bitpack those

earnest wave
#

sure, whatever i do to describe the update, thats fine

#

my question is more like

#

can i change the model of the data received while i'm receiving it

jade glacier
#

yeah, you can do all kinds of flags to indicate what is included

earnest wave
#

ie can i get that first byte and then use that to change how i read in the rest of the stuff from stream

jade glacier
#

That is more serializaton

#

yeah, you generally have headers to indicate what follows

#

but I use single bit switches all the time

earnest wave
#

ok cause none of the samples i've seen so far do that and i don't understand why not

jade glacier
#

like when I serialize a transform, it is preceeded by a single bit...

earnest wave
#

seems kinda like... mandatory

jade glacier
#

true = a transform follows... 0 = nothing... move to the next read

earnest wave
#

ok so maybe one byte witha bit for each kind of array tha tmight follow

jade glacier
#

But that isn't your data structure

#

that is just your serialization

earnest wave
#

so if 2nd bit is true, expect an array of loot statuses

jade glacier
#

for every object, you will create a Serialize and a Deserialize

earnest wave
#

then when masterclient is pushing data out make sure those bits match what its sending

jade glacier
#

and in those methods you can get as fancy pants as you want with packing

#

all that matters is that it reads exactly the same number of bits that were written

earnest wave
#

for now its just a bunch of arrays of basic data types

#

i just need to make sure that the first byte is always the descriptor

#

not... somewhere in the middle of the last update or something

jade glacier
#

If its a lot of stuff, determinism might be more where you want to take that

#

but I don't know the details

earnest wave
#

well i appreciate your input on this in any case man

#

thanks, seriously

#

such a murky mess

jade glacier
#

but with determinism, you just reliably send that inputs to the sim... rather than the sim state

#

Just start simple

#

And remember to keep things broken up into objects that serialize/deserialize themselves

#

You can refine those methods later, and for starters just push giant byte[]

#

but you want to keep your structure clean

earnest wave
#

i'm wondering if i could have a bunch of floats each client keeps local, that represents when the last time they updated their dirty arrays was

#

and they always send that to everyone else

jade glacier
#

Avoid floats and even time as a measure of anything for networking

#

if you need syncing up... you want to use numbered ticks

earnest wave
#

and then the masterclient reads those, and if ever any of them is less than its version of when the last time it updated those arrays, it keeps sending them

#

ok ints then

jade glacier
#

Get your sim engine and network sends on the same tick

earnest wave
#

but some 'update reference id'

jade glacier
#

then the world history becomes a series of ticks, like a movie

earnest wave
#

and that number only increases

jade glacier
#

For most things, you go with a circular buffer

earnest wave
#

so i send new stone statuses, along with a 'last stone status update tick counter'

jade glacier
#

since you don't really need 33000 history ticks

#

like I generally use a 60 frame circular buffer for everything

#

so my frames are numbered with 6 bits

#

0-59 frame numbers

earnest wave
#

then clients receive stone status, or they don't, (unreliable), but in either case, they keep sending their 'last stone update tick counter'

jade glacier
#

For unreliable you just send once

earnest wave
#

master client keeps reading those 'last update tick counter's

jade glacier
#

if the others didnt get it in time or at all... they extrapolate and the next unreliable corrects any bad guessing

earnest wave
#

and until they are all up to it's value, it keeps unreliably sending them

#

right but i only want to send this when a player picks up a stone

#

so it could be a lot of updates between

#

its not position data

jade glacier
#

nope, if you repeat unreliable until its acknowledged... thats reliable

#

the point of unreliable is to be unreliable

earnest wave
#

its just a byte of 'stone is on the ground' versus 'stone is picked up by viewID' etc

jade glacier
#

Every client sends its numbered unreiliable tick once per sim.... and never again

earnest wave
#

right but if i switch to reliable it does 'on change compressed' or whatever and that's just flat out not working

#

i need reliable

jade glacier
#

I wouldn't "switch" to relaible

earnest wave
#

but for this its not working yet

jade glacier
#

I would send things that need to be relaible... as relaible

#

and don't mix them with your unreliable

vernal remnant
#

Things you cant live without should be reliable

jade glacier
#

for example, a map change shouldn't be comingling with your player transform updates

earnest wave
#

that was the first thing i tried and it's not triggering recieve events in my clients

#

master client does write them, non master clients dont receive them

jade glacier
#

Keep critical stuff separate from the lossy firehose

earnest wave
#

yes that sounds reasonable but its not working

#

i don't know why

#

i cant make sense of the docs

jade glacier
#

You might just need to step back and pick at the problems one at a time

earnest wave
#

yah i'm trying to, i've been putting off some of this for weeks while i dick around with posing monster necks and adding slug monsters and random bullshit

#

i gotta get this networking locked down

jade glacier
#

What are you trying to send as Reliable right now?

earnest wave
#

the status of each stone

jade glacier
#

LOL... "networking locked down"

earnest wave
#

is it on the ground, or is a player holding it

#

there are 50 stones

indigo current
#

@earnest wave @mossy river @vernal remnant what?

earnest wave
#

hi punfish

vernal remnant
#

Eyman i didnt tag you

earnest wave
#

your tutorial has been helping me man

#

i tagged you

indigo current
#

Doesn't matter, you were co-conspirator

earnest wave
#

i'm jsut trying to sort some shit out here and struggling against the docs

#

or...lack of docs, whatever

jade glacier
#

Are you trying to pass authority over the stone?

earnest wave
#

no the stones aren't even observed

indigo current
#

There's two different docs

earnest wave
#

they don't need to be

indigo current
#

One is usage docs which kind of sucks, and then there's the api

earnest wave
#

i have a stone manager, and that manages the status of all of them

#

can you link me to all of them please so i know i'm on the right ones

indigo current
#

But seriously, why was I tagged haha. I you need something?

earnest wave
#

i'm using the CHM, what i can figure out fromt he website, and the pun forums

jade glacier
#

Ok, but then you still have to assign an Actor ID as the owner of these stones and make sure everyone knows? @earnest wave

earnest wave
#

punfish well i'm trying to get my stone manager working and so i'm tackling onserializeview

indigo current
#

You can't use actor ID because it's not consistent over Photon.

vernal remnant
#

He tagged in hopes you would have had a more solid implementation for him to consider using in his current scenario

earnest wave
#

i've had some success getting it to update but only if i use 'unreliable'

indigo current
#

You use Photon view ID or Photon player

earnest wave
#

yes this

#

emot the holder of the stones is referenced by viewID

#

and that is now working but only if i update every single update

indigo current
#

That works fine

#

In what way

earnest wave
#

but its sending so much data

#

ok lemme try to slow down and lay out my plan a sec

indigo current
#

Hold on

mossy river
#

why don't you make events where they should update?

indigo current
#

What do you mean every update

mossy river
#

you shouldnt have to do it in the update right?

earnest wave
#

every onserializeview

indigo current
#

Okay that's not every update

earnest wave
#

yes jorrit i know but thats not working right and i dont know why

#

kind of three conversations going on here

indigo current
#

Yes it sends data constantly but it only sends what the network can handle

earnest wave
#

punfish while you're here, you're the biggest pun guy in the room i think, i'd like to talk to you directly about this if yall others don't mind

#

ok so here is the plan

jade glacier
#

Pretty sure ActorId is the same for all clients in a room

indigo current
#

It's not

jade glacier
#

Has that changed maybe?

#

The server assigns its value

earnest wave
#

i have a stoneManager, and it is monobehaviorpun with a photonview, and the stoneManager is the observed component

indigo current
#

View ID is the same.

jade glacier
#

Each player has an actorId (or ID), valid for that room. It's -1 until it's assigned by server. Each client can set it's player's custom properties with SetCustomProperties, even before being in a room. They are synced when joining a room.

earnest wave
#

the stoneManager has an array of 50 ints for now, one for each stone

indigo current
#

Gameobject ids can be different

jade glacier
#

View is a networked object, the Actor is the connection Id

earnest wave
#

those ints represent the status of each stone, theres 'on the ground', 'converted to a point', 'in midair' or 'in viewID's possession'

indigo current
#

Okay so when you said actor id I thought you were using that as a term for gameobject

jade glacier
#

The PhotonView does contain the ActorId as part of its value I believe as well?

earnest wave
#

the last status is indicated by a negative number which is the viewID, negative

indigo current
#

Because in Ue4 gameobjects are called actors

jade glacier
#

I hope ActorId is the same across the network... otherwise I have been putting some very borked shit on the asset store ๐Ÿ˜ƒ

earnest wave
#

so i want to send that array of ints from the masterclient to everyone else, every time someone picks up a stone, converts it to a point, or thorws it

indigo current
#

Okay

earnest wave
#

that is now working if i set the observe option on the stoneManager's photonview to 'unreliable'

#

but it is doing it very often, much more often than is necessary

indigo current
#

Why not just move that logic to the stones then so it only fires when stone is in use

jade glacier
#

The reliable option may require some kind of dirty command

indigo current
#

Also on serialize is going to send every network update, that's normal.

jade glacier
#

again, I just use raiseEvent, so I just avoid this whole issue

earnest wave
#

but if i only send it the time that it changes, i'm not sure each client will actually be in sync, and if i change that observe option to 'reliable', for some reason non-master clients never seem to receive any data at all

indigo current
#

But it will drop excess packets, which is also nornal

jade glacier
#

you probably should as well... just raise events on your own tick

indigo current
#

Oh right yeah that's a fun one

jade glacier
#

You are planning to make your own serialization scheme for this stuff to byte[]... so just stick with raising your own event

#

and refine the serialization later

indigo current
#

You could add an event that when the object Awake to request current states via rpc

#

And only send to that one person

earnest wave
#

ok, that's doable i have a raiseevent system in place and thats working fine

#

and i could do all this with raiseevent, i know. i might.

#

but i want to get onserializeview figured out

#

currently its just a big fuzzy question mark for me and i hate that

jade glacier
#

Yup, just have a means to request a data dump.

#

Its going to end up looking the same with or without OnSerializeView... you will just be controlling the send intervals is all

earnest wave
#

what i'd like is a reliable way to say 'master client detected this array of ints needs sent to everyone'

#

and then know that sooner or later, everyone is going to get those ints and apply them locally

jade glacier
#

How you dirty up your data is pretty much up to you

indigo current
#

You don't do it that way, if u want to sync on joins only

earnest wave
#

no this gets changed often midgame

#

players pick up the stones

#

thats the scoring system

indigo current
#

The easiest way is when the mono Awake method is call is to request the data if not master client

earnest wave
#

so yes onjoin will require full update

indigo current
#

Awake only calls once so you know it's being instantiated for the first time

earnest wave
#

but after that, updates when dirty

indigo current
#

You can choose when to transmit on serialize

earnest wave
#

yeah thats what we were discussing when you came around

#

the idea that the first byte of stream data describes what follows

indigo current
#

You could just add a bool check to not send the data

earnest wave
#

and so i read that and based on its value, that determines what i read from the stream next

#

is that reasonable?

indigo current
#

But you have to check data lengths when reading and parsing

jade glacier
#

Yeah, how you delta and such is going to be completely up to you

#

Pfft... data checks

earnest wave
#

like if the stone's array is updating, first byte might be a 1

jade glacier
#

Just make your serailize and deserialize flawless ๐Ÿ˜ƒ

indigo current
#

First byte is a good idea too

#

A very common practice

earnest wave
#

so clients read first byte, if it's 1, they say ok read from stream an array of 50 stone status ints

#

ok so that's a plan i'llt ry

jade glacier
#

I have a ton of single bits inline indicating if something expected will follow. One of many schemes for this kind of thing.

#

Though keep in mind if your byte header gets bloated enough....

#

you may as well just send a different event code

earnest wave
#

but if first byte is 2, that may mean... update the loot status array

jade glacier
#

since PUN already is slapping a byte header on your packet

earnest wave
#

and if 3, update the monster status array

#

btw i realize it would be better to use bits for this

#

so i can combine, and i may do that

jade glacier
#

I would learn about bitpacking before you make any schemes

earnest wave
#

jsut trying to simplify for sake of convo

jade glacier
#

because your byte idea will go out the window when you realize you can pack this stuff with any number of bits

earnest wave
#

yeah i know, like layermasks yes?

jade glacier
#

even those assume even bytes

earnest wave
#

yeah just trying to simplify the convo

indigo current
#

The idea of on serialize though is that the data eventually gets there. You can't just toggle streaming off randomly and assume everyone got the data

earnest wave
#

right, thats the part thats kinda irking me

#

like what if master client says 'ok, its dirty, send it once'

#

and 3 out of 4 non master clients get the data but that 1 of 4 didn't

jade glacier
#

You will end up taking multiple passes at your serialzation methods when you start trying to get the data rates down

#

don't kill yourself with it now

earnest wave
#

this conversation is just killing my ADD

#

fuck

#

i gotta go, sorry

jade glacier
#

Just be aware of these things, don't worry about most of it yet

#

no worries

indigo current
#

"If you skip writing any value into the stream, PUN will skip the update. Used carefully, this can conserve bandwidth and messages (which have a limit per room/second).

Note that OnPhotonSerializeView is not called on remote clients when the sender does not send any update.

"

#

So it's better to not send any data then to use a byte saying no data is available

earnest wave
#

byte says 'data type A / B / C' incoming tho?

#

sometimes A/B/C all equal false, then its no data

indigo current
#

Depends how you use it

earnest wave
#

but sometimes it's just A, no b or c

indigo current
#

It's better to send no data than send a byte that says there's no data

earnest wave
#

k

indigo current
#

If you don't send data, others don't get a receive

#

So there's no risk of trying to parse what isn't there

#

What irks me is it doesn't say if the last sent eventually gets through

#

I've looked for that information high and low in the past. Could ask on their forums.

jade glacier
#

Though, eventually you will be bundling EVERYTHING unreliable up into one write, and that write will lead with a frameid

#

But you can lead most items with a one bit flag indicating if they were included or skipped

earnest wave
#

if a scene owned object is in it's OnSerializeView, and it's the master client, it's only writing, yes?

#

and on non master clients, it's only receiving?

indigo current
#

Yes

earnest wave
#

k thanks

jade glacier
#

Not sure if there is a setting to make master get its own write

#

I forget the options for targets

indigo current
#

It's been awhile since I've used photon. You might need to handle that manually

#

But that's how you're supposed to design it

jade glacier
#

its indicated by the receve opts flag

indigo current
#

Iirc stream.iswriting is true for master

#

And is receiving for others

jade glacier
#

yeah, that weird unified Serialize method

#

Every other networking library has a Serialize and a Deserialize... Tobi for some reason unified them

indigo current
#

Also if you haven't figured this out already, turn off rigidbodies or make kinematic on non masters

#

Non owning *

#

Assuming they're synchronized

#

Another useful bit for streams.. If you want to have responsive actions to data changes but don't want to use reliable or raise events you can pass the data though a "Set Value" method which checks if its changed

jade glacier
#

Using properties to auto-dirty is a thing for sure

indigo current
#

It's pretty useful