#archived-networking
1 messages ยท Page 70 of 1
I think I do but maybe I'm not fully understanding that, could you elaborate on that?
Shooters use UDP and client prediction and lag compensation and rollback.
You will see it locally in prediction, but you will get a dud for a hit
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
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.
But if the server never gets it, it just doesn't update health.
Ow okay
It still shows it partially happened.
This is often called a "hit registration" issue, by players
I assumed the bullet would disappear then, but I guess not since the server can't make it disappear
With client prediction, you typically don't predict the actual hit and damage
How often does that occur though?
you still have to wait for the server to confirm that
Not very often in most big well-built infra
Partly because UDP isn't that unreliable :P
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.
Yep
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
Also, state merging is somewhat common
It is also typical to send in each player packet to the server X number of previous inputs.
It's not super common in open source netcode
@jade glacier I was honestly just thinking of having the client run the game and be corrected by the server, not a good idea?
But it is common in proprietary engines
So lost packets don't require a long ack resend process
So should I be utilising a function that checks if a player joined on each of these GameObjects @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
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
Tick rates are often less than frame rates.
That usually means you're coalescing > 2x frames of inputs into a single update
I feel that TCP is the way to go, I'm just scared it might screw with my combat system.
If you pick TCP you have to tune your retries and timeouts
@prisma girder Yes, RS has 10 ticks and LoL has 30 ticks
TCP will not, by default, just ignore dropped packets and keep going with no problem
It will wait, a while
Yes, for the sending server > client I wrote down to do that
If you have any good source let me know
Just make some small prototypes, and see.
Theorycrafting networking to death rarely gets anyone anywhere. Just build something and see.
Yes of course. This helped me a lot already, thanks both. Now that I understand the big picture better I'll start prototyping.
https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcpclient.sendtimeout?view=netframework-4.8 this is just one thing to look at, for instance
Ah great thanks for sharing
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
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
@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?
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
@sinful niche you need to make user of the OnPlayerJoin/Leave callbacks
forgetting their names
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
Is that basically opening a connection and keeping it open to send data back and forth? Like SignalR?
I'm not familiar with pipelines
Most people aren't, myself included until just this week. They're pretty specialized
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
Check that link. It's a better way to do this than ArraySegment
PUN2 though is not designed to push entity counts high enough for that to even register as a problem though.
Which .net version?
Anyway thanks again both for the help, I'll go start working on my prototype now ๐
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.
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
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 ๐
haha, totally fair.
I just need to get this GC thing resolved.
I touch it a lot and also don't like it :D
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"
Might be able to make use of Span<T>
So it has the same pains as unity. Just works = less than ideal choices.
Span not in the Unity versions supported
Ah right, you're targeting back to much older Unity
ArraySegment<byte> is the best option available at the moment for nonalloc with byte[]
zero-copy is likely a long way off
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
The entire system exists based around Unity and its use of MonoBs... so any overengineering is probably on hold until Unity completes a stack.
SpatialOS exists but it honestly seems like a mess at the moment.
I can't imagine how they could be doing well with this. They are in middleware hell.
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
Having to code around the preview landmine hell - sounds not fun.
Their docs are a big list of "this will be working soon honest"
Including the flagship feature of zoning :P
Even if it works, its going to always be breaking.
Its like trying to be a middleware dev for like facebook
That's why I'm inclined to write something that's much simpler and general enough to be useful.
Quantum ended up with its own entire memory ECS-like system I believe
Yeah they've had to do a lot of work to be deterministic
No idea how fragile that is
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
mmm
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
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
Yeah, a lot of devs are jumping to UE
Unity is experiencing a large brain drain. Not sure if the recognize that upstairs yet.
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
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.
So calls to RecvFrom just encapsulate the packets.
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 ๐
Ah, well, sending and receiving UDP, at the lowest level, is just SendTo(socket, address, data) and data = RecvFrom(socket), basically.
I just trust someone smarter than me has made sure it arrives in one piece ๐
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
What does that mean to developers?
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
Interesting
That sounds like a higher level problem though than transport level?
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"
Ah, gotcha
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
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.
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
yeah, that is kind of the million dollar question these days.
@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...
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.
Yeah, I've stopped the RPC, instead I am just trying to call a function from a gameobject
Or you are welcome to use it.
It's crazy that it's so difficult to implement a variable on a gameobject that is kept across all connections... gah
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.
I'll give it a try!
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.
I'm really bad with packages - how would I import it/where do I need to save the unitypackage file? ๐
I do, yeah - how do I go from that to having it in Unity?
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
You should just be able to physically drag in the .unitypackage file
dragging it into the hierarchy like that will import as well yeah
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
Oh God I'm an idiot...thanks guys
I'm not sure exactly where to add, but these errors appear
Networking is something very new to me, but I'm already having troubles at the getting-started page haha
Make sure you have the [BurstCompile]
Right afterwards it tells me this
So I add the burst compiler inside the GoInGameRequestSystem, but the error still appears
@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
He is fighting with getting client variables synced up with for late joiners @sullen folio
@jade glacier ah got it
Easiest to DM you @sullen folio ?
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.
That's a fair point - was more worried my disjoint ramblings were exceeding capacity ๐
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.
@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
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?
@mellow sapphire wish I could point you in the right direction, but I've yet to look at the new networking preview for Unity
The DOTS channel likely is of better help than the networking chan for Netcode
Is it normal for me to have so much difficulty with just the GettingStarted documentation @sullen folio ?
@mellow sapphire yes. It's a lot to take in especially if you are newer to programming
Anything part of the new DOTS/ECS stuff is going to be brutal.
The getting started is pretty much the only thing out there atm
@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
Which version of NetCode are you on?
Well, that's because the syntax has updated
Oh, right
@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.
[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>
{
}
@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
Multiplayer is one of the most complicated things you can encounter in gamedev
@stray scroll This is different from the documentation, why is that?
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)
@night plover Oh boi. I mean, I like the challenge, but at least some tutorials would be nice
@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.
@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
@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?
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
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
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
@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
@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
@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
Yeah - I have been trying for ages to work out how to set the integer for the ones that aren't "yours"
Because RpcTarget.AllBufferedViaServer will also call it on the client that it is called from
@sinful niche give me one second and I will show you how it works
@sinful niche could you do me a favor and paste that code in?
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
Yah that would work ^
Ok, that ended badly https://pastebin.com/0hwsLmKG here's the pastebin...
@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?
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
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
@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.
Haha, sorry it's taking me a minute too
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?
So that variable you are retrieving from PlayerPrefs is just whatever was stored on that client previously ; you do understand that right?
@mellow sapphire updated the code I posted to better example
I understand, yeah.
@sinful niche also, you can pass values like this
@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
GetComponent<PhotonView>().RPC("UpdateAnimation", RpcTarget.AllBufferedViaServer, "here", 1, "are", true, "some", false, "things");
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.
Still too many vague parts in that for me to follow
@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.
I'm attempting to set an animation variable to a stored integer Set where?
PlayerPrefs
and the value is originating where?
^
Could you send that code?
When describing networking problems, pronouns are evil, but painfully explicit
Yah. it's kind of like an audit trail, we're just trying to find the root of the problem
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
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?
Could you Debug.Log() the player pref BEFORE you do any PRC calling?
and make sure it's the value you want?
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
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.
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
So that doesn't describe any networking at all
What is being networked in that series of events, and why?
So you need to remember too, that photonView.isMine will only be true on object of the client that it belongs to
edited ^
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.
Yes - that's what I'm trying to get at
I've just been working on it for too long to make sense haha
That is the exact opposite of what you just described LOL
haha ok now that makes sense
It's been a long day
no worries
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.
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
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?
@stray scroll Thanks! By the way, is this the Multiplayer Asteroid project?
https://github.com/Unity-Technologies/multiplayer/tree/master/sampleproject/Assets/Samples/Asteroids/Mixed
Yeah @jade glacier
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)
- Spawn your player
- Get your PlayerPref
- Apply it to your newly spawned player
- Send an RPC from your player object
- Other connections will rcv that RPC on your player object, and can apply it to their local copy
Like this @sullen folio?
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
Why is an official Unity discord blocking you guys from pasting small bits of code?
Trying that now
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?
You can actually see it for a second
That lack of ismine in start looks like a problem though
These are spawned players right? Not scene objects?
I had to call UpdateAnimation in the IsMine but apart from that it worked
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.
Ah I'm back. Sorry it blocked me from the chat
Lol, must have been from spamming code in the box
Unity Discord is hostile
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.
Basically, what's happening is that method is getting called 1 time on EVERYONE's client, including the one it was called on.
Start is going to fire on all player objects on every connection
@jade glacier yes - that's why the implementation itself is a bit odd to me
But, it does work
It will, because that RPC just won't fire unless you are IsMine
So its just shunted for you
@jade glacier let me go back up and read your chats because I lost you somewhere
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
@jade glacier Yah you caught me on to an issue. Throw a `if(!photonView.isMine) return; in the start
thanks @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
@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
yeah, putting networking code in start is fragile
Yeah - I had worked that out previously but thanks
better practice later is to try to stick to OnJoinedRoom
Yah, it's typically something I don't do so I didn't even catch that - nice catch
That is the first moment an object can safely use IsMine
Does anyone know of a complete C# networking tutorial / book / ...? Even the book I bought doesn't explain things.
Those words don't really go together in the context of gaming like that @dry wave
@sinful niche I'm glad we could be of help. Let us know if you have anything else
C# is C# ... game networking is game networking
Thank you very much โค๏ธ
gl
Networking for Unity is all about the libraries you use.
the .net core networking stuff is VERY low level
I'm talking about the .net core networking stuff yes
Yah. I'd wrap your head around networking in general before even considering getting into the code - if you don't know it already
Their docs are fine yes, but it's just bits and pieces to mush together
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?
.net networking is not going to get you anything you need for game networking though
Why not?
game networking is a very very different set of problems that basic messaging
But the code is the same
yeah, not really
What
@sullen steppe yes
The core code for sending a byte[] from one connection to another is, but that is hardly the difficulty in game networking
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
Yes so the code is the same, and I'm looking to know the code
by Command I mean like the [Command] thing
I'm sorry no threading in Discord is tough
LiteNetLib is C#
@sullen steppe You basically have the right idea
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(...)
Are you only playing audio, or is anything else happening?
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
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
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
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
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
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
i don't know what to call it but some manager
Exactly ^^^
FooManager whatever
Exactly what @icy ermine said
Yes there you go
and in RpcShotFired i should call AudioManger.Instance.PlaySound
then do all the sound and flashing in the same method
on the local client
just do 1 call for 1 bullet
you can have multiple methods, just call all of them in the ONE rpc method
Of course, I should have probably said that -> Once RPC *** method
[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?
definitely
like we don't need to run the raycast on the server
well, if you dont have an authoritive server, than there can be cheating
i'm not worrying about that yet
Exactly, it just depends on how your network is structured
im making this as though only my friends who i trust not to cheat will be playing it
because that's probably true lmao
changing that whole structure later on will be like creating the whole game from scratch. something you should be aware about.
i was kind of under the impression i could just use the anti-cheat toolkit?
@sullen steppe keep in mind that UNET is depricated
Photon
and it's in alpha?
for what you're trying to achieve
Photon?
its a third party library
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!
Pun specificially
oh sick
Unity's new networking looks slick, but it's very new
right
i hadn't considered that there would be third party options
but i guess duh
still, just sticking an "anti-cheat-module" like you called it, onto your application is not gonna work hassle-free.
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?
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
so im a professional web dev
but game networking is very different
from HTTP/websockets etc
but i'm not completely clueless
Oh good
like i understand the network layers and clients and servers and all that
it's really just the paradigm
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.
Sorta, except it's not really headless
It's just running the game like everyone else
i would recommend searching on github for a photon pun prototype implementation of a minigame.
If you're interested in a headless server, then you're going to have to go with something else (like PhotonBolt)
while i have you are there any other like widely used third party things I should be aware of? not just networking but like
besides that, there is the "dots fps unity sample" which uses the new networking library from unity
frameworks etc? maybe for architecture. I feel like i've been hardcoding vanilla JS with jquery and i want whatever react/redux is
just as you already noticed, there is not much of an documentation yet
@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
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
As someone who probably works with npm a lot, I'm suprised! Haha. Good luck and NP.
@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.
@sacred patrol i run a well-trafficked multiplayer webgl game over websockets and i do not experience this issue
@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 ?
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
I see. I'm using photon cloud servers while living in the middle of nowhere. Packet loss is devastating to me.
ah
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.
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.
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".
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.
screen based player's actions?
Not sure what that means @analog fog
@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.
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
@slim ridge thats the wrong way generally to do it
server should not have to step back in time to simulate a client
so long as all the clients can do this as well, all the server has to do is relay that input
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
@weak plinth https://gist.github.com/fholm/d1e933136cd51fc3a25e2e0b810781f3 like this
no
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.
@weak plinth you mean a 2d fighting game? like streetfighter?
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.
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?
You are trying to pull off an advanced deterministic architecture based on that graphic.
oh wait, those are scenes?
yeah, no idea
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
Why are you having multiple scenes?
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.
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
@solar garden mixing TCP and UDP is last resort
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.
@graceful zephyr is it ?
@solar garden yes, either use something like KCP for reliability and low latency, or use custom UDP
And it's not a starting point as I already covered all basic data communication.
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
But I'm no where near a network engineer so that's why I'm asking for advice ๐
@jade glacier but you have to have RCPs in a game at some point right ?
RPCs are satan's work LOL
nope
@jade glacier You ask how much experience I have, but do you have a follow-up on my actual question too? ๐
oh rly ?! ๐
Hottake: RPC is just a TCP packet
(Or equivalent conceptually)
Multiple people are typing
How does one make sure that some things in need of reliability happens without RPCs then ?
Like shooting
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.
By having the client send all its previous states
Kinda built my transport layer around RPCs ๐
reliable ordering message is mostly unavoidable
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
Well I guess not then...
https://www.youtube.com/watch?v=k6JTaFE7SYI This explains how you can achieve determinism with UDP packets
Take an in-depth look at how the netcode of a fast-paced multiplayer shooter like Unity's FPS Sample works. Learn about snapshot generation and compression, client-side prediction and lag compensation. See how the game code has been structured into server and client parts to e...
those commands need to be delivered in order That is a perfect example of mistaking messaging for simulation
@dry wave build your world out of prefabs instead of scenes will make it much easier
the implementation in libyojimbo (reliable.io and netcode.io) is pretty good
Introduction Hi, Iโm Glenn Fiedler and welcome to Building a Game Network Protocol.
Many people will tell you that implementing your own reliable message system on top of UDP is foolish.ย After all, why reimplement TCP?
But why limit ourselves to how TCP works? But thereย are so...
@slim ridge That is actually crazy good advice.
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 ๐
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.
I thought that was how you do it !
Anyhow, don't mix UDD and TCP
It's overly complicated for no benefit
And fragile
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.
If you need full reliabilty for the entire data stream, use KCP
then how do you suggest you handle a player sending a chat message?
@void spade presumably via a secondary service for chat
or via reliable messages built ontop of udp
chat is considered to be "not simulation"
... exactly
exactly what? ๐
RPC is nothing
no it's not?
@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
You can do both reliable and unreliable RPC
yes it is, it's sending a message and having a procedure executed with that message as the parameter on the remoet
RPCs are just a wrapper that makes people do dumb things when they don't understand what it is doing.
lol... arguing what RPC is and isn't... ยฏ_(ใ)_/ยฏ
please go away
unless you have something useful to contribute
#archived-networking turned into a stream ๐
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
LOL, that aimed at me for trolling @graceful zephyr ?
i'm out, absolutely useless discussion arguing semantics over what an RPC is or isn't... ยฏ_(ใ)_/ยฏ
@graceful zephyr Before you're out could you look at my question? ๐ (https://discordapp.com/channels/489222168727519232/497874116246896640/698549169056645201)
@dry wave now you're talking about scene management which has nothing to do with networking
maybe you should look at the new NetCode example if it's unclear
@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
solve the problem from network side of things then
Just a heads up on who fholm is btw... he is literally THE networking guru of the Unity world.
That's what I'm here for asking a question
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
My answers is that that all looks too vague and complicated for me to really have a good answer to. @dry wave
yeah, drissy thinking too far ahead
@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
try some of the ideas you have and you'll come up with better questions
Has NOTHING to do with the transport protocol, etc.
@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
@slim ridge How can you know I think too far ahead
from listening to you in this discord all day
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.
Then how do you not know that I'm here progressing every day ๐
god the amount of misunderstanding and miss-information here.. makes my head spin, would take a week to sort this all out
It comes soooo fast
time to eat easter dinner o/
just listen to emotitron
I'm dizzy aswell haha
Yup, I did, and there we go this is the next step
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.
for me ?
Do you have a working simple prototype networking correctly for what you are trying to make? @dry wave
@jade glacier Yes
Or correctly for now, maybe I'll have to adapt it later
As you requested too
And now you are trying to add level changes or something?
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
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.
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.
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
So you have three unity exes running on the server there?
Yes
going right into the deep end it looks like.
Or not if that's better
yeah, I don't know - have little experience with that sorry.
I would just be making shit up.
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
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.
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
why not?
Because there are a lot of assets
Unity loads them all in memory no?
If you load a scene
Why not?
Unless your player is actually zoning, I don't see the point of the zone servers
Yes he will that's why I'm asking this ๐
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
I don't know runescape well enough to know the scale of the world, or if it breaks the world into zones
I would expect its not running full physics in runescape
no, RuneScape only updates the simulation every 600ms
WOW would not work with unity
No it's not, neither am I, only nav mesh
-- it doesn't do zoning
Wow has its own VERY lightweight physics and such that make it possible to spin up a lot of instances and regions
@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
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
@jade glacier How would I load assets efficiently then, if not using multiple scenes?
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
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.
No idea what that means ๐
trying to build WoW scale world with Unity executables on the server... as I was just saying.... not reasonable.
cant, i dont know what hes talking about anymore
If you say I don't need scenes sure fine, but it's like everyone here says the opposite of another person
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.
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
Give it a shot then as you are trying it sure.
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
@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.
Yeah they use photon
The other quest game does as well, Rec Room I think uses PUN doesn't it?
ยฏ_(ใ)_/ยฏ
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.
@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
They have teams on that stuff for a reason, its monumental at scale.
For sure
@prisma girder Thanks, I'll look into that
https://www.gdcvault.com/play/1022246/Shared-World-Shooter-Destiny-s this one in particular
For Bungie's new game Destiny, we wanted to create a shared world shooter - a player experience that combined low-latency action gameplay, always-available drop-in cooperative missions, and seamless in-world interactions with strangers. The...
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.
Talks about their "bubble" system, how they did zone transitions and used map design to assist
@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
@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
Keep in mind "Photon" isn't an actual product, is a collection of apis. I think you mean PUN2 and/or Realtime? @dry wave
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.
I have been at networking for years now- I would fail miserably if I tried.
It's a cliff of a learning curve, for sure.
@prisma girder What out of the box solutions would you advice to look at? E.g. Photon
At some point when the cliff is too steep no learning happens.... just inevitable death. ๐
Photon does not offer zoning distribution systems.
SpatialOS does in their Unity GDK. They're "working on it" for UE.
Ye I said earlier I don't think it's meant for MMOs, although Albion Online used it
I don't have hands on with Spatial, but
You also need to take a moment and reconsider something
Spatial seems to always go for UE first, and also not optimal for MMO, from what I could find
Yes?
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.
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.
WOW mostly solved that with the sharding system, and the sharding is not seamless AT ALL
I always have wondered how they were dealing with PVP and such that breaks out on the edges between zones.
The answer is they don't.
What I'm assuming is that it starts loading the next zone the moment you reach x units from the edge, no?
Players disappear if not traveling at the same time
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"
Map design is used to help prevent crossing the edges
very simplistic ofc
I guess I just never got into a fight on the border
For open world stuff, you can watch players disappear on the edges if both sides are full enough
All that's seamless is the client's visual representation of your own movement
Which is still a hard problem but way easier
just it's done in a carefully constructed way where players wont notice 9/10 times
and that's good 'nuff
@prisma girder What do you mean? Is that still about zones?
the zones (if you think wow-zones) have nothing to do with it
The visual of own movement
zones is just gameplay elements
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
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
I will say you will learn a lot on this path. And that can be very valuable.
WOW had the two main continents that did not connect, but I have no idea how many shards each continent was broken into
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
It's important to have proper expectations
give up now,got it ๐
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.
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.
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
There are 20 more important concepts of online game making I would put in front of shards
Most people approach it from the first side.
I actually never asked how to recreate a multi-million dollar solution, only how to deal with loading scenes on the server
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.
loading scenes and shards are very different things
@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
Yes I understand, and appreciate it
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.
You are are so far out of your depth you don't even know what questions to ask.
^
"You" here is general, not aimed at someone specific
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
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 :)
Yup
@prisma girder Appreciate the positive advice
Thanks for the help all
You bet
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.
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
I would add one small thing that amuses me. Epic's advice on this from https://docs.unrealengine.com/en-US/Engine/LevelStreaming/WorldBrowser/#bigworldsandmultiplayer is ```Implement your own server solution. MMO licensees mostly do this.
or
Implement some layer between clients and unreal dedicated servers which will transform shifted absolute positions from the clients and route them to the right dedicated server, which only holds part of the world where client is.```
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.
I.e., you're on your own, good luck
@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.
huh
how do you not have to care about lag
if you have 4 players
ping is ping
Turn based maybe?
ยฏ_(ใ)_/ยฏ
I've beat this poor horse enough.
lol
I appreciate the advice, I go look into my solution now
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.
ditto lol
YMMV, but it's a fun journey if you're game. Good luck
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
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
I'm a guitarist and a UX dev mainly.
time to mount my soundbar with the new 3d printed brackets i just made ๐
bbl o/
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
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
@jade glacier oh yeah fo r sure
Fholm knows this well
I often find CS majors are terrible programmers. The degree track doesn't really focus on lots of coding practice. Just theory underpinnings
The courses are not about programming practice... That's is up to you
I've seen CS and non CS people all fall into the theorycrafting abyss.
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
But there's very valuable knowledge in there (if you know where too look for it,.lol)
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
I would hire fholm (no degree) and the other guy who works with us (CS major) with no questions... It's about the individual
Agreed. I've interviewed a lot of both.
Apsu, fholm knows all about that, with no degree... Some people get into the right knowledge, no matter what
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
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 ๐
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
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)
Definitely a timesink
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.
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....:)
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
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
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.
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
In the life cycle of a RCP over UDP when do you consider that a rpc has been played ?
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.
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);
}
you want the photonView.PlayerId (forgetting the actual code off the top of my head)
What is the RPC?
I don't see the hit players ID being sent in that code you just pasted
Looking at the docs
it seems like
PhotonView hitPlayerPhotonView = PhotonView.Get(player); this gets PhotonView component on the hit player
Your HealthController should hold a reference to its PV for easy access
ah okay
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
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
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
sure totally
If that originates from the shooter, you need to indicate the id of the object that was hit.
so it does originate from the shooter
Then you need to indicate who/what was hit no?
but it seems to me from the docs that indicating who was hit is done by calling .RPC on that game object's photonView
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)
sure
The hit person has authority over his/her health.
So the conversation is Player A to all -> "I hit player B"
right
Player B responds to that RPC from the shooter by telling its health component "You take damage"
mhm
Player B RPCs to all "My health went down"
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"
you have to pack up on that
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();
}
}
first RPC is Shooter saying myGun.RPC("Boomstick", otherPlayerId, maskForCritsOrwhatever)
i see
The player has to broadcast that, or target the hit player with that
so wouldn't that say: "Call BoomStick method on gameObject myGun on all clients"
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?"
and if they own the health that got hit, then that triggers events for dealing with taking damage
You can do either
- Have the shooter just say who it it
- 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
could that cause sync issues? the second option
Its all sync issues
okay sure
this is snapshot interpolation without rewind.
Your entire networking life is going to be about hiding timeframe differences
gotcha
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
you mean that