#archived-networking

1 messages ยท Page 70 of 1

jade glacier
#

if your "I fired packet" didn't arrive in time.... it never happened.

dry wave
#

I think I do but maybe I'm not fully understanding that, could you elaborate on that?

prisma girder
#

Shooters use UDP and client prediction and lag compensation and rollback.

jade glacier
#

You will see it locally in prediction, but you will get a dud for a hit

prisma girder
#

If the client sends a shoot command, it also Shows the shooting animation/sound/etc, locally

#

And then shows damage/deducts health after the server confirms

jade glacier
#

They MIGHT go back for late packets and do a rewind just for that, but that will also have to be replicated out as the new state - which is doable.

prisma girder
#

But if the server never gets it, it just doesn't update health.

dry wave
#

Ow okay

prisma girder
#

It still shows it partially happened.

#

This is often called a "hit registration" issue, by players

dry wave
#

I assumed the bullet would disappear then, but I guess not since the server can't make it disappear

jade glacier
#

With client prediction, you typically don't predict the actual hit and damage

dry wave
#

How often does that occur though?

jade glacier
#

you still have to wait for the server to confirm that

prisma girder
#

Not very often in most big well-built infra

#

Partly because UDP isn't that unreliable :P

jade glacier
#

But, no hard rules... all depends on how you write your prediction model... and how you write that is based on how you write your server to deal with late packets... if at all.

prisma girder
#

Yep

dry wave
#

Not very often in most big well-built infra
@prisma girder That's what I expected, reason I said earlier UDP might make it more complex. TCP just does this while for UDP you need that well-built infra

prisma girder
#

Also, state merging is somewhat common

jade glacier
#

It is also typical to send in each player packet to the server X number of previous inputs.

prisma girder
#

It's not super common in open source netcode

dry wave
#

@jade glacier I was honestly just thinking of having the client run the game and be corrected by the server, not a good idea?

prisma girder
#

But it is common in proprietary engines

jade glacier
#

So lost packets don't require a long ack resend process

sinful niche
#

So should I be utilising a function that checks if a player joined on each of these GameObjects @jade glacier ?

jade glacier
#

For my PUN2 system I have players send a complete update as reliable when a new player joins - but that is just one answer. @sinful niche

dry wave
#

It is also typical to send in each player packet to the server X number of previous inputs.
@jade glacier That's actually not a bad idea indeed

prisma girder
#

Tick rates are often less than frame rates.

jade glacier
#

Its what most systems do @dry wave

#

since player inputs are VERY compressible

prisma girder
#

That usually means you're coalescing > 2x frames of inputs into a single update

dry wave
#

I feel that TCP is the way to go, I'm just scared it might screw with my combat system.

prisma girder
#

If you pick TCP you have to tune your retries and timeouts

dry wave
#

@prisma girder Yes, RS has 10 ticks and LoL has 30 ticks

prisma girder
#

TCP will not, by default, just ignore dropped packets and keep going with no problem

#

It will wait, a while

dry wave
#

Yes, for the sending server > client I wrote down to do that

#

If you have any good source let me know

jade glacier
#

Just make some small prototypes, and see.

#

Theorycrafting networking to death rarely gets anyone anywhere. Just build something and see.

dry wave
#

Yes of course. This helped me a lot already, thanks both. Now that I understand the big picture better I'll start prototyping.

jade glacier
#

Burn it down and start over often ๐Ÿ™‚

#

until you feel its a winner

prisma girder
dry wave
#

Ah great thanks for sharing

prisma girder
#

The default is 0. No timeout. Aka blocking.

#

If you set it low, it may fire exceptions

#

And there's higher level abstractions on these, stream readers, pipelines, tasks

#

But yeah :P

dry wave
#

Makes sense. I'll see what works best. Will be going with TCP for now. Just want a playable version and once all functionality is there I can tweak the packet properties in detail to fit better.

#

It's reassuring knowing that I can tweak it so much though

sinful niche
#

@jade glacier Sorry for all the pings and questions, so if I had in OnJoinedRoom() a loop for every player in the room, how would I get that Player's gameobject (currently just have the Photon.Realtime.Player) - if this isn't a really wide question?

prisma girder
#

I'm actually considering writing my own netcode with some of the more advanced stuff Microsoft has in .net

#

Itching to try a replication graph like Unreal has

#

And the new System.IO.Pipelines

jade glacier
#

@sinful niche you need to make user of the OnPlayerJoin/Leave callbacks

#

forgetting their names

prisma girder
#

tl;dr, backpressure mediated async Task stream readers for sockets

#

That are basically zero-copy

#

Mirror and PUN are not zero-copy and their multiplexing model is kind of poor, so they hit Unity thread limits and cause GC churn :P

dry wave
#

Is that basically opening a connection and keeping it open to send data back and forth? Like SignalR?

#

I'm not familiar with pipelines

prisma girder
#

Most people aren't, myself included until just this week. They're pretty specialized

jade glacier
#

Pun2 allocates new objects for most operations. Working right now on making byte[] and ArraySegment<byte> incoming reuse from a pool... but it will still involve copying

prisma girder
#

Check that link. It's a better way to do this than ArraySegment

jade glacier
#

PUN2 though is not designed to push entity counts high enough for that to even register as a problem though.

#

Which .net version?

dry wave
#

Anyway thanks again both for the help, I'll go start working on my prototype now ๐Ÿ™‚

prisma girder
#

Core 2.0+ or Framework 4.6+ or Standard 1.3+ looks like

jade glacier
#

How does that map out to unity and monob versions?

#

PUN2 works on Unity 5.6 still, though might have gone as far as forcing 2017 recently.

#

So most magic isn't available.

prisma girder
#

Haven't tried it yet but I believe it will work fine with their mono as it only relies on super core bits like System.Buffers and System.Threads.Tasks

jade glacier
#

The allocations though occur in the dll, so not sure what limitations are involved there.

#

I don't usually touch transport level. I'm not good at it, and I don't like it ๐Ÿ™‚

prisma girder
#

haha, totally fair.

jade glacier
#

I just need to get this GC thing resolved.

prisma girder
#

I touch it a lot and also don't like it :D

jade glacier
#

so I am holding my nose and looking to help remove the byte[] allocation.

#

PUN to the core is built around serializing object[]

#

so it has a lot of baked in boxing/unboxing and other issues. When it started their focus was "just works"

prisma girder
#

Might be able to make use of Span<T>

jade glacier
#

So it has the same pains as unity. Just works = less than ideal choices.

#

Span not in the Unity versions supported

prisma girder
#

Ah right, you're targeting back to much older Unity

jade glacier
#

ArraySegment<byte> is the best option available at the moment for nonalloc with byte[]

#

zero-copy is likely a long way off

prisma girder
#

Do you think there's room for a recent-unity-only focused replication/netcode layer for Unity? I'm strongly considering writing one, particularly for distributed servers

#

I've been working in Unreal lately and there's a ton of frustration in trying to make it work on distributed servers

jade glacier
#

The entire system exists based around Unity and its use of MonoBs... so any overengineering is probably on hold until Unity completes a stack.

prisma girder
#

SpatialOS exists but it honestly seems like a mess at the moment.

jade glacier
#

I can't imagine how they could be doing well with this. They are in middleware hell.

prisma girder
#

Indeed, and the whole spat with Unity and Epic grant. You'd think that would mean their Unreal GDK would be amazing, but it's super stagnant

jade glacier
#

Having to code around the preview landmine hell - sounds not fun.

prisma girder
#

Their docs are a big list of "this will be working soon honest"

#

Including the flagship feature of zoning :P

jade glacier
#

Even if it works, its going to always be breaking.

#

Its like trying to be a middleware dev for like facebook

prisma girder
#

That's why I'm inclined to write something that's much simpler and general enough to be useful.

jade glacier
#

Quantum ended up with its own entire memory ECS-like system I believe

prisma girder
#

Yeah they've had to do a lot of work to be deterministic

#

No idea how fragile that is

jade glacier
#

not very, since they are doing the whole thing.

#

Its solid, but you have to do so much out of standard unity land.

#

Its basically a game engine inside of a game engine

prisma girder
#

mmm

jade glacier
#

But that is kind of the state of middleware with Unity

#

if you try to extend MonoB or DOTS.... you are in a losing position

#

MonoB is stagmant, and DOTS is quicksand

prisma girder
#

Yeah it's a mess right now for sure

#

Part of why I'm working in Unreal, but their framework is fairly inflexible in a lot of ways unless you literally write entirely new core layers

#

Which you can totally do, but it's a lot of work

jade glacier
#

Yeah, a lot of devs are jumping to UE

#

Unity is experiencing a large brain drain. Not sure if the recognize that upstairs yet.

prisma girder
#

I was looking into how they do Steam relay last night, and it's both horrifying and clever

#

Valve wrote a socket driver, that pretends to be regular sockets, but runs the translation to their embedded protocol underneath

jade glacier
#

They are trying to code to "outperform UE"... but by the time they actually realize that... too many of the people capable of comprehending DOTS may have left.

prisma girder
#

So calls to RecvFrom just encapsulate the packets.

jade glacier
#

Too low level for me to appreciate

#

I'm a UX guy who codes high level networking library stuff... what happens between me sending and receiving my byte[]... is voodoo ๐Ÿ™‚

prisma girder
#

Ah, well, sending and receiving UDP, at the lowest level, is just SendTo(socket, address, data) and data = RecvFrom(socket), basically.

jade glacier
#

I just trust someone smarter than me has made sure it arrives in one piece ๐Ÿ™‚

prisma girder
#

And that's core library stuff in most languages

#

Unreal has a thin abstraction layer on top, to handle different platforms

#

But I wouldn't have expected Steam to work by hijacking that fundamental low level bit

jade glacier
#

What does that mean to developers?

prisma girder
#

Well, the reason I was looking is because UE servers don't allow for clients on multiple maps at the same time. There's some map tiling/streaming stuff, but that's still one map as far as coordinates go.

#

Which means if you want large worlds, and origin shifting is an issue, you need to have multiple servers

#

But there's no good way to distribute clients between them

jade glacier
#

Interesting

prisma girder
#

It's a hard jump

#

Spatial is basically the only public service trying to fix that

jade glacier
#

That sounds like a higher level problem though than transport level?

prisma girder
#

It is, but, Epic's advice is "Write your own translation layer to steer clients to the right server based on map location"

#

And "our MMO licensees do this"

jade glacier
#

Ah, gotcha

prisma girder
#

Figured I'd see what Steam was doing since their relay network hides real client IPs

#

I think I could build something for Unity that's easier, but allows distributed servers

#

UE's replication graph is also super clever, and would be great to build one for Unity

#

Basically a way to have a persistent data structure that sorts objects by various filters, to decide what to replicate and when

#

Things like proximity, visibility, relationships (weapons vs character holding them), etc

#

As opposed to just replicating anything that moves every tick

jade glacier
#

There are definitely uses for that. The main issue I have always seen with libs like that (assuming you want others to make use of it, pay for it, or just make it popular) is that if they aren't a complete stack for networking - its hard to get devs to commit to using it.

#

And making it bulletproof and complete.... is SUPER work intensive.

#

Most nerds who understand what it is... will want to try making it themselves.

prisma girder
#

Yeah, that's totally fair. I have a large game project that I'm getting past the initial design phase on, got my basic assets ready, so I'm mostly looking to solve this problem for myself first, figured I might end up with something general enough to be useful for others

#

I've worked on lots of large open source community projects in my career, not too worried about that aspect

#

Mostly just not sure if it's worth doing it in Unity at this point

#

Looking for signs they're getting their shit together :P

jade glacier
#

yeah, that is kind of the million dollar question these days.

sinful niche
#

@jade glacier I'm still ramming my head into walls here - how do I iterate through Photon's playerlists in order to call the gameobject associated with a player? Google searches are bringing up results from quite a while ago...

jade glacier
#

It's a bit more advanced than just using the standard components yeah. I don't use RPCs so my system of serializing all owned objects to one byte[] makes it easier. Not sure how I would tackle it with vanilla PUN2.

#

SNS is free and beta, you can poke around it - but its not an easy read.

sinful niche
#

Yeah, I've stopped the RPC, instead I am just trying to call a function from a gameobject

jade glacier
#

Or you are welcome to use it.

sinful niche
#

It's crazy that it's so difficult to implement a variable on a gameobject that is kept across all connections... gah

jade glacier
#

SNS has syncvars for that.

#

There are params you can store with the connection and share with vanilla pun, but not sure how. I don't use vanilla so I am actually not the best person to ask.

sinful niche
#

I'll give it a try!

jade glacier
#

Be sure to run the tutorial if you do. The main thing of interest though will be the packobject

#

Which is at the end of the tutorial

#

And keep in mind it is in beta, so let me know if you run into anything odd.

sinful niche
#

I'm really bad with packages - how would I import it/where do I need to save the unitypackage file? ๐Ÿ˜›

jade glacier
#

just import the asset package yeah

#

you have the link to the beta release on git?

sinful niche
#

I do, yeah - how do I go from that to having it in Unity?

jade glacier
#

Just import the package into your project, it will add the folders

#

download the package to your harddrive somewhere

#

and import it into your project, should be all that is needed

sullen folio
#

You should just be able to physically drag in the .unitypackage file

jade glacier
#

dragging it into the hierarchy like that will import as well yeah

mellow sapphire
#

Hi, I have been following the unity.netcode getting started documentation, and it tells me to add some codes inside another script, which is the one from this image

sinful niche
#

Oh God I'm an idiot...thanks guys

mellow sapphire
#

Networking is something very new to me, but I'm already having troubles at the getting-started page haha

sinful niche
#

Make sure you have the [BurstCompile]

mellow sapphire
#

Right afterwards it tells me this

#

So I add the burst compiler inside the GoInGameRequestSystem, but the error still appears

sullen folio
#

@sinful niche , if you need help with RPC's with Pun2 let me know - you can achieve what you are trying to achieve with RPC's alone

#

Although, obviously there's nothing wrong with doing it another way as suggested

jade glacier
#

He is fighting with getting client variables synced up with for late joiners @sullen folio

sullen folio
#

@jade glacier ah got it

sinful niche
#

Easiest to DM you @sullen folio ?

jade glacier
#

the buffered RPCs is usually what people try, but that never pans out as planned

#

Best really to keep that convo here, so other can learn

#

or contribute

#

PMs kind of defeat the whole point of these chat rooms, but that is up to you guys.

sinful niche
#

That's a fair point - was more worried my disjoint ramblings were exceeding capacity ๐Ÿ˜„

jade glacier
#

That's what these chans are for. There are a lot of idle readers who never talk, or active other people who might learn something.

#

Not saying what to do, just not to worry about it.

sullen folio
#

@sinful niche yah I agree best to keep it here if possible

#

Yah, you will eventually run into issues with buffered RPCs. Best to try to keep track of the current state on your master client, then when a new player joins the room send them the info they need

#

Although, this is something that I've never had to deal with directly myself -- in the current project I'm working on, player scenes are changed and synced so frequently that when someone else loses connection or joins the game, the master client just connects them when the new scene starts

mellow sapphire
#

And how should I start learning Unity NetCode? I couldn't find a single tutorial using the new DOTS system, the only document I found was this

#

Any tips or suggestions?

sullen folio
#

@mellow sapphire wish I could point you in the right direction, but I've yet to look at the new networking preview for Unity

jade glacier
#

The DOTS channel likely is of better help than the networking chan for Netcode

mellow sapphire
#

Is it normal for me to have so much difficulty with just the GettingStarted documentation @sullen folio ?

sullen folio
#

@mellow sapphire yes. It's a lot to take in especially if you are newer to programming

jade glacier
#

Anything part of the new DOTS/ECS stuff is going to be brutal.

stray scroll
#

What is the error you get?

#

@mellow sapphire

night plover
#

The getting started is pretty much the only thing out there atm

mellow sapphire
#

@stray scroll Hi man, so I'm at the part that the document tells me to add the BurstCompile IRPC Command

#

Then this error appears

night plover
#

Which version of NetCode are you on?

stray scroll
#

Well, that's because the syntax has updated

night plover
#

Oh, right

sinful niche
#

@sullen folio the top section of this is in my Void Start function. This script is attached to the player gameobject which gets instantiated on the network. I have the int variable for "race" which gets used by an animation to decide which animation to run (different sprites essentially) but it seems to be defaulting to the 0 value from the variable initialiser.

stray scroll
#
    [BurstCompile]
    public struct RPCDeclineAuthentication : IRpcCommand
    {
        public void Serialize(ref DataStreamWriter writer)
        {

        }

        public void Deserialize(ref DataStreamReader reader)
        {

        }

        [BurstCompile]
        private static void InvokeExecute(ref RpcExecutor.Parameters parameters)
        {
            RpcExecutor.ExecuteCreateRequestComponent<RPCDeclineAuthentication>(ref parameters);
        }


        public PortableFunctionPointer<RpcExecutor.ExecuteDelegate> CompileExecute()
        {
            return new PortableFunctionPointer<RpcExecutor.ExecuteDelegate>(InvokeExecute);
        }
    }

    class RRPCDeclineAuthenticationCommandRequestSystem : RpcCommandRequestSystem<RPCDeclineAuthentication>
    {
    }
mellow sapphire
#

@sullen folio Yeah, I'm about to release a VR game in 3 dayson Steam, and now I'm thinking about starting a new multiplayer project, but I had no idea it would be this complicated hehe

night plover
#

Multiplayer is one of the most complicated things you can encounter in gamedev

mellow sapphire
#

@stray scroll This is different from the documentation, why is that?

sinful niche
#

It updates for anyone who was already connected, just not for someone new who joins, who gets that default sprite for anyone who has been on longer

#

(If that makes sense)

mellow sapphire
#

@night plover Oh boi. I mean, I like the challenge, but at least some tutorials would be nice

stray scroll
#

@mellow sapphire Because they are bad at updating documentation, and if you've using latest NetCode, they have updated the syntax, if you read the changes it will tell you this.

night plover
#

@mellow sapphire You have to remember that NetCode is in very early stages

#

It's still in preview

#

If you go for something like PUN, it's going to be a lot more documented

#

But if you wanna do ECS you have to go with NetCode for now

#

Or your own solution

#

Which is even more complicated

mellow sapphire
#

@stray scroll Thanks Jaws

#

@night plover So, the VR game I'm about to release is a realistic fighting one, it's super fast paced, would PUN be able to handle that?

night plover
#

But yeah, your IDE can also help you with implementing the right functions. The function definition has been changed, so your IDE can auto-import the right one. They just removed some arguments

#

Probably

mellow sapphire
#

The thing I liked about the new NetCode, is that I can just switch the clients, and since I only have one VR device, it's great for me

night plover
#

Yeah, I wouldn't use NetCode for anything production atm..

#

But if you want to learn it for the future, then it's good

#

But that's about the only reason to use it right now

sullen folio
#

@sinful niche so just from looking at the code, what's happening to me is the object with this script is instantiated over the network. If it is yours, you are calling UpdateAnimation

mellow sapphire
#

@night plover I will play a little with NetCode for a few days and think about it, but the option to switch client inside Unity is great for me

sullen folio
#

@sinful niche If UpdateAnimation gets called, and photonView IS yours, so you set the integer

#

@sinful niche then, you're calling it again on itself

sinful niche
#

Yeah - I have been trying for ages to work out how to set the integer for the ones that aren't "yours"

sullen folio
#

Because RpcTarget.AllBufferedViaServer will also call it on the client that it is called from

mellow sapphire
#

@stray scroll Hi there, now it's appearing another error

sullen folio
#

@sinful niche give me one second and I will show you how it works

mellow sapphire
#

I tried looking for what that means, but I came out empty

sullen folio
#

@sinful niche could you do me a favor and paste that code in?

sinful niche
#

How do I do that without it stopping me? haha, is there a quote-type system?

#

When I paste it in it deletes it, I assume because it detects it's code

sullen folio
#

do a backtick first

#

test

jade glacier
#

Might just be too much of it

sullen folio
#

Yah that would work ^

sinful niche
sullen folio
#

@sinful niche I can't paste it in either. Ignore the errors, but I'm trying to follow your code as if I'm the object that is instantiated

#

I have errors because I just created a demo project that doesn't have Photon

#

But read the comments and try to follow them

#

@sinful niche Do you sort of see what's happening now?

sinful niche
#

So removing my first UpdateAnimation() would stop it from "double-dipping" (this is probably from the amount of times I've re-written this in the last 8 hours of trying) - so how would I set an "old" gameobject to do this? My assumption would be from OnJoinedRoom() or something, but then I'm personally missing the mental logic of getting the game object associated with a player

jade glacier
#

As long as you aren't abusing the buffered rpcs, it should work. And assuming the rpc is setting something that is changing.

#

I've lost track of what you are ultimately trying to achieve

stray scroll
#

@mellow sapphire This was just example of how it should look, the components used is for my context only. You should use names of structs/classes/components that are for your context etc.

sullen folio
#

Haha, sorry it's taking me a minute too

jade glacier
#

Are you just trying to have each player set a value, and inform all other players of that value - even if they join late?

#

Or something more exotic than that?

sullen folio
#

So that variable you are retrieving from PlayerPrefs is just whatever was stored on that client previously ; you do understand that right?

stray scroll
#

@mellow sapphire updated the code I posted to better example

sinful niche
#

I understand, yeah.

sullen folio
#

@sinful niche also, you can pass values like this

mellow sapphire
#

@stray scroll Thanks once again Jaws! Let me know if you have some suggestions for me on where I should start or if I'm starting at the right place

sullen folio
#

GetComponent<PhotonView>().RPC("UpdateAnimation", RpcTarget.AllBufferedViaServer, "here", 1, "are", true, "some", false, "things");

sinful niche
#

Essentially I'm attempting to set an animation variable to a stored integer. The problem I'm having is establishing this on all connections - newer connections seem to be missing this on gameobjects created before the client joined.

jade glacier
#

Still too many vague parts in that for me to follow

stray scroll
#

@mellow sapphire If you really want to use Dots NetCode. Look at the quick start guide, try to follow it, look at the asteroids demo. The scripts, how they spawn, send RPCs, send Commands etc.

jade glacier
#

I'm attempting to set an animation variable to a stored integer Set where?

sinful niche
#

PlayerPrefs

sullen folio
#

@sinful niche where is that PlayerPref variable set from?

#

origionally?

jade glacier
#

and the value is originating where?

sullen folio
#

^

sinful niche
#

Another scene

#

The scene that plays beforehand

sullen folio
#

Could you send that code?

jade glacier
#

When describing networking problems, pronouns are evil, but painfully explicit

sullen folio
#

Yah. it's kind of like an audit trail, we're just trying to find the root of the problem

sinful niche
#

So the scene beforehand is a character selection screen - later on I want to skip past that if that playerpref is set from a previous game

jade glacier
#

The problem we are reading is "Why isn't my value setting".... impossible to answer without all the gritty details

#

You are trying to set it on the player owner side?

sullen folio
#

Could you Debug.Log() the player pref BEFORE you do any PRC calling?

#

and make sure it's the value you want?

sinful niche
#

Oh - the value works - but only for the client who has that saved in their playerpref. I utilise the "SetInteger" in the animation to choose which set of character sprites to use, and on other connections the character (with the script we just discussed attached) it appears as the character associated with "0" - from the variable initialisation

jade glacier
#

Which client are you calling this RPC from? Since you have multiple players. The idea of one client setting a value that changes is playerpref on another client sounds like a VERY strange use case.

sinful niche
#

So it's essentially
->Character selection scene loaded

  • Player chooses character
  • Character stored in PlayerPrefs as an integer
    -> Game Scene Loaded
  • User gets the PlayerPrefs int
  • Uses it to select the sprite animation
  • Tries to send it to all clients
#

oops

jade glacier
#

So that doesn't describe any networking at all

#

What is being networked in that series of events, and why?

sullen folio
#

So you need to remember too, that photonView.isMine will only be true on object of the client that it belongs to

#

edited ^

jade glacier
#

Each connection has its own owned player... so what you are after is still making no sense at a basic level.

#

Are you trying to GET some value for your player from player prefs, and then inform all other players of what that value was? That would make sense.

sinful niche
#

Yes - that's what I'm trying to get at

#

I've just been working on it for too long to make sense haha

jade glacier
#

That is the exact opposite of what you just described LOL

sullen folio
#

haha ok now that makes sense

sinful niche
#

It's been a long day

sullen folio
#

no worries

jade glacier
#

a buffered RPC should be fine for that, though I have never used them.

#

As long as that value is some static info about the user, like its color or something

#

You can also attach info to your instantiated player I think, but I totally forget how off the top of my head.

sinful niche
#

Excuse the spaghetti - but the different values of the int relate to the animation Char<int>a

#

So I have the animation check the value and assign the animation as required

jade glacier
#

You want to get a playerpref when you spawn your player.. and apply it to your players animator.... and then tell other players what that value was... so they can set it for their copies of your player?

mellow sapphire
sinful niche
#

Yeah @jade glacier

sullen folio
#

With your current code setup, I'd simply remove the checking for photonView.IsMine in the UpdateAnimation method, then pass in the index value for the animation

#

So like this.... (one sec)

jade glacier
#
  1. Spawn your player
  2. Get your PlayerPref
  3. Apply it to your newly spawned player
  4. Send an RPC from your player object
  5. Other connections will rcv that RPC on your player object, and can apply it to their local copy
sinful niche
jade glacier
#

The main issue I see is race conditions there

#

But I assume Tobi has that wire up so buffered RPCs won't fire remotely until after the object is set up and ready

sullen folio
#

sorry

jade glacier
#

Why is an official Unity discord blocking you guys from pasting small bits of code?

sinful niche
#

Trying that now

jade glacier
#
How is this not allowed?
How is this not allowed?
How is this not allowed?
How is this not allowed?
How is this not allowed?
How is this not allowed?
How is this not allowed?
sullen folio
#

Seems to be

#

but yah when i paste in code it's gone

jade glacier
#

weird

#

maybe a very short limit?

sullen folio
#

You can actually see it for a second

jade glacier
#

dunno

#

All I can think is that maybe you are just over the size limit.

sinful niche
#

You're a "flipping" legend thedยฌ!

#

It works

jade glacier
#

That lack of ismine in start looks like a problem though

#

These are spawned players right? Not scene objects?

sinful niche
#

I had to call UpdateAnimation in the IsMine but apart from that it worked

jade glacier
#

The RPC only firing on the owner is saving you from that code error

#

But it is pointless to be pulling and trying to RPC the "race" value on anything but IsMine.

sullen folio
#

Ah I'm back. Sorry it blocked me from the chat

jade glacier
#

LOL

#

I had that happen for pasting other discords

sullen folio
#

Lol, must have been from spamming code in the box

jade glacier
#

Unity Discord is hostile

sullen folio
#

Haha

#

So, I can explain what the code is doing now

jade glacier
#

You should only be reading that pref and trying to RPC if you are IsMine == true. But it won't fire regardless, so not huge. Just a weird waste of mips there.

sullen folio
#

Basically, what's happening is that method is getting called 1 time on EVERYONE's client, including the one it was called on.

jade glacier
#

Start is going to fire on all player objects on every connection

sullen folio
#

@jade glacier yes - that's why the implementation itself is a bit odd to me

#

But, it does work

jade glacier
#

It will, because that RPC just won't fire unless you are IsMine

#

So its just shunted for you

sullen folio
#

@jade glacier let me go back up and read your chats because I lost you somewhere

jade glacier
#

you don't have an IsMine in front of your RPC

#

@sullen folio

#

So it will be trying to RPC even when IsMine == false... which it will fail at.

#

I believe at least, that is the rule for PUN2 and RPCS

#

Which would explain why what you have works

#

I would paste the code in question... but its a graphic LOL

sullen folio
#

@jade glacier Yah you caught me on to an issue. Throw a `if(!photonView.isMine) return; in the start

#

thanks @jade glacier

jade glacier
#

no biggy, it was going to work regardless

#

just figured it might be misleading to look at

#

since the RPC failing isn't something obvious

sullen folio
#

@jade glacier agreed. @sinful niche keep that in mind too. When you instantiate an objet over the network, the Start method is getting called on everyones instantiated network object

#

Sorry I forgot to mention that

jade glacier
#

yeah, putting networking code in start is fragile

sinful niche
#

Yeah - I had worked that out previously but thanks

jade glacier
#

better practice later is to try to stick to OnJoinedRoom

sullen folio
#

Yah, it's typically something I don't do so I didn't even catch that - nice catch

jade glacier
#

That is the first moment an object can safely use IsMine

dry wave
#

Does anyone know of a complete C# networking tutorial / book / ...? Even the book I bought doesn't explain things.

jade glacier
#

Those words don't really go together in the context of gaming like that @dry wave

sullen folio
#

@sinful niche I'm glad we could be of help. Let us know if you have anything else

jade glacier
#

C# is C# ... game networking is game networking

sinful niche
#

Thank you very much โค๏ธ

jade glacier
#

gl

dry wave
#

@jade glacier What do you mean?

#

I'm asking about C# networking not games in general

jade glacier
#

Networking for Unity is all about the libraries you use.

#

the .net core networking stuff is VERY low level

dry wave
#

I'm talking about the .net core networking stuff yes

sullen folio
#

Yah. I'd wrap your head around networking in general before even considering getting into the code - if you don't know it already

jade glacier
#

Just whatever MS resources then

#

MS documents their stuff VERY well

dry wave
#

Their docs are fine yes, but it's just bits and pieces to mush together

sullen steppe
#

I'm having a hard time understanding how UNet works. If I have something like this:

    void Update()
    {
        if (isLocalPlayer)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Shoot();
            }
        }
        
    }

And I play an audio source in the Shoot method it will only play for the local player right?

jade glacier
#

.net networking is not going to get you anything you need for game networking though

dry wave
#

Why not?

jade glacier
#

game networking is a very very different set of problems that basic messaging

dry wave
#

But the code is the same

jade glacier
#

yeah, not really

dry wave
#

What

sullen folio
#

@sullen steppe yes

jade glacier
#

The core code for sending a byte[] from one connection to another is, but that is hardly the difficulty in game networking

sullen steppe
#

So I'm considering that the Shoot method should do some sort of command to another class (probably a singleton?) and then that thing can do an Rpc call to play the sound

dry wave
#

Yes so the code is the same, and I'm looking to know the code

sullen steppe
#

by Command I mean like the [Command] thing

jade glacier
#

I would go look at some of the transports then

#

like NX's enet for C# or something

sullen steppe
#

I'm sorry no threading in Discord is tough

jade glacier
#

LiteNetLib is C#

sullen folio
#

@sullen steppe You basically have the right idea

sullen steppe
#

okay right so like

    [Command]
    public void CmdPlayAudio()
    {
        RpcPlayAudio();    
    }

    [ClientRpc]
    public void RpcPlayAudio()
    {

    }
#

then in my client specific shoot method i can like AudioManager.Instance.CmdPlayAudio(...)

sullen folio
#

Are you only playing audio, or is anything else happening?

sullen steppe
#

well for now just audio

#

but i'm shooting a gun right so like a muzzle flash effect or something might be in the works

#

i have a ShootingController.cs that's disabled for non-local players

sullen folio
#

What you are doing seems fine, just remember that you only need 1 RPC call for all of that stuff to happen. The sound will just be part of the whole process of you actually shooting the bullet

sullen steppe
#

i see so i should

#

not like duplicate ParticleManager or whatever

#

and send multiple Rpc calls

#

so maybe AudioManager is like no the right abstraction

sullen folio
#

It's ok to send multiple RPC calls, but if you're shooting a bullet, literally all the other client needs to know is the information about shooting the bullet. The local client can make the flash, sounds, etc...

#

which can all be done in 1 RPC call. If the client shoots another bullet, it's fine to make another RPC call for that bullet

sullen steppe
#

well i mean the local client is just what's in the Rpc method right

#

right i don't want shoot bullet -> rpc call for flash and rpc call for audio

#

ohhhh you know what i should have like

icy ermine
#

as far as i know, the RPC is being called over the network and having multiple RPCs to basically just do one thing is increase network load

sullen steppe
#

i don't know what to call it but some manager

sullen folio
#

Exactly ^^^

sullen steppe
#

FooManager whatever

sullen folio
#

Exactly what @icy ermine said

sullen steppe
#

and it has CmdShotFired

#

RpcShotFired

sullen folio
#

Yes there you go

sullen steppe
#

and in RpcShotFired i should call AudioManger.Instance.PlaySound

sullen folio
#

then do all the sound and flashing in the same method

#

on the local client

#

just do 1 call for 1 bullet

sullen steppe
#

right yeah

#

i have like this code working related to taht

icy ermine
#

you can have multiple methods, just call all of them in the ONE rpc method

sullen folio
#

Of course, I should have probably said that -> Once RPC *** method

sullen steppe
#
  [Client]
    void Shoot()
    {
        RaycastHit _hit;
        if (
            Physics.Raycast(
                blah blah
            )
        )
        {
            ...blah...
                        CmdPlayerShot(hitTransform.parent.parent.name, equippedWeapon.headDamage);
                     ...blah...

                }
            }
        }
    }
#

so is it okay to ahve one "ShotFired" Rpc call

#

and then another "PlayerHit" Rpc?

icy ermine
#

definitely

sullen steppe
#

like we don't need to run the raycast on the server

icy ermine
#

well, if you dont have an authoritive server, than there can be cheating

sullen steppe
#

i'm not worrying about that yet

sullen folio
#

Exactly, it just depends on how your network is structured

sullen steppe
#

im making this as though only my friends who i trust not to cheat will be playing it

#

because that's probably true lmao

icy ermine
#

changing that whole structure later on will be like creating the whole game from scratch. something you should be aware about.

sullen steppe
#

i was kind of under the impression i could just use the anti-cheat toolkit?

sullen folio
#

@sullen steppe keep in mind that UNET is depricated

sullen steppe
#

so i saw that

#

but the learning material for the new thing

#

is like not there

sullen folio
#

Photon

sullen steppe
#

and it's in alpha?

sullen folio
#

for what you're trying to achieve

sullen steppe
#

Photon?

icy ermine
#

its a third party library

sullen folio
#

Pun specificially

sullen steppe
#

oh sick

sullen folio
#

Unity's new networking looks slick, but it's very new

sullen steppe
#

right

#

i hadn't considered that there would be third party options

#

but i guess duh

icy ermine
#

still, just sticking an "anti-cheat-module" like you called it, onto your application is not gonna work hassle-free.

sullen steppe
#

right

#

wait so i should probably just use this not-deprecated thing from the start

#

and this one is good there's not other options?

sullen folio
#

Yup. I personally really like SmartFoxServer, but if you don't have networking experience that is going to be quite the undertaking

#

And that's authoritative

sullen steppe
#

so im a professional web dev

#

but game networking is very different

#

from HTTP/websockets etc

#

but i'm not completely clueless

sullen folio
#

Oh good

sullen steppe
#

like i understand the network layers and clients and servers and all that

#

it's really just the paradigm

sullen folio
#

So basically photon uses one of the clients as the server, called the "Master Client".

#

As you're building the game, you can try to think of the Master Client as the server.

sullen steppe
#

right it's like a headless client

#

i assume

#

or just the host client

sullen folio
#

Sorta, except it's not really headless

#

It's just running the game like everyone else

icy ermine
#

i would recommend searching on github for a photon pun prototype implementation of a minigame.

sullen steppe
#

okay cool yeah

#

i'm gonna dig into this

sullen folio
#

If you're interested in a headless server, then you're going to have to go with something else (like PhotonBolt)

sullen steppe
#

while i have you are there any other like widely used third party things I should be aware of? not just networking but like

icy ermine
#

besides that, there is the "dots fps unity sample" which uses the new networking library from unity

sullen steppe
#

frameworks etc? maybe for architecture. I feel like i've been hardcoding vanilla JS with jquery and i want whatever react/redux is

icy ermine
#

just as you already noticed, there is not much of an documentation yet

sullen folio
#

@sullen steppe Something to handle the state of your game like what Redux does for React? As far as I know, there isn't really anything like that. But, unity sort of takes care of many things like that with a combination of scenes and GameObjects

#

As for third party libraries that can help you out, it really just depends on your game. Photon will take care of the networking stuff for you. There are some decent JSON libraries on the asset store if you ever run in to that issue. Most everything else will probably be graphics / sound related tools

sullen steppe
#

Alright awesome. I dont' know why it didn't occur to me that there would be third party stuff. I'll do some googling. I gotta run but thanks so much y'all

sullen folio
#

As someone who probably works with npm a lot, I'm suprised! Haha. Good luck and NP.

sacred patrol
#

@dry wave I've just read the logs way above. So uh... I'm working on a WebGL game, so I'm using websocket. Obviously websocket only support TCP.
I find it to be one of the major limiting factors to networking quality because as soon as you lose just 1 packet - the whole network layer freezes for like entire second while it's resending that one damn lost packet.
It's so bad that I had to roll my own synchronization library which would help hiding this lag. TCP is certainly not bad for games with low sync frequencies, but if the send rate is exceeding 1 message per second - forget about it. You would have to fight it rather than benefit from it.

amber trench
#

@sacred patrol i run a well-trafficked multiplayer webgl game over websockets and i do not experience this issue

sacred patrol
#

@amber trench Interesting. What's your average ping time to the servers you're contacting with ?

#

Have you tried using clumsy to simulate packet loss and latency ?

amber trench
#

if you're located in california, it's 1-5ms, i colocate my own hardware

#

i haven't tried clumsy though

#

sounds like a good thing to do ๐Ÿ™‚

#

the only people who report latency trouble are phone users in europe, lately

#

i don't have CJK players

sacred patrol
#

I see. I'm using photon cloud servers while living in the middle of nowhere. Packet loss is devastating to me.

amber trench
#

ah

sacred patrol
#

That's the reason why I became a network programmer. I keep dying to lag and bad netcode whenever I play any online games. If there's a netcode problem - I will definitely run into it and repeatedly die to it.

dry wave
#

Been writing my server and so far so good. I have another question though. When using Unity as a server for physics, collisions, ... I obviously need my world itself to be on there too. Even though I don't necessarily have to render it, it still has to be there. Now, how would I best go about updating my game world then? Since the world would be in both the client and the server. It seems quite tedious and error-prone to copy-paste the whole project every time and update the scripts.

#

I'm assuming the solution will have to do with scenes. But I'd like to leave it to the expert to guide me on that.

sacred patrol
#

Usually developers use the same project for both server and client, then just build it and run as much instances as they want, but I doubt you'll go with that because this simple solution might not look like an "expert guide".

analog fog
#

Am looking for help with Photon - I have a VR / Windows screen based project. (asymmetrical game ) For some weird reason the VR player only sees the screen based player's actions if the VR player enters the game first. I'm developing using Oculus Quest & a link cable which allows to play in editor but does not allow to sync across a network.. so I have to disconnect after building to the Quest headset and then run it. All asymmetrical based games I've seen to date are local only. Hope someone can point me to some resource, a tutorial would be nice. Currently I am building two separate versions . One pushed to the Quest ( Android) and the other is a PC build. They do connect and both join the game scene.

jade glacier
#

screen based player's actions?
Not sure what that means @analog fog

dry wave
#

@sacred patrol I just meant that you guys know more about this than me :) If it's possible to build with certain scripts disabled, then it might be an options, I'll look into that thanks.

slim ridge
#

there are souls in here

#

server and client both run the same simulation

#

thats too early for programming

#

"prediction" means your client already knows what to do with those inputs (and does so), but ultimately the server decides whether this is correct or not

#

you can sync using timestamps or some sequence value

#

and both client and server need ability to go back in time, apply changes, and re-simulate up to the current point in time

#

it's very complex and hard to pull off

#

thats why ppl flock to prepacked solutions

#

ofc, the best solution is the one that does exactly what you require nothing more nothing less

#

yeah

#

here's what mine are shaping out to be (i happen to be working on this right now)

|redundant frame count|timestamp|input count for this frame|input type|input value|...
#

the server sees the timestamp, goes back to that time in the simulation, applies the input

graceful zephyr
#

@slim ridge thats the wrong way generally to do it

#

server should not have to step back in time to simulate a client

slim ridge
#

so long as all the clients can do this as well, all the server has to do is relay that input

graceful zephyr
#

client should send input so it arrives in time to server for tick 'X' or time 'N'

#

and client locally offsets and predicts it

#

@weak plinth thats what it should do

#

well you can do either interp between two known values

#

or extrapolation with error correction

#

extrapolation is predicting the position in the future

#

based on known previous values

#

also called dead reckoning

#

huh

#

that is dead reckoning - yes

#

and that's one type of extrapolation

#

can turn that into 1 bit each for every bool

#

yeah?

#

unity is mono/.net with c#

#

has to be packed in by hand, but yes ofc

#

no

jade glacier
#

masks are basically bitpacked bools

#

they are used all over the place in C#

#

a uint can act as up to 32 bools

#

each bool field becomes a bit offset

#

usually using an enum

#

enum InputKeys { None = 0, Left = 1, Right = 2, Forward = 4, Back = 8, Fire = 16 }

#

Very piss poor example

#

But an enum mask is a bitmask

#

That is a massive topic in itself, but yeah - don't network bools as bytes or ints. Mask them together wherever possible, or bitpack them with a tool like fholm posted.

graceful zephyr
#

@weak plinth you mean a 2d fighting game? like streetfighter?

jade glacier
#

Have you made a networked game before?

#

Start with tutorials for some of the major libraries

#

your first attempt is going to be smoking garbage

#

So don't try to make your dream project first

#

Give yourself a few months of brutal failures making things you don't care about first.

#

That will teach you way more about the right questions to be asking.

#

I would avoid networking if you don't love this stuff, it only gets worse and harder.

#

Starting over from scratch is a good expectation for your first year of learning networking... many times.

dry wave
#

Hi all, another question. Imagine I have different scenes to load the world gradually. How would I handle player input then? Would I do it like in this diagram? What I can't wrap my head around is that in my opinion the player should be updated no matter the scene it's in. But on the other hand, it needs that scene to do collision detection. How would I handle this correctly?

jade glacier
#

You are trying to pull off an advanced deterministic architecture based on that graphic.

#

oh wait, those are scenes?

#

yeah, no idea

solar garden
#

Which is the better solution between:
Trying to make reliable RPCs by making your UDP transport layer reliable by sending Ack packets
or
Implementing TCP into the mix so that it handles everything that needs to be reliable

jade glacier
#

Why are you having multiple scenes?

dry wave
#

One scene one area. It needs them for collision detection, I could of course load all of them at once but no idea how that'd work either.

#

Because it's a big world and loading it all into memory at once would be too much.

jade glacier
#

This is looking very complicated as a starting point. Same question I ask everyone here, is this your first MP game or do you have a few simple working MP games/experiments under your belt? @dry wave

graceful zephyr
#

@solar garden mixing TCP and UDP is last resort

dry wave
#

You asked this last time too, I already did multiplayer in my own 2D engine, but with Unity in there there are a lot of unanswered questions.

solar garden
#

@graceful zephyr is it ?

graceful zephyr
#

@solar garden yes, either use something like KCP for reliability and low latency, or use custom UDP

dry wave
#

And it's not a starting point as I already covered all basic data communication.

jade glacier
#

Even mixing UDP and RUDP on separate channels runs the risk of race conditions. There is always the risk as new devs of mistaking messaging for simulation and losing sight of the abstraction of simulation from messaging that is critical for sanity. @solar garden

dry wave
#

But I'm no where near a network engineer so that's why I'm asking for advice ๐Ÿ™‚

solar garden
#

@jade glacier but you have to have RCPs in a game at some point right ?

jade glacier
#

RPCs are satan's work LOL

slim ridge
#

nope

dry wave
#

@jade glacier You ask how much experience I have, but do you have a follow-up on my actual question too? ๐Ÿ˜„

solar garden
#

oh rly ?! ๐Ÿ˜„

night plover
#

Hottake: RPC is just a TCP packet

#

(Or equivalent conceptually)

#

Multiple people are typing

solar garden
#

How does one make sure that some things in need of reliability happens without RPCs then ?

#

Like shooting

jade glacier
#

All networking should be:
Messaging <-> Input/State Buffers <-> Simulation

All of these conversations happening I don't think are recognizing that Simulation is where networking happens for MP games... NOT in the messaging.

night plover
#

By having the client send all its previous states

solar garden
#

Kinda built my transport layer around RPCs ๐Ÿ˜…

void spade
#

reliable ordering message is mostly unavoidable

night plover
#

Oh no

#

Look at how the new Unity NetCode is being done

void spade
#

if your player opens an inventory, then interacts with an item, those commands need to be delivered in order

#

the new Unity NetCode package even has an out of the box RPC command queue for you

dry wave
#

Well I guess not then...

night plover
jade glacier
#

those commands need to be delivered in order That is a perfect example of mistaking messaging for simulation

slim ridge
#

@dry wave build your world out of prefabs instead of scenes will make it much easier

void spade
dry wave
#

@slim ridge That is actually crazy good advice.

solar garden
#

I don't understand thats a first for me i'm gonna have a look of what you guys sent

#

"RPCs evil" no god is safe ๐Ÿ˜„

jade glacier
#

Lot of questionable advice flying around here. If you are just networking by throwing around and applying them remotely, you are already on a path of hell. but everyone starts there.

solar garden
#

I thought that was how you do it !

graceful zephyr
#

Anyhow, don't mix UDD and TCP

#

It's overly complicated for no benefit

#

And fragile

jade glacier
#

Real game networking is ALWAYS about creating a simulation that can be reduced to inputs and states against a tick.

Once you have that, you are dealing with input and state histories, and THOSE are what you sync with messaging. What you decide on messaging isn't going to be that big a concern once you have your inputs and state buffers in order.

graceful zephyr
#

If you need full reliabilty for the entire data stream, use KCP

void spade
#

then how do you suggest you handle a player sending a chat message?

graceful zephyr
#

@void spade presumably via a secondary service for chat

#

or via reliable messages built ontop of udp

jade glacier
#

chat is considered to be "not simulation"

void spade
#

... exactly

graceful zephyr
#

exactly what? ๐Ÿ˜„

void spade
#

or via reliable messages built ontop of udp

#

this is RPC

jade glacier
#

RPC is nothing

graceful zephyr
#

no it's not?

dry wave
#

@slim ridge I think though that it'll just have the same issue, you'd need to load everything in memory at the start, instead of only what is in one scene

graceful zephyr
#

You can do both reliable and unreliable RPC

void spade
#

yes it is, it's sending a message and having a procedure executed with that message as the parameter on the remoet

jade glacier
#

RPCs are just a wrapper that makes people do dumb things when they don't understand what it is doing.

graceful zephyr
#

lol... arguing what RPC is and isn't... ยฏ_(ใƒ„)_/ยฏ

#

please go away

#

unless you have something useful to contribute

solar garden
void spade
#

maybe Unity has some automatic RPC binding thing I'm not aware of, but sending a message to a remote server and executing a function with it is fundamentally a remote procedure call

jade glacier
#

LOL, that aimed at me for trolling @graceful zephyr ?

graceful zephyr
#

i'm out, absolutely useless discussion arguing semantics over what an RPC is or isn't... ยฏ_(ใƒ„)_/ยฏ

dry wave
slim ridge
#

@dry wave now you're talking about scene management which has nothing to do with networking

void spade
#

maybe you should look at the new NetCode example if it's unclear

dry wave
#

@slim ridge It does if it affects how your networking solution works

#

I'm not asking about how to load scenes, I'm asking about how to send data when using multiple scenes

slim ridge
#

solve the problem from network side of things then

jade glacier
#

Just a heads up on who fholm is btw... he is literally THE networking guru of the Unity world.

dry wave
#

That's what I'm here for asking a question

solar garden
#

Ok so NO tcp its either RUDP or no RCPs at all is there any chance that you would have some talks on what you said i'm kind of curious @jade glacier

jade glacier
#

My answers is that that all looks too vague and complicated for me to really have a good answer to. @dry wave

slim ridge
#

yeah, drissy thinking too far ahead

graceful zephyr
#

@solar garden For the last time, RPC has nothing to do with reliability, tcp, udp, rudp, etc. nothing - zip nil nilch. RPC is just an abstraction, it can be implemented on top of carrier pigeons if you wanted to

slim ridge
#

try some of the ideas you have and you'll come up with better questions

graceful zephyr
#

Has NOTHING to do with the transport protocol, etc.

solar garden
#

@graceful zephyr I was planning to do RUDP from the start but i fear that my buffer gets flood by "Ack" packages as i think i should send them 3 times

dry wave
#

@slim ridge How can you know I think too far ahead

slim ridge
#

from listening to you in this discord all day

jade glacier
#

Make your simulation first, reduce your game to a tick based simulation that consumes inputs/states to produce a new state. That is networking... not all of these concerns about RUDP vs TCP and such.

dry wave
#

Then how do you not know that I'm here progressing every day ๐Ÿ˜„

graceful zephyr
#

god the amount of misunderstanding and miss-information here.. makes my head spin, would take a week to sort this all out

jade glacier
#

It comes soooo fast

graceful zephyr
#

time to eat easter dinner o/

slim ridge
#

just listen to emotitron

solar garden
#

I'm dizzy aswell haha

dry wave
#

Yup, I did, and there we go this is the next step

jade glacier
#

Listen to fholm and Erick when they are around first. They are the ones who actually have built all of this stuff many times over.

solar garden
#

for me ?

jade glacier
#

Do you have a working simple prototype networking correctly for what you are trying to make? @dry wave

dry wave
#

@jade glacier Yes

#

Or correctly for now, maybe I'll have to adapt it later

#

As you requested too

jade glacier
#

And now you are trying to add level changes or something?

dry wave
#

Yes indeed

#

Think of it going from one area to the next

#

But honestly I think the scene changing should probably only be on client side, just not understanding how server would handle the collisions properly then

jade glacier
#

If you are trying to do like actual zones and such, that is going to not probably play out well with one Unity instance trying to serve all of the regions.

dry wave
jade glacier
#

But I have very little experience in MMO type games or anything that has zone servers and such. So I can't really give any good advice on best practices.

dry wave
#

That's why I put multiple ones, but then how can I see players in scene 1 from scene 2, if you're standing close

jade glacier
#

So you have three unity exes running on the server there?

dry wave
#

Yes

jade glacier
#

going right into the deep end it looks like.

dry wave
#

Or not if that's better

jade glacier
#

yeah, I don't know - have little experience with that sorry.

#

I would just be making shit up.

dry wave
#

I think the server should run all scenes at the same time

#

But I'm not understanding how you could then see players in another scene basically

jade glacier
#

They have to all be running if players can be in any one of the zones. But be aware that for a real game you are starting to run up some hefty server costs trying to do what you are doing

#

And MMO scale stuff is not a one man job

#

writing it is hard, maintaining it is hard, and marketing MMOs is hard.

dry wave
#

Yes I understand that

#

That's why for now I'm okay with having it not-so-scalable on the networking side

#

But one scene is just not going to cut it, so that should be in the initial development too

slim ridge
#

why not?

dry wave
#

Because there are a lot of assets

#

Unity loads them all in memory no?

#

If you load a scene

jade glacier
#

How big is your world?? And why?

#

Are you talking about scenes, or zones?

dry wave
#

Why not?

jade glacier
#

Unless your player is actually zoning, I don't see the point of the zone servers

dry wave
#

Yes he will that's why I'm asking this ๐Ÿ˜„

jade glacier
#

How big is your world?

#

WHY are you needing to make zones?

dry wave
#

Right now not big, but that's why I'm asking this, to make it bigger. If you want an example of the end result, do you know Runescape (I can screenshot part of the map)?

#

Its a good example

jade glacier
#

I don't know runescape well enough to know the scale of the world, or if it breaks the world into zones

dry wave
#

WoW?

#

Can get an example from that too

jade glacier
#

I would expect its not running full physics in runescape

void spade
#

no, RuneScape only updates the simulation every 600ms

jade glacier
#

WOW would not work with unity

dry wave
#

No it's not, neither am I, only nav mesh

void spade
#

-- it doesn't do zoning

jade glacier
#

Wow has its own VERY lightweight physics and such that make it possible to spin up a lot of instances and regions

dry wave
#

@void spade I know how it works I worked on an RSPS, but that's when you create it from scratch, I don't see how to do that in Unity, unless I'm misunderstanding something

jade glacier
#

Unity with physics is a hefty instance to spin up

#

I would not try to make any zone based MMO type stuff with Unity EXEs

#

might be doable, but no sane company would/should do that

dry wave
#

@jade glacier How would I load assets efficiently then, if not using multiple scenes?

void spade
#

I don't know the ins and outs of a distributed real-time MMO on Unity, but that's a very different story from a point-and-click RuneScape server

jade glacier
#

You are asking the wrong guy, all I can say is you are diving into the deep end of the pool holding a rock right now.

dry wave
#

No idea what that means ๐Ÿ˜„

jade glacier
#

trying to build WoW scale world with Unity executables on the server... as I was just saying.... not reasonable.

dry wave
#

I never said it's a WoW scaled world?

#

I said it'd have zones like in WoW

jade glacier
#

Ok, I pass

#

someone else please advise Drissy

slim ridge
#

cant, i dont know what hes talking about anymore

dry wave
#

If you say I don't need scenes sure fine, but it's like everyone here says the opposite of another person

jade glacier
#

Yeah, because this channels is 90% other people who are just learning this stuff.

#

Advice here unless it comes from Fredrick or Erick... is suspect and just something to think about.

#

The correct answer is don't try overambitious networking on your own without a lot of success under your belt.

#

Or it devolves into these types of conversations.

dry wave
#

I don't take everything literally, just using it as advice.

#

"without a lot of success" Won't happen if you don't try

#

Can't learn it without looking into it

jade glacier
#

Give it a shot then as you are trying it sure.

dry wave
#

But I appreciate your concern, I'll just continue looking into Unity memory management and then see if I need scenes or not

#

Thanks for all the advice

burnt axle
#

@gleaming prawn Just saw VRChat is using Photon, thats pretty impressive. They have 10 millions MAU and i have a feeling this game will be the next big "social game" in the future.

graceful zephyr
#

Yeah they use photon

jade glacier
#

The other quest game does as well, Rec Room I think uses PUN doesn't it?

graceful zephyr
#

ยฏ_(ใƒ„)_/ยฏ

jade glacier
#

I'm right now trying to make an extension for the Oculus Integration kit that is wired up with SNS/PUN2 handling

#

Trying to convert the Oculus examples to networking is brutal, everything is so cross coded and hard wired for a single player.

prisma girder
#

@dry wave You certainly can use Unity servers, and write your own distribution and zoning orchestration layer. It's a lot of work but of course it's possible. How efficiently it uses memory and CPU vs a custom lightweight physics server is a different question, but A) WoW didn't have a good answer when it launched, and was overwhelmed and crippled for weeks under the load, and B) for every 10x scale, you'll encounter entirely new unforeseen classes of problems that are hard to predict ahead of time. Big reason why lots of big multiplayer launches go poorly. Large scale distributed systems are always hard.

#

That all said, there's a good example you can look to for zoning (aka sharding) and how to handle communication across the 'edges', and there's a couple GDC talks on it too. That would be Destiny

jade glacier
#

They have teams on that stuff for a reason, its monumental at scale.

prisma girder
#

For sure

dry wave
#

@prisma girder Thanks, I'll look into that

prisma girder
jade glacier
#

I think part of the real headache is that when you scale and hit one of those walls... it usually means a massive refactor from the ground up to fundamentally make getting over that hurdle possible.

prisma girder
#

Talks about their "bubble" system, how they did zone transitions and used map design to assist

dry wave
#

@prisma girder I'm also looking at Photon as a possible option, since Albion Online used that. But I'm not sure if that's meant to be used for MMOs

prisma girder
#

@jade glacier Having worked at a hosting company on large scaling problems, I've seen a lot of that, and I've also seen the most common 'easier' reaction -- namely to throw more money at it.

#

Bigger servers, more cores, faster networking

#

Rearchitecting is almost always the right answer eventually

jade glacier
#

Keep in mind "Photon" isn't an actual product, is a collection of apis. I think you mean PUN2 and/or Realtime? @dry wave

graceful zephyr
#

TBH anyone starting out with networking trying to replicate what they did for destiny is kidding themselves

#

You're never going to build that as your first networking project

#

Never. ever.

jade glacier
#

I have been at networking for years now- I would fail miserably if I tried.

prisma girder
#

It's a cliff of a learning curve, for sure.

dry wave
#

@prisma girder What out of the box solutions would you advice to look at? E.g. Photon

jade glacier
#

At some point when the cliff is too steep no learning happens.... just inevitable death. ๐Ÿ™‚

prisma girder
#

Photon does not offer zoning distribution systems.

#

SpatialOS does in their Unity GDK. They're "working on it" for UE.

dry wave
#

Ye I said earlier I don't think it's meant for MMOs, although Albion Online used it

prisma girder
#

I don't have hands on with Spatial, but

#

You also need to take a moment and reconsider something

dry wave
#

Spatial seems to always go for UE first, and also not optimal for MMO, from what I could find

#

Yes?

jade glacier
#

Yeah, no part of the Photon catalogue has anything for people trying to make MMOs with shards. It supplies the opposite end of the dev market mostly.

prisma girder
#

Most MMOs, WoW included, do not do communication across the edges, for players.

#

You're assuming they do, but they do not.

#

Most of them make the travel appear seamless, but the active objects are not actually visible

#

Because the cross-edge interaction is the very hard problem.

graceful zephyr
#

WOW mostly solved that with the sharding system, and the sharding is not seamless AT ALL

jade glacier
#

I always have wondered how they were dealing with PVP and such that breaks out on the edges between zones.

prisma girder
#

The answer is they don't.

dry wave
#

What I'm assuming is that it starts loading the next zone the moment you reach x units from the edge, no?

prisma girder
#

Players disappear if not traveling at the same time

graceful zephyr
#

They basically said "yeah so we can't have 1k players in one area at the same time, so just limit it to 128 or 200 or w/e and then split the world"

prisma girder
#

Map design is used to help prevent crossing the edges

graceful zephyr
#

very simplistic ofc

jade glacier
#

I guess I just never got into a fight on the border

prisma girder
#

For open world stuff, you can watch players disappear on the edges if both sides are full enough

graceful zephyr
#

yeah, it's not seamless at all

#

its very much in your face

prisma girder
#

All that's seamless is the client's visual representation of your own movement

#

Which is still a hard problem but way easier

graceful zephyr
#

just it's done in a carefully constructed way where players wont notice 9/10 times

#

and that's good 'nuff

prisma girder
#

^

#

Destiny is the same sort of way, they just included a little edge bubble

dry wave
#

@prisma girder What do you mean? Is that still about zones?

graceful zephyr
#

the zones (if you think wow-zones) have nothing to do with it

dry wave
#

The visual of own movement

graceful zephyr
#

zones is just gameplay elements

jade glacier
#

yeah, I played it for years and had chased or been chased through passes and never noticed it, so they did a good job of making it not too breaking

graceful zephyr
#

like world is split into X zones

#

it has no bearing on this from a technical pov

#

yeah sure they might put edges, edges, etc. on zone borders,

#

tbh if you are tying to build an MMO, or something even MMO-ish

#

you're not gonna make it.

#

there's not even a discussion to have

prisma girder
#

I will say you will learn a lot on this path. And that can be very valuable.

jade glacier
#

WOW had the two main continents that did not connect, but I have no idea how many shards each continent was broken into

graceful zephyr
#

if you need to ask questions about how this works in a public discord server, you're never ever ever going to be able to build it to completion

prisma girder
#

It's important to have proper expectations

slim ridge
#

give up now,got it ๐Ÿ‘

graceful zephyr
#

or well, never ever is strong... but you need to put maybe 5-10 years into it

#

and most people just don't have the stamina

#

@slim ridge no, not at all... but build something simpler first.

jade glacier
#

That really isn't a joke - he isn't saying give up... he is saying that you aren't even close to ready or being in a position for this attempt to be a good or worthwhile experience.

prisma girder
#

If your expectation is "ship a game and make it big", it's a very steep hill. If your expectation is "have fun and learn a lot and maybe create something cool", go for it

jade glacier
#

There are 20 more important concepts of online game making I would put in front of shards

prisma girder
#

Most people approach it from the first side.

dry wave
#

I actually never asked how to recreate a multi-million dollar solution, only how to deal with loading scenes on the server

graceful zephyr
#

if you want to build an MMO as your first serious networking endeavour... you're just going to slowly fail at it for a few months and then give up.

jade glacier
#

loading scenes and shards are very different things

prisma girder
#

@dry wave Yes but this is a super common question and it usually leads to the second question.

#

Folks are just trying to set expectations

#

There's some hall of fame /r/gamedev posts on this very question :P

dry wave
#

Yes I understand, and appreciate it

jade glacier
#

I can count the number of people who have come into these channels looking to start an MMO and actually got even close to that on zero fingers.

graceful zephyr
#

You are are so far out of your depth you don't even know what questions to ask.

jade glacier
#

^

graceful zephyr
#

"You" here is general, not aimed at someone specific

jade glacier
#

That is really what all of this is about. You have to work your way up to where you are even asking the right questions.... which requires a lot of earlier lower level fails and successes

prisma girder
#

So that said, your actual question and diagram, on multiplexing replication to multiple servers at the edges of maps; that is the general architectural idea, yes. The major hurdle to cross first is who is the source of truth.

#

In that diagram, the client would be, which is bad.

#

That leads you to an orchestration layer responsible for steering clients, next

#

Which involves server->server communication

#

And that's about where 99% of people will get stuck or lost

#

If you make it there, come back :)

graceful zephyr
#

Yup

dry wave
#

@prisma girder Appreciate the positive advice
Thanks for the help all

prisma girder
#

You bet

jade glacier
#

good luck, worst case you will learn something new in the attempt.

#

One last comment on this topic and how it pertains to this channel.

Attempting this kind of stuff "just to learn" shows a bit of a lack of value of one's own time. Professionally speaking the best place to stretch oneself is at the edges of their ability, where they have a good chance of success and advancement fast.

graceful zephyr
#

built something simpler first

#

build a co-op 4 player top down game first

#

then do an fps maybe

#

first do MP tetris

#

etc.

#

dont need to be complete games

#

but at least workable online

#

jumping into trying to build a sharded mmo, you'll flop around like a fish on land and then give up

prisma girder
jade glacier
#

The struggle this will be now to get ANYTHING to kind of work, will involve a lot of doing it wrong and a lot of time with nothing to show. Where as if you pin it for later when you are ready for it, it will take a LOT less work and time to succeed.

prisma girder
#

I.e., you're on your own, good luck

dry wave
#

@graceful zephyr Already did all that, put from scratch not with Unity ๐Ÿ™‚ And it didn't matter if there was lag or anything, if you only have 4 players you don't have to care much about that yet.

graceful zephyr
#

huh

#

how do you not have to care about lag

#

if you have 4 players

#

ping is ping

prisma girder
#

Turn based maybe?

dry wave
#

Because it was a simple game

#

I didn't need to send much info back and forth

graceful zephyr
#

ยฏ_(ใƒ„)_/ยฏ

jade glacier
#

I've beat this poor horse enough.

prisma girder
#

lol

dry wave
#

I appreciate the advice, I go look into my solution now

prisma girder
#

I'm a very stubborn person, and I learned a lot by brute force over decades. I have a career in it as a result. But it's not the advice I'd give to anyone else.

graceful zephyr
#

ditto lol

prisma girder
#

YMMV, but it's a fun journey if you're game. Good luck

graceful zephyr
#

i do multiplayer/networking for a living

#

never went to uni or have any fancy degree

#

just didn't yield

#

but most people don't work like that i've noticed

prisma girder
#

Same and same lol

#

The youngins at my current company coming out of college are of a very different mindset, not sure how they're going to deal with the Very Hardโ„ข๏ธ problems in tech when they hit them

jade glacier
#

I'm a guitarist and a UX dev mainly.

graceful zephyr
#

time to mount my soundbar with the new 3d printed brackets i just made ๐Ÿ˜„

#

bbl o/

jade glacier
#

Getting good at networking largely is about a lot of hours and learning fast. A CS degree will help produce cleaner code, but it won't solve the paradoxes and creative problems game networking produces.

#

They are strong enough? @graceful zephyr

gleaming prawn
#

I think university has little.to do with it... Doesn't hurt,.sometimes help

#

Helped me, but not a solution for everyone, not even close

graceful zephyr
#

@jade glacier oh yeah fo r sure

gleaming prawn
#

Fholm knows this well

prisma girder
#

I often find CS majors are terrible programmers. The degree track doesn't really focus on lots of coding practice. Just theory underpinnings

gleaming prawn
#

The courses are not about programming practice... That's is up to you

jade glacier
#

I've seen CS and non CS people all fall into the theorycrafting abyss.

prisma girder
#

I'd rather hire the person who goes home and writes code for fun and contributes to a Linux distro because they use it outside work hours

gleaming prawn
#

But there's very valuable knowledge in there (if you know where too look for it,.lol)

prisma girder
#

Oh of course. Big O notation and complexity analysis is critical to large scale software engineering

#

But most people don't know it on a formal level ;P

gleaming prawn
#

I would hire fholm (no degree) and the other guy who works with us (CS major) with no questions... It's about the individual

prisma girder
#

Agreed. I've interviewed a lot of both.

gleaming prawn
#

Apsu, fholm knows all about that, with no degree... Some people get into the right knowledge, no matter what

jade glacier
#

Just hanging in the right Discord channels will get you a lot of that.

#

CS majors loooove to talk ๐Ÿ™‚

#

If people are willing to listen

#

Happy easter btw @gleaming prawn

gleaming prawn
#

Yep, happy Easter you all

#

I've stopped answering to most stuff in here

jade glacier
#

It is a bit of a repetitive time sync

#

I watch the channel for PUN2 specific stuff, but I get dragged into these big "I want make MMO, where do I get a book on that" questions.... but shouldn't ๐Ÿ™‚

prisma girder
#

I hung out answering questions in the #๐Ÿ’ปโ”ƒcode-beginner channel when I first came here, now I don't even look. It seem to be the funnel where every would-be game maker with 0 coding knowledge lands

gleaming prawn
#

It's pretty much two categories:
A) people who know their shit, these are nice to discuss with, but neither would have time for getting deep enough.
B) the teen-years old next great mmo/br guy (no offense, but they either listen, or we can talk in 10 years, then I'll listen)

prisma girder
#

Definitely a timesink

jade glacier
#

I like giving back a bit. I wouldn't be here if Fredrick hadn't brain dumped for me a lot.

#

But you can usually spot the people who are soaking it up, vs the people who are set on a path and just want validation.

gleaming prawn
#

I've always advocated being nice and answering everything (as a former professor, can't help), but when people just ignore simple advice.like: what are you trying to do, etc? Then it becomes useless....:)

jade glacier
#

yeah, very true

#

the problem is restraint.. I check in for people in actual need who will benefit... and get sucked into some of the dumb stuff ๐Ÿ™‚

#

I need better discipline LOL

gleaming prawn
#

I think for me it needs.to be a double way...

#

I'm not sure if I've been learning anything from this discord at all

#

Other places, sure

jade glacier
#

Not in the Unity channel I haven't for sure

#

But some back channels have split off from that from GDL and such

#

I'm a a few "snobby" dev discords where people all are the real deal. The conversations there regularly involve new info.

#

Unity/GDL channels I definitely feel like I am giving 99% for every 1% I get back.

sullen steppe
#

Hey I have a question, trying to understand PUN/Photon

    void PlayerShot(GameObject player, int damage)
    {
        HealthController healthController = player.GetComponent<HealthController>();
        if (healthController == null)
        {
            Debug.LogError(player.name + " got hit but does not have a health controller!");
        }
        photonView.RPC("RpcTakeDamage", RpcTarget.All, damage);
    }

In this code I'm not sure how to make the distinction that I want all clients to apply TakeDamage to one object

solar garden
#

In the life cycle of a RCP over UDP when do you consider that a rpc has been played ?

sullen steppe
#

ohhhh

#

I need the photonView of the thing getting hit

jade glacier
#

You will want to serialize that into the RPC. The only inherent thing in your RPC is the player that owns the object the RPC is being sent from.

sullen steppe
#
    void PlayerShot(GameObject player, int damage)
    {
        HealthController healthController = player.GetComponent<HealthController>();
        if (healthController == null)
        {
            Debug.LogError(player.name + " got hit but does not have a health controller!");
        }
        PhotonView hitPlayerPhotonView = PhotonView.Get(player);
        hitPlayerPhotonView.RPC("RpcTakeDamage", RpcTarget.All, damage);
    }
jade glacier
#

you want the photonView.PlayerId (forgetting the actual code off the top of my head)

sullen steppe
#

like this?

#

so i get a game object from doing the raycast for shooting

jade glacier
#

What is the RPC?

#

I don't see the hit players ID being sent in that code you just pasted

sullen steppe
#

Looking at the docs

#

it seems like

#

PhotonView hitPlayerPhotonView = PhotonView.Get(player); this gets PhotonView component on the hit player

jade glacier
#

Your HealthController should hold a reference to its PV for easy access

sullen steppe
#

ah okay

jade glacier
#

sec, let me just get it

#

pv.Owner.ActorNumber I believe

#

wait, you just want to know the object

#

just the pv.viewid for that

#

pv.ViewID

sullen steppe
#

why do i need that?

#

if i make my HealthController extend MonoBehaviourPun I get a public photonView property for free seems like

#
    void PlayerShot(GameObject player, int damage)
    {
        HealthController healthController = player.GetComponent<HealthController>();
        if (healthController == null)
        {
            Debug.LogError(player.name + " got hit but does not have a health controller!");
        }
        healthController.photonView.RPC("RpcTakeDamage", RpcTarget.All, damage);
    }

so now I have this

#

I see how to get the view id but I don't see in the RPC docs where you would use it

jade glacier
#

I don't know

#

I don't see all of your code so I can only assume based on the bits I see.

#

I thought you were trying to networking a weapon hit

sullen steppe
#

sure totally

jade glacier
#

If that originates from the shooter, you need to indicate the id of the object that was hit.

sullen steppe
#

so it does originate from the shooter

jade glacier
#

Then you need to indicate who/what was hit no?

sullen steppe
#

but it seems to me from the docs that indicating who was hit is done by calling .RPC on that game object's photonView

jade glacier
#

I see you are RPCsing from the health collider, but that doesn't seem doable

#

the shooter doesn't have authority over the object with the health does it?

#

Unless you are doing some weird Master Client acting as if its a Server kind of thing (don't do that)

#

The shooter has authority over its objects (itself, its weapon if that is networked)

sullen steppe
#

sure

jade glacier
#

The hit person has authority over his/her health.

sullen steppe
#

yup

#

im with you so far

jade glacier
#

So the conversation is Player A to all -> "I hit player B"

sullen steppe
#

right

jade glacier
#

Player B responds to that RPC from the shooter by telling its health component "You take damage"

sullen steppe
#

mhm

jade glacier
#

Player B RPCs to all "My health went down"

sullen steppe
#

okay so i follow that

#

but i think that's basically what this is doing

#

?

#

lemme see if i got this right:

#

Player A shoots Player B, this means the script running on Player A has a reference to the locally hit gameObject of playerB

#

this call: healthController.photonView.RPC("RpcTakeDamage", RpcTarget.All, damage);

#

says "hey on everyone's client run this method for Player B's gameObject"

jade glacier
#

you have to pack up on that

sullen steppe
#

the RPC call looks like this for reference

#
    public void RpcTakeDamage(int amount)
    {
        currentHealth -= amount;
        Debug.Log(transform.name + " now has " + currentHealth + " health.");

        if (currentHealth <= 0)
        {
     //         Die();
        }
    }
jade glacier
#

first RPC is Shooter saying myGun.RPC("Boomstick", otherPlayerId, maskForCritsOrwhatever)

sullen steppe
#

i see

jade glacier
#

The player has to broadcast that, or target the hit player with that

sullen steppe
#

so wouldn't that say: "Call BoomStick method on gameObject myGun on all clients"

jade glacier
#

I tend to broadcast, since if its a shot, there are graphics for that everyone will want to render

#

and its just cleaner

#

All clients would have to check to see "Oh, is that me that just got hit?"

sullen steppe
#

oh

#

i run the raycast on all clients

jade glacier
#

and if they own the health that got hit, then that triggers events for dealing with taking damage

sullen steppe
#

so i want to move the RPC back in my procedure

#

is what you're saying?

jade glacier
#

You can do either

#
  1. Have the shooter just say who it it
  2. Recreate the ray/shot on all clients
#

Either way, The shooter has to announce what it is doing in a way that will trigger the hit on the owner of the player that is getting hit

sullen steppe
#

could that cause sync issues? the second option

jade glacier
#

Its all sync issues

sullen steppe
#

okay sure

jade glacier
#

this is snapshot interpolation without rewind.

#

Your entire networking life is going to be about hiding timeframe differences

sullen steppe
#

gotcha

jade glacier
#

But the conversation has to happen one way or the other

#

The shooter can only say that it shot. The one hit is the only one that can apply damage to its health

#

Being that this is all client authority

sullen steppe
#

you mean that