#archived-networking
1 messages ยท Page 43 of 1
ahh, so you need determinism ๐
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
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
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
not being pvp also makes things a bit easier
yeah pvp is something I'll tackle on a much later date
Its still going to be history that the player sees around them
because everything is interpolated on the past, and not extrapolated
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
@graceful zephyr do you have a default sample game scene you use for any of these tests? Or are they pure data streams atm?
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
@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
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
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
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
which.. projectiles are
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
@cosmic atlas he already is server auth, so he is just sorting out how to hide the fact that the player is seeing history
aye
@stuck void Every little bit helps
yeah this is just for fixing up visual disrepancies on the client
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
might be worth a try
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
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
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
its 2d as well so it wouldnt be a noticeable improvement as in 3d
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
ye I think I'll just go with a simple server telling the client when it hits tbh
yup, should always start there anyway
main issue is when the projectile never hits at all on the client
see the actual problem you are trying to solve before going crazy with it
a bit of delay and it hitting slightly beside the player wouldnt be that big a deal I reckon
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
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
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
yep had another test, looks like I'll need some extrapolation too
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
depends if the train has to send ack packets or not
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
Also, if these are ai, you can transmit their intentions, which can be extrapolated without needing full deterministic
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
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
Some parts of Overwatch are deterministic no? I REALLY need to go look into how they do things.
Not sure
@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
Requires too much strict setup of their data to conform with it?
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
What's your current goal with this stuff? Like how many players/net objects?
Comparatively, where does Bolt start to crap out?
bolt scales fine up to 50 players or so
I take it that this second thread doing the serialization is pretty critical get getting up to those numbers
@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
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?
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
yeah, the thing I am thinking off would be totally game specific
and is much cheaper
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
yeah
That is so totally game specific though, don't see how to write that into an engine
well, i do :p
I suppose by creating groups that things can belong to, if all of the groups match... then they get the same serialized stream
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
Can always revisit it too
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
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
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
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 ๐
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
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
@jade glacier Could we please keep the language less edgy. At some point swearing just becomes gratuitous. ๐
Sorry, forgot this was the official unity discord @oak flower
Thank you ๐
@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.
I've removed that line. It was a bit off topic ๐
@oak flower And since when is masturbation a curse/swear word?
It depends on the context.
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.
I'd guess that goes on keeping the place friendly for people at all ages here
My context was in terms of coding, not the actual physical act... to be clear. ๐
We are not discussing how human body works. And it didn't have any relation to the #archived-networking ... Yep ๐
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
It is arbitrary. But I would draw the line on swearing for the sake of swearing.
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
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
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.
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...)
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.
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.
in other news it looks like the mono guys fixed a bug I asked them to: https://github.com/mono/mono/pull/12654
nice!
@prisma spade nice, how long before thats rolled into unity?
and will it propagate to il2cpp also?
il2cpp shouldn't have the issue iirc it was isolated to "new mono on windows"
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
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
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
It would definitely seem to indicate an underlying problem with it
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
Sorry stepped away for a moment.... what platform were you seeing this on @graceful zephyr ?
windows
and you see it with il2cpp and mono ?
ah okay
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
@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.
4.x mono has the race condition that that github pr resolves... Which can cause a thread to get stuck on a blocking call
@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
LOL, yeah didn't think that was going to be comprehensible
@prisma spade or did you mean mono 4.x as ".NET 4.x"-mode in unity?
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.
@prisma spade but I would assume that IL2CPP will use the same mono-socket-libs as mono would?
Sorry I was talking about framework version
@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
@graceful zephyr no worries, just thinking out loud anyway
mono in both build and editor
right yeah they share the same underlying windows socket code. So that makes sense
@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
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
oh right
im talking about a fully auth environment here
where this only goes one way
client=>server only
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
Didn't expect you to have the answer, just thinking out loud since I'm clearly not getting any coding done today ๐
@graceful zephyr
I did make a nice visualization report at least.
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
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
morning o/
@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
Nice
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
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
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
If you are having a problem with hard typed ips... you will have a problem still with discovery I would think
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
Hard addressing local lan ips should be as bulletproof as it gets... if that is failing you have something wacky happening
I'm setting the network address, then NetworkManager.singleton.StartClient();
I am sure you aren't messing that part up.. setting an ip and connecting is pretty straight forward
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
if your machine is suddenly not getting those messages through, you have some network level weirdness it sounds like
do you think it's hardware related? I might try with another router
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?
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...
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?
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
oh ok, thanks for the tips
There are no callbacks available with UNET like that, its annoying that way
You have to capture that stuff by deriving NetworkManager
https://gdl.space/omenocavin.cs
I had to make this just to get callbacks like that
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
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
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 ?
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
does the new networking system support the relay sever system? I don't want to have to forward ports for MP
New networking system is just a twinkle in unity's eyes at the moment. It's just a transport last I saw. @dusk kayak
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
@jagged radish Have you looked at Mirror as a replacement? Unity isn't even planning to replace HLAPI. They're just doing an LLAPI.
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
@gray pond mirrror? No idea, it is too different?
I'd expect more news on the Unity's networking at GDC (starts in ~5 weeks from now)
It's very similar...the components and API are mostly the same @jagged radish
NO
it's literally the same thing
We'd like people to start with the asset store version
oh wait, you don't have like stable releases on github?
"This is a bleeding edge release. "
that release list looks like master branch
It is auto built from master, correct
and I'm the wrong guy to raise git issues with - I don't run that
there are tons of releases and tags but not ones that would matter
please save your rant
I just need to NAT punchthrough and send messages xD
yeah, I'll save the rest but still think that's not how you should use github
NAT is added to the UDP transport @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
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
Wow it's great, in my last multiplayer game I was using Unet with a nat punchthroufg plugin and steam for matchmaking
why would you need separate punch through if you use steamworks?
I thought steamworks handles that for you
You can punch thorough with steamworks but didn't want to depend only on steam
especially if you're not using the full spectrum of Mirror / HLAPI
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
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
I'm thinking really hard into changing right now
there's still alloc, and we know that
Oh yes, but I'd rather compress all into little messages and send it
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 ๐
That is cool , unity's send one msg per syncvar I think
I promise Mirror is not just a flip of Unet
https://ascent-bias.itch.io/xequon
I had to do a lot of network optimizations for this game to work xD
Oh yes yes, I believe you
I'm thinking seriously to change the networking system
Good! - As I said - if you need help, come to our Discord and ask!
Were you using Unity's services, or Lobby?
The invitation link has been deleted :(
I was using Steam Lobbies to know the IPs and matchmaking and then doing the nat punchthrough
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
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!
Ooh ok, sorry!
Tag me when you get there
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
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 ?
@gusty pumice you might be interested in Kevin Kaymak's youtube channel. He uploads tutorials for making custom network solutions with unity.
thanks @alpine oriole, seems a nice channel
https://gafferongames.com/ is the usual go to @gusty pumice
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.
@stray scroll you can look for documentation and examples here https://github.com/Unity-Technologies/multiplayer
Thanks @untold plume , not sure how I missed that : )
thanks @jade glacier, yea glen is awesome
Joost as well has a couple of cool blog posts:
http://joostdevblog.blogspot.com/search/label/multiplayer programming
also this can be useful for fast pased games => https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
new unity networking is interesting, but unfortunately for now not supports websockets
Its also just a transport last I looked.
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
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
Tobias is pretty responsive on the forums if you drop a message there as well
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
that sounds pretty cool!
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
are you making the game all by yourself?
i am yes
wow
would you like to see a screenshot?
who is doing your art?!
i am more of an artist than a programmer actually
dude that looks amazing holy flip
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
Been working on the particle effects for the explosions today, also you can see a bit of the title screen in this short video. Trying it at 1080p but somehow...
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
that looks so cool!
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
mobile?
yes
will phones be able to run that?
yes but some of the detail may be reduced
want to hear how i'll make phones run that?
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
so for how long have you been programming?
"old"
well i guess it's relative, but i feel old... anyways
could you teach me some thing when we both have time maybe?
of course
i like to share techniques and help people
so ok, about putting this on phones
yeah
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
that shouldnt be a problem for phones right
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
yeah at my internship we are also making a mobile game so I hear the artist talk about the polys a lot
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
isnt clutter also pretty expensive for performance?
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
but you will be using a mesh collider? I guess you kinda have to with such a huge object
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
sounds like it would work
yeah had to put some colliders on weapons and tools for my internship
it should look like basically the same place too
but I had to avoid using mesh colliders
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
well if it works with mesh colliders that should be fine too right
seems like it
its kinda lowpoly ish
even mobile handles terrain + one big mesh collider just fine as is
at least not highpoly xD
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
is it hard to make a shader?
most of the trees don't even have leaves and thats intentional
yes gotta say, kinda is
i mean we have shadergraphs now
some people have an easier time with it though, you should try it out
but that isnt optimal i suppose
hahaha
so ok, you're up to speed on my basic outline now yes?
yeah I think so ๐
multiplayer also sounds difficult to do
what is PUN?
uh oh!
Im kinda new to programming haha, im programming for 2 years now
haha thanks
its way easier that I always thought it would be
I was like
its gonna be 0010101010
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
I mean it also helps to think about solutions
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
what do you actually need
ok i'll outline it
It began talking about your game theory and then branched off into switching to mobile platforms
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
can't you just make an event for when the status changes?
yes probably
use the one too many pattern
i'm trying to get this planned out a little more solidly
should work great for this right?
maybe! sec lets see what squiggly-marks-name thinks here
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
Other stuff looks like you only need players to know the state of the stones
there's 'masterclient'
ah ye its in that bs style
so 1 player hosts the match?
correct
or am I understanding it wrong
well sorta
it's weird man
one player and sometimes that player changes
mid game
I think there are still server RPCs but they are more 'running on master client' which can be altered by the main player
i'm not worried about cheating at this point
i just want it to function and then i will worry about that
side note, i need a 'lootManager' that basicallyd oes almost the same stuff as the stone manager
yes much easier
start small by synchronising the states, the smaller the better (probably an enum)
well thats where i'm having issues
no state machine?
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
Would you get away with defining [PunRPC] and forcibly pushing out the information?
maybe for everything but the 'stone is in midair being thrown like a football' status
If its actually being thrown you can sync up their physics state
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
almost sounds like old replication in directx
but what is the exact problem again? cause it sounds like you can just make a one too many pattern right?
could you explain one-too-many pattern please i don't know that one
I only refer to that for relational databases
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
lotta general MP practices just don't apply with it
i would actually prefer this 'no server' appraoch for now
i have... no money
Yeah, more recently server architecture has been hot seat client masters
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
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
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
music to code destruction to:
https://www.youtube.com/watch?v=gVB5cMLi8Ss
Stay Retro and Subscribe: http://bit.ly/1aIGam6 Support Our Soundcloud: http://bit.ly/1yIcZLb Support Our Facebook: http://on.fb.me/1O5W1NZ Get Your Retro We...
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
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
properties are a very basic example of observer
changing them raises their set method
but thats off topic
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
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
well i found this
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
its all C#, so you can just trace that enum to see where it leads
but i need to open the inspector editor to actually see what that option is accessed as
i think it's that syncho var
its basically the reliability channel it looks like
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
I would assume that depends on the replication settings
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'
Scene owned by default become MasterClient owned I believe
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
makes sense. The targets are indicated by the options flag
why wouldn't i get receive data events tho
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
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
You can look at what transformview has in it, its using OnSerializeView
just makes no sense to me
i just wish i didn't have to unravel all this stuff, seems very counterintuitive
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?
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
If you have your channel to off.. I would think it wouldnt send anything
no its not off, it's 'unreliable' now
Not sure why the choice for defaulting that to off
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
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
no it's a lot better than anythign i've written like this i just wish the docs made more sense
It definitely doesn't hold your hands, esp with PUN2 - almost nothing tutorial wise and such yet
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
you'll want your own scheme for organizing and culling that most likely
yeah i was thinkinga bout a 'dirty' flag
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
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
with your own handling for prioritization and partial sends and such
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
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
or... no server, as the case may be
So you either need a reliable method of making sure certain events get through, or a design that is tolerant of eventual consistency
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
yeah, I mean there is no "answer' for most of this - you have to decide where and how you want to handle your desync
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
I had tobi join a few days ago, but I think he is too busy and just checked out of discord
i don't blame them
He can't answer those particular questions anyway
those are very game specific, and not specific to PUN
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
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
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
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
basically Photon with PUN uses a relay rather than punchthrough
so all clients can talk to all clients... through the relay
which is fine by me but i'm not sure i'm playing ball correctly with the magic yet
rather than the server model... where all clients talk only to the server
i see
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
seems like... why not just have a server
everyone talks through the relay to everyone else
keeps server load down?
Because then you have to host game logic on a Photon server
and this is to avoid that
right so this way game logic is client side
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
ok diff question then
how much data can i sling around every OnSerializeView before its a problem
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
a few bytes, 100 bytes, 1000 ints, what?
I was just pushing 2K bytes over my wifi in a test a couple days ago
i mean that seems like a lot more than i actually need
Not recommended, thats abusive to clients, data costs... mobile...etc
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
yeah, it will be on you to trim down your serialization and prioritization to as thin as you can
they just get picked up and very rarely, thrown
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
yeah thats my plan right now
just anything fully functional then i'll break it as necessary to fix it better
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
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'
Just be aware that all OnSerializeView is is an automated RaiseEvent op
so if the byte is say, 1, that means 'full update, going to get a big bunch of arrays'
If you already know how to raise events... I would just stay there
and if byte is 2, that maybe means 'only updating stones status'
raise events is working great for me
I would use bits for flags like that
i figured serializeview as more performant
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
yeah, you can do all kinds of flags to indicate what is included
ie can i get that first byte and then use that to change how i read in the rest of the stuff from stream
That is more serializaton
yeah, you generally have headers to indicate what follows
but I use single bit switches all the time
ok cause none of the samples i've seen so far do that and i don't understand why not
like when I serialize a transform, it is preceeded by a single bit...
seems kinda like... mandatory
true = a transform follows... 0 = nothing... move to the next read
ok so maybe one byte witha bit for each kind of array tha tmight follow
so if 2nd bit is true, expect an array of loot statuses
for every object, you will create a Serialize and a Deserialize
then when masterclient is pushing data out make sure those bits match what its sending
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
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
If its a lot of stuff, determinism might be more where you want to take that
but I don't know the details
well i appreciate your input on this in any case man
thanks, seriously
such a murky mess
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
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
Avoid floats and even time as a measure of anything for networking
if you need syncing up... you want to use numbered ticks
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
Get your sim engine and network sends on the same tick
but some 'update reference id'
then the world history becomes a series of ticks, like a movie
and that number only increases
For most things, you go with a circular buffer
so i send new stone statuses, along with a 'last stone status update tick counter'
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
then clients receive stone status, or they don't, (unreliable), but in either case, they keep sending their 'last stone update tick counter'
For unreliable you just send once
master client keeps reading those 'last update tick counter's
if the others didnt get it in time or at all... they extrapolate and the next unreliable corrects any bad guessing
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
nope, if you repeat unreliable until its acknowledged... thats reliable
the point of unreliable is to be unreliable
its just a byte of 'stone is on the ground' versus 'stone is picked up by viewID' etc
Every client sends its numbered unreiliable tick once per sim.... and never again
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
I wouldn't "switch" to relaible
but for this its not working yet
I would send things that need to be relaible... as relaible
and don't mix them with your unreliable
Things you cant live without should be reliable
for example, a map change shouldn't be comingling with your player transform updates
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
Keep critical stuff separate from the lossy firehose
yes that sounds reasonable but its not working
i don't know why
i cant make sense of the docs
You might just need to step back and pick at the problems one at a time
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
What are you trying to send as Reliable right now?
the status of each stone
LOL... "networking locked down"
@earnest wave @mossy river @vernal remnant what?
hi punfish
Eyman i didnt tag you
Doesn't matter, you were co-conspirator
i'm jsut trying to sort some shit out here and struggling against the docs
or...lack of docs, whatever
Are you trying to pass authority over the stone?
no the stones aren't even observed
There's two different docs
they don't need to be
One is usage docs which kind of sucks, and then there's the api
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
But seriously, why was I tagged haha. I you need something?
i'm using the CHM, what i can figure out fromt he website, and the pun forums
Ok, but then you still have to assign an Actor ID as the owner of these stones and make sure everyone knows? @earnest wave
punfish well i'm trying to get my stone manager working and so i'm tackling onserializeview
You can't use actor ID because it's not consistent over Photon.
He tagged in hopes you would have had a more solid implementation for him to consider using in his current scenario
i've had some success getting it to update but only if i use 'unreliable'
You use Photon view ID or Photon player
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
Hold on
why don't you make events where they should update?
What do you mean every update
you shouldnt have to do it in the update right?
every onserializeview
Okay that's not every update
yes jorrit i know but thats not working right and i dont know why
kind of three conversations going on here
Yes it sends data constantly but it only sends what the network can handle
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
Pretty sure ActorId is the same for all clients in a room
It's not
i have a stoneManager, and it is monobehaviorpun with a photonview, and the stoneManager is the observed component
View ID is the same.
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.
the stoneManager has an array of 50 ints for now, one for each stone
Gameobject ids can be different
View is a networked object, the Actor is the connection Id
those ints represent the status of each stone, theres 'on the ground', 'converted to a point', 'in midair' or 'in viewID's possession'
Okay so when you said actor id I thought you were using that as a term for gameobject
The PhotonView does contain the ActorId as part of its value I believe as well?
the last status is indicated by a negative number which is the viewID, negative
Because in Ue4 gameobjects are called actors
I hope ActorId is the same across the network... otherwise I have been putting some very borked shit on the asset store ๐
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
Okay
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
Why not just move that logic to the stones then so it only fires when stone is in use
The reliable option may require some kind of dirty command
Also on serialize is going to send every network update, that's normal.
again, I just use raiseEvent, so I just avoid this whole issue
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
But it will drop excess packets, which is also nornal
you probably should as well... just raise events on your own tick
Oh right yeah that's a fun one
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
You could add an event that when the object Awake to request current states via rpc
And only send to that one person
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
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
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
How you dirty up your data is pretty much up to you
You don't do it that way, if u want to sync on joins only
no this gets changed often midgame
players pick up the stones
thats the scoring system
The easiest way is when the mono Awake method is call is to request the data if not master client
so yes onjoin will require full update
Awake only calls once so you know it's being instantiated for the first time
but after that, updates when dirty
You can choose when to transmit on serialize
yeah thats what we were discussing when you came around
the idea that the first byte of stream data describes what follows
You could just add a bool check to not send the data
and so i read that and based on its value, that determines what i read from the stream next
is that reasonable?
But you have to check data lengths when reading and parsing
Yeah, how you delta and such is going to be completely up to you
Pfft... data checks
like if the stone's array is updating, first byte might be a 1
Just make your serailize and deserialize flawless ๐
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
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
but if first byte is 2, that may mean... update the loot status array
since PUN already is slapping a byte header on your packet
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
I would learn about bitpacking before you make any schemes
jsut trying to simplify for sake of convo
because your byte idea will go out the window when you realize you can pack this stuff with any number of bits
yeah i know, like layermasks yes?
even those assume even bytes
yeah just trying to simplify the convo
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
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
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
"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
byte says 'data type A / B / C' incoming tho?
sometimes A/B/C all equal false, then its no data
Depends how you use it
but sometimes it's just A, no b or c
It's better to send no data than send a byte that says there's no data
k
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.
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
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?
Yes
k thanks
Not sure if there is a setting to make master get its own write
I forget the options for targets
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
its indicated by the receve opts flag
yeah, that weird unified Serialize method
Every other networking library has a Serialize and a Deserialize... Tobi for some reason unified them
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
Using properties to auto-dirty is a thing for sure
It's pretty useful