#archived-networking
1 messages Β· Page 49 of 1
no problem π
Hello Guys, i am making a unity multyplayer game its an fps but i got a little problem see, i got this hitmarker that i want to show for .25seconds i already made a code for that but when i shoot a player every player gets to see the hitmarker i only want it to be seeing from the player who shot the other any fixes??? i use UNET btw thank you π
@velvet tulip Did you figure out the problem?
nope π¦
@velvet tulip So your problem as you say is it that you have this animation of a hitmarker that you want to show when a player hits another player, but only the player that made the shot. It's a bit hard to say in what way you are shooting, with an object, raycast etc. But let me ask you if your players move around in the environment?
Hi!
I'm thinking about doing a game using networking and a dedicated server. Where would you guys recommend me to start to learn how you do multiplayer games in Unity? (I have basic knowledge in networking but not in Unity)
I don't need anything stable or something like that as I just want to play around for now. (I heard there are many changes coming in the networking)
Hi there - I'm sure this has been asked before, but the unity technologies tutorial on jobified multiplayer seems to be a bit out of date, and im getting an exception when I run the code as is
has anyone done any troubleshooting on this?
@steep plinth is it using unity multiplayer?
Yes! I was working through this to start learning the new DOTS instead of UNET
maybe consider trying out Photon PUN - https://www.photonengine.com/en-US/PUN
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!
oh nevermind, is this a new thing? looks neat sorry π
Yeah they have a new networking stack coming out, and this was to be a guide for it
However the API is changing regularly still so some of it is outdated, and I'm getting a shared resource error between my two jobs.
Has anyone worked with this before?
InvalidOperationException: The previously scheduled job ServerUpdateConnectionsJob writes to the NativeArray ServerUpdateConnectionsJob.connections. You must call JobHandle.Complete() on the job ServerUpdateConnectionsJob, before you can read from the NativeArray safely.
Seems like Complete is synchronizing the threads, but if I complete, it deallocates the job so I lose a reference. The server works then but i get a separate exception
This is an AtomicSafetyHandle error
I'm using the Netcode and works fine for me
Are you working from the samples, or doing your own stuff?
@stray scroll sry for the late respons but yes i am using raycast and yes i can move around in the environment its an fps
and it isn't an animation its a image that i want to enable and disable when the player shoots the other player π
i want it only to be enable .25 seconds tho
do you want me to show my script to you ??
In the start function I have the first player that joins the room make an RPC call declaring himself as player 1 in a buffer
So that all the next players that join will know he is player 1
However when I get player 2 to join the room
Player 2 adds himself to the list as player 1
in the start function
And only after the start function does the buffer take place and add's itself as player 2
so then all instances always have themselves as player 1
is it possible for the buffered command to happen during the start function?
@velvet tulip So I assume if you move one player, another doesn't move? Can't you apply the same logic to your animation?
@spiral glen Why not use AllBufferedViaServer ?
@spiral glen AllBufferedViaServer is not a great idea.
It buffers ALL calls, and they can build up.
You're better off just having the owner send the information manually when a player joins.
@stray scroll no its something else its that when the localplayer shoots and the raycast hits tag "player" There needs to be a hitmarker than is showed up for 0.25 seconds
i'll give u my script
HitmarkerScript
@velvet tulip I thought u said you were using UNET, why is there PunRPC?
And your check to start the hitmarker is outside the check for input
So it will start on all Hitmarker scripts you have all the time for the player they belong to
and how to do that xD,??
oh
yea
its unchecked
i will remove punrpc in a sec and see what that gives
but do i need to use ''if(!islocalplayer)' or if(!photonview.isMine)?
oke thx
π
edit
i use photon
what do i need to add on the image itself? network identitie and photonView??
its a prefab in player resourcer
you seem to be mixing the two libraries in all of your questions. NetworkIdenity should not be in a PUN project
does anyone have a GameObject custom type for PUN 2?
is there a way to do player rotations more consistently? Seem like my client and my server somehow end up having differerent rotations over time, despite sharing the same codebase
Entities.ForEach((CharacterController controller, PlayerClient player) => {
if (player.registry.inputHistory.TryDequeue(out InputHistory history))
{
player.transform.Rotate(new Vector3(0.0f, player.registry.mouseAccel, 0.0f) * 20 * Time.fixedDeltaTime);
controller.Move(player.transform.localRotation * player.GetAcceleration(history).normalized * 10 * Time.fixedDeltaTime);
player.registry.tick++;
}
if (player.registry.inputHistory.Count < 1) {
player.transform.Rotate(new Vector3(0.0f, player.registry.mouseAccel, 0.0f) * 20 * Time.fixedDeltaTime);
controller.Move(player.transform.localRotation * player.registry.acceleration.normalized * 10 * Time.fixedDeltaTime);
player.registry.tick++;
}
Debug.Log($"Client {player.registry.mouseAccel}");
});
Only difference between server and client codebase is that ``PlayerClientisPlayerServer` in the entity loop
and both handle updates at the same rate
If you only sync inputs and never sync states, loss will become a problem
Typical server auth pattern is you send inputs from player to server, server applies them, and sends out the state results to all clients (including the owner that may have been predicting)
@gleaming fossil
Gotcha, yeah thats the pattern that I am going with. Went with a shared codebase to make the client side predictions better
my reconcilliation works, its just that my
if (player.registry.inputHistory.Count < 1) {
player.transform.Rotate(new Vector3(0.0f, player.registry.mouseAccel, 0.0f) * 20 * Time.fixedDeltaTime);
controller.Move(player.transform.localRotation * player.registry.acceleration.normalized * 10 * Time.fixedDeltaTime);
player.registry.tick++;
}
Seemed to have caused the issue
not sure why
Deleted it and now rotation and movement is spot on...
I process inputs half as slow as the player moves
so the movement is jittery
Which is why I wrote that, in order to fill the gap between updates
but that seems to create the inconsistency that I am experiencing...
Is a queue of inputs maybe not such a good idea emo? Thinking memory and GC wise
What is a Generalist?'
@gleaming fossil a ring buffer of input structs is pretty normal for server auth.
@spiral glen Making a gameobject custom type isn't realistic.
You'd have to consider every possible variation of it.
Yea that's way too hard
I just gave it the coordinates of the gameobjects location
And found the object thanks to its coordinates
Probably not the best way to do this
Idk
@gleaming fossil You can check at the multiplayer sample for some inspiration if you just don't want to use it right off : ) https://github.com/Unity-Technologies/multiplayer
Currently using dark rift 2 and very happy with it, used it for half a year. Just kept experimenting with the authoritive model
How well would you say input buffers scale?
I somehow imagine the GC going nuts dependant on how much there is
GC would be if you don't prealloc your classes/arrays.,. So of course prealloc, reuse and pool as needed. @gleaming fossil
Hello all!
I am testing this solution: https://normcore.io/documentation
What do you think about?
Interesting at first but seems like its only useful for a VR chat type of game @karmic void
Not only I think, very similar to Photon with TransformView and DataStore for persistent data
I just started making a new game and i dunno if i should wait for the new networking system or already use it. Or just still use the old one anybody that can help me out?
Waiting gets you nowhere. You need to start making failed networking projects, or running tutorial projects with any library, because there is a massive learning curve - and the new ECS networking system is only going to be more complicated to use rather than easy compared to what exists currently as options. @mighty urchin
I tried PUN 2 first and then abandoned it completely for a full custom networking implementation using a raw UDP library. Extremely happy with the switch.
But it wasn't until I tried something like PUN 2 that I understood it's flaws. So you just need to pick something and try it to learn.
@jade glacier thnx
Someone can help me out with networking?
@nimble berry Got the DOTS netcode working π do you have any clue on making a headless server? I guess the NetworkEndpoint is used to define the IP address but other than that I'm clueless hehe. Is it required to make a seperate scene? If so, how would the PlayMode Tools work if there are two scenes involved?
@slow wagon : Yes. Ask a few concrete questions and I'm sure you get some input here.
@jade glacier this may sound stupid but how to see if ur using photon or Unet ?
@carmine dragon I haven't done a dedicated server yet. On a first glance there are two parts involved:
- Starting the server: Read a config file and start the server up according to the config. I would do this in a seperate scene with a monobehavior reading the config and starting the server part. I haven't used the playmode tools, so i don't know how they act in this scenario.
- Creating server only prefabs without textures to save a lot of disk space
Weird things are happening with PUN 2 right now
I didn't change any code
and when I connect to a random room
it creates a new one
but when I do that with the new account
it does not find the newly created room
and also creates a new one
@velvet tulip did you install pun2 from the asset store?
The editor may be connecting to a different region. I always hand enter a region in settings for dev. @spiral glen
ill give that a shot
do you just set fixed region to eu in the server settings?
yea that fixed it thanks @jade glacier
@nimble berry Ah, alright, I guess I'll have to find a way to use the PlayTools with a seperate scene then π cheers
@spiral glen π
is there a way to run both clients in unity?
would be a lot easier for debugging
and a lot faster without having to rebuild every 5 minutes
Some people run two editors. Never have tried though. Make your networking separate from most of your heavier graphics and audio stuff. Builds take like 10 seconds if you work on the networking without all of that.
its photon thx @jade glacier
Then be sure not to be using any cases of using UnityEngine.Networking and you should be fine. @velvet tulip
oh thanks didn't knew
π
@jade glacier so that means i can use "if(photonview.isMine)"
if you are using the photon usings and base classes/interfaces yeah
How can I set a spawned camera as the main camera?
I am spawning a bunch of player prefabs all from the same player object. How do I link these together in code? Is it through a unique id?
@spiral glen : As you ran into the issue with differing regions: I could use some info to fix this.
The region pinging results can be logged very easily: In the PhotonServerSettings, set the PUN logging level to "Informational".
For the editor, you can force best region pinging. Use the "Reset" button in the PhotonServerSettings to clear the "Best Region Preference".
Via code, you an also clear the setting: ServerSettings.ResetBestRegionCodeInPreferences();
Two log entries are of interest:
"PUN got region list. [...]" and "Region Pinging Result" which contains multiple lines.
We need those from the clients that have different opinions of which region to choose.
If anyone runs into this and has some time to help: PM me the results from 2 clients that are not finding one another.
Thanks
@slow wagon: The result values of Instantiate is the object you just created. In the code that spawns the local instances, you can get the references and attach the cam.
Remotely, PUN will instantiate the other's objects and not attach the cam.
Not on my computer right now but ill do that for ypu as soon as I get back
Has anyone here made a a networked physics-based game using an authoritative server?
Not a game, but did make a proof of concept library that was server auth physx sync with resim done on a second lightweight physics scene @glacial totem
@jade glacier So right now when i handle a state correction, i perform the correction and fast forward the client back to where it was (clients run in the future compared to server)
And after that fast forward, i interpolate rigibody position, rotation, and velocities
Basically that is the idea
Are there dynamic interpolation algorithms? Like right now I'm Lerping position with a .3f time value
That sounds very wrong
Just wondering if there's any other techniques where the interpolation isn't static
You should have a fixed simulation rate
I do.
Then lerp against that
what do you mean by that?
.3f time value is the last argument supplied to the lerp function
I think you misunderstood
t = (time.time - time.fixedTime) / time.fixedDeltaTime
is there any explanation on that?
Not much more than what the equation is. That is how you interpolate physx ticks in update
are you saying the lerping should be based on how many ticks everything was fast forwarded?
You don't lerp anything on your simulation
Lerping is only for the cosmetic Update() stuff
In this case I'm lerping rigibody simulation stuff
because physics need to match visuals
Resim is about going back, applying the server state to the client, and the client reapplying all inputs and resulting each tick back to current
Okay that's what I'm doing. However, if I do that without anything on top, you're gonna end up with sudden changed
The client is about 100ms in the future in perfect world conditions
Physics doesn't need to match visuals. If they are rbs they will interpolate themselves. If it's your own physics, you have to keep the visual.
so 100ms of an object going left when 100ms ago it suddenly went right.
That looks bad.
So i should remove Lerping on my end, and just turn on Rigibody Interpolation on the component?
I would, no point fighting Unity
But isn't interpolation very game specific
Physics interpolation is pretty standard
t = (Time.time - Time.fixedTime) / Time.fixedDeltaTime
Lerping the last two results of simulation
but if I'm rewinding and fastforwarding, how will Unity know what the last two results are?...
Becasuse technically speaking non of the in between matters
Will Unity only lerp on Update?
So nothing that happens in between matters?
You are confusing the two works out sounds like
Simulation is just states on a fixed tick
State[x] + inputs[x] = state[x+1]
Resim is just going back to a previous state index, changing that state to match the servers result, and resimulating back to current
There is no lerping
You only lerp in update, it has nothing to do with the sim states
so i guess I'm just unclear because I don't want visuals that don't match the current physics word
I get you now
i don't want my rigibody to be in one position but the rendered model to be in another
because anything interaction with that model won't actually work right
because the rigidbody isn't actually there
Depending on unity version, you can do that
I'm on alpha
I haven't touched that, so I have no best practice there. I just let it hard correct
Because desyncs are rare. Regular interpolation still happens.
To really slow down the resync you will need to create cosmetic objects I suspect
Or like detach the cosmetic and move that while in desync
Basically your Colliders and such could correct instantly, but tween the graphics/player cam
You have to have them not match, or else you will still be in desync
Unless you are ok with making clients resim A LOT. It's going to get expensive though.
I just would hard correct, the cases of desync should be rare of you design with that intent
@jade glacier are you talking about a multiplayer game though...?
Predicting other clients is impossible.... so the expectation has to be that state corrections will happens like 60 times a second...
It's impossible to predicting other clients with ever-changing input
Players only predict their own objects usually
Depending how deterministicy you are trying to be
@glacial totem
Yeah that's where the disconnect is.
The reason for the resim is to account for not having a complete sim
You're speaking on the grounds of basically what most games do in the past.
I'm speaking on more current practices like what RL does
If it were a complete soon on all clients, you may as well go deterministic
RL predicts physics for all rigidbodies
I'm talking like Overwatch and such
Yeah also slightly different since it's not a true physics based game
That's fine, it's the same deal. They extrapolate to try to keep the player on the present
But it will always be wrong, so lots of resim will have to happen
Yup understood
That's what I have, that's what's happening
I'm just getting more stutter than I want during the corrections
And I'm not necessarily sure what can be done to improve it
So you are trying to smooth the other players? Not the players Avatar?
I'm smoothing everything
Even my own player when it happens
and I still get deterministic results with my own player
Yeah, I have no best practice for that
because the margin of error is so low
if i connect to the server and interact with the physics object (a hockey puck in this case)
I get about 1-2 corrections every couple of seconds
Which is technically perfection for what I'm after
You are in a constant desync, so usual pattern is out the window
If i don't smooth anything, I still get those same results for my own player
just very slight corrections because of Physx
which again is as good as I need to get there
It's the other players movements where all the problems are
Blue Player = Local, Red Player = Remote
You can see how the puck leaves the stick way earlier than it actually happens
And that's will very heavy smoothing
(lerping all values with a .3f time value)
Part of the problem is definitely because of how unpredictable the stick movement is since the input is tied to mouse movement
And those values are the most dynamic input there is lol
You definitely have that working against you with extrapolation
Which is why Rocket League (and what I also implemented) uses input decay
RL uses heavy vehicles
That mouse value is decayed over time if no state updates come in
So I'm not fast forwarding with a consistent input value each tick
That value gets decayed slightly during state correction fast forwards
Just an area that needs to be fine tuned probably
Nonetheless, you are predicting very rapid changing inputs, it's going to be quite a bit harder
Yeah that's what I'm afraid of
I'm worried that the game design itself makes the networking challenge impossible
The mouse inputs aren't cosmetic, they are extremely critical to the sim
Current
But so is steering in RL with the analog stick
Which is where they applied the input decay
There will be answers, but you are going to have to write a lot of custom stuff
But a car can't 180 turn in a tick
So the error is pretty capped in RL
yeah that's what I was theorycrafting over last night
Still unsure why dashes in RL don't produce the same weird results tho
Extrapolation is more in the domain of trying to make this deterministic
Which does dislike this kind of input
i think I'm already extrapolating tho technically speaking right?
Since i'm using the player's last server input to fast forward?
If a player is holding W during a state correction frame, each tick during the fast forward I advance the simulation as if they continued to hold W
Quantum so far has avoid mouse input stuff for fps games. Can be done, but the predictions are hard to hide
That's what I mean, extrapolation is ugly
Lies, damn lies, and extrapolation
So I'm basically extrapolating, then interpolating the result from the extrapolation
yup
It's the free mouse that is borking you
same thing is the case with player movement with the analog stick
But the input decay and interpolation hides that extremely well
yup i understand
Unless you are taking the stick as raw 0-360... Then it's just a trackball in disguise
just not sure at all what do do/try next...
Lots of trial and error really
That's how RL was made
You are mostly edge case here, so you kind of have to try it all
Sounds like you get the concepts, so not much I can tell you that you don't already know, sorry
That's fine
Just the obvious stuff you are thinking of
For occasional desyncs I have strategies, but none for perpetual desync
Phone doesn't like big words
I appreciate the help though
I feel like this is only something I'll be able to get help with from someone who's dealt with this before
Like I legit might try reaching out to the lead engineer of RL....
I'm glad that I seem to already understand the concepts of what's going on and shit tho...
this is all new to me
Can always try asking
But it is something of a creative per game exercise when you wander into these mixed prediction schemes
because the answer really is just "is it hiding the desync in the least noticeable place"
and that is super subjective
Its literally relative
For my rts. I use 16.16 integers to describe the rotation
At a camera away from the object. It looks perfectly smooth
But if you got really, really close, you could notice a slight snappibg
Snapping*
Unless i turn on the rotational lerp
In which case you wouldnt notice at all
(The speed at which it lerps to the new position depends about the delta time from the newest and oldest position)
Its going to be highly game dependent yeah. The more the game tends to produce major disagreements between server and clients the more creative you will have to get. So its best to try to make the game itself not produce wild disagreements
I think CSSource networking is very relevant for this
Afterall in a competitive game like csgo where collisions means living from dieing or getting a kill or not. And even for monetized competition. Needs to be as accurate as possible
If you are wondering. The Source engine is on github
Thats how apex is a source game without being a valve game :p
Though from what I have heard about Apex, it does a lot of client authority since the servers would be overtaxed trying to do per shot rewind and such - not entirely sure if that is relevant at all to this though.
I think in Rob's case he is going more for a RL thing, which requires a very un-CS-like form or prediction since it relies heavily on extrapolation and resims rather than rare resyncs as you get with typical FPS games @jade wharf
Oh
He's basically doing RL type prediction, but with things that are harder to predict than vehicles... so he has some hurdles
In the case of a client/server authoritative with client side prediction, can you get away with just having the same movement code for both parties and updating the pose in case of desync or is there more to it ?
Because of latency you can't just move it on the player to agree with the server. You have to go back, apply the historical fix, then resimulating back to the current tick @solar garden
This is in case of desync only right ?
All players client or server move freely in their local world but only the server can correct mis behavior right ?
Because its the only way i can see client prediction working
Since you can't rely on sent data because of latency
there are a bunch of models, so kind of depends what you are after
How much the server can afford to rewind, how much you are willing to trust clients, etc
How deterministic things are
But yes, to your original question, you typically run the same movement code on server and owner
the only time they should disagree is
- Non-deterministic event that can't be predicted happens, usually another players action that blocks your action in some way
- Lost packets cause the server to have to guess your inputs
- Just slop in the simulation, like floating point error
- maybe something else I am forgetting
At the start of any project would work on getting the miss rates as low as possible, and getting things to when they do miss - that the error is negligible
The smaller the desyncs, the less exotic you have to get with your code to try and hide it from users
@solar garden you can rely on sent data though. Clients will be in the future on tick 120 while the server is only on tick 100, for example
that way by the time the input packet for tick 120 reaches the server, the server hasn't processed that tick yet and all players inputs for tick 120 can be processed at the same time.
The higher the latency, the farther into the future that client needs to be.
By having the server tell each client how many inputs it has in queue to process, i can move the clients further into the future or pull them back by processing 2 physics ticks at once or 0 ticks.
2 ticks moves it slightly further into the future, 0 ticks lets the client slow down.
once that logic gets the client at the right point of time, it should stay consistent as long as no packets are dropped or latency doesn't increase. So it's a constant adjustment being made when needed.
The cost is that there's slightly more latency introduced from the input queue on the server. Inputs are sitting for a moment until they are processed.
I believe the speed up/slow down technique is referred to as an Upstream Throttle and it's what Overwatch uses.
RL also uses it but it's an option you have to enable.
Ok i think i understand after some reading i saw that i have to number the packets sent for server reconciliation where redondant inputs are dropped and the one with the same number as the server is processed
I thought you were adding to our previous discussion. Didn't realize you were asking a question only related to your own situation. I'm sorry for the rant....
But yes all your inputs sent to the server should always have a tick number. And all game state updates sent from the server to the client should also have a tick number.
Quick question: I have a networkbehaviour on an object that exists in the scene from the start and isn't spawned in. Can this networkbehaviour utilize syncvars? And is there any way to know if the scirpt is current being ran on the server or client?
Right now, it seems isServer is always false and the syncvar doesn't actually change on the client
@autumn bone I'm stuck at a similar problem myself, I have one button in my scene and a script with network identity. I have two syncvar ints for player 1 and 2. The int decreases for the other player when I press the button, but the problem is the int doesn't change at all since syncvars can only be accessed by the server
I'm looking into commands now to give access to the client to access syncvars
Hi folks! is there any roadmap or discussion for unity to support http2 at all?
Bit of an odd question, but what is the best networking solution for a fairly physic heavy multiplayer game?
Hamachi migth do it if you want to @soft palm
Hi, guys! Does anyone know where to start when wanting to learn networking? π
First think what do you need the networking for, and how should it work in your game
Well, I just want to learn it in general. So I donβt really have one specific case I need it for @undone sigil
what api should i use for lan
netwoking
when i google lan networking Unet is all that comes up
what are some other popular options (lan only)
@weak plinth Definitely Mirror networking. They have a discord where you can ask whatever, and it's basically a remake of Unet, so all the old Unet tutorials apply to Mirror. I've used it plenty and it's well made and just works. You can connect with Hamachi and or something if you want to play with friends.
I haven't personally used Photon, but that's another well received option
@void burrow there is no general you wont find friendly tutorials to make every thing from a to z you are entering the wastland of gamemaking here, id suggest to learn to use either Bolt or PUN from photon they are the highest level solutions for networking to this day Unet is waiting to respawn for now so if you are interested in mid level networking there is Mirror that for now the best solution because it is made with a fixed version of Unet and can use loads of transport layers counting steamwork
I wasn't expecting an a to z tutorial for networking, what I was expecting though is at least some form of information on how to get started without a framework doing all the networking for you. Such as literally pulling every string out of your hands. @solar garden
And I get that for a lot of users that works perfectly fine, but you don't really learn how it works from doing so in my opinion and experience.
You dont want to not use a framework its like saying i want to make my game from scratch without any game engine but if you really do you will need to learn about sockets and threading
I understand you can't do everything your self, but the key concepts of networking aren't going to fall out of the sky when using a framework that does everything you want automatically. You probably won't learn how to do things like client side prediction, optimizing packets, server side control (such as anti-cheats, physics).
Ohh but dont worry none of those concepts are already made for you to use you have to make them yourself π
Then what's the point in using a framework π
The frameworks are transport layers the actual connecting is made for you but the game networking is all on you
Aah, like that.
Photon has most of those game networking "covered" for you but when you use Mirror with one of the networking layers all game logic has to be made by yourself you just chose the one that may get the closest of what you are aiming to do and get ready for months of water boarding π
If you want to go down that path google will be your main tool but if i can cut you some trouble look for Glenn Fiedler's articles and Valves networking wiki they cover the raw concepts
I did find Glenn Fiedler yeah, but haven't looked at Valve's networking wiki yet.
Try coder's block by joe best-rotheray too and look at gdc's talks too
Although Glenn apparently did take down his blogs π¦
Luckily we have archive.org but yeah
xD
Yeah i almost lost it when i saw that but yeah good thing peoples waybackmachined it lmao
But thanks a lot for the help, I'll take a look at Valve's wiki and coder's block by joe best-rotheray π
Anytime, may you find ease on your journey π
Thanks haha xD
I just found this repository, if anyone is interested, it contains a lot of talks & article's about networking. and even names some libraries / demo projects. π
https://github.com/MFatihMAR/Awesome-Game-Networking
Ahh nicely found i wanted to send you this originaly but i couldn't find it
This is the coolest bible i ever seen
Gabriel Gambetta is a good source too
I wish this kind of stuff was just pinned in the channel, that would have made things much easier haha
Np! π
Hey! I've got a question, if I wanted to make a simple dedicated server. So for example chat clients (which are Unity clients) and a standalone C# application (the dedicated server) which can talk to each other through the server. Could the approach making a C# project with the shared code such as packets work? So that both the server and client implement that project.
Or does anyone else have a better idea for doing this?
I'm a bit worried that this will eventually mess everything up as more complex things come along.
what are you guys using for networking these days ?
personally using Mirror
im using Photon
working pretty well so far
not sure how it compares to other services though
playing around with dots new Multiplayer
anyone knows how UnityWebRequest handle tcp connections, read/write streams and web requests? are they all threaded or some with coroutines?
Im using Forge its an odd ball this one but things make sense for me when i use it
plus idk how the others systems do it but forge has a dedicated thread for its networking, how does the others systems works
?
are they working on the same thread as unity ?
if you go out of memory playing in a ressources intensive scene and freeze do you lose the connection aswell ?
@weak plinth believe it's all coroutines
@steep wolf this guy from UnityTech says it uses another thread under the hood, i don't quite get his statement. https://forum.unity.com/threads/is-unitywebrequest-threaded-to-background.514360/#post-3369121
how do you find out what it is? it is all proprietary code right?
or look at the decompiled libraries if you're hardcore lol
not recommending this
neither condoning it
neither have experience with it
disclaimer haha
I suspect it starts a process that does the web grab, and all that is ienumberated is the regular "are you done yet?" check of that
Hey I was thinking of how could it be possible to create a unity online multiplayer game that won't be playable without a game client. I want to make a matchup search in a client with users and run the game made in unity through the client sending as arguments the user to the game and connect then together and at the end of the match terminate the game and send the results of each player back to the game client, any idea?
Does anyone here know of a reverse-proxy, load balancer, or what have you (service not software) that can point to any old ip I so desire and supports tcp/udp
that's very specific
Does anyone know where to find good Mirror networking tutorials?
I can't find any good ones.
Answered in Mirror Discord
Is there any way to make multiple spawnpoints in photon networking?
Hi
How can i use simple network system? Don wanna make s multiplayer game, just wanna use some network stuff in game... where do i learn it?
Dunno what to search in youtube, it only has tutors for multiplayer games
@neon rampart look for simple c# chat app & learn from its source, its easy
@neon rampart try this Lidgren Library, this commit should be groovy: https://github.com/lidgren/lidgren-network-gen3/tree/e26203f6526835779dcf7d2357e4ebab642e72e6
it already has a chat example thats pretty easy to implement in unity
TheOnesandedMan thanks, but thats not quite what i wanted, I wanted a tutorial, wanna learn
@gusty niche somethin like this?
https://play.google.com/store/apps/details?id=com.skyapper.hb.learncnet
@neon rampart that's just learning c# syntax, i didn't know you have no understanding of the language, but yeah start from there, it will take some time to learn c# then go to networking etc..
@gusty niche oh, no, i kno c# i just don kno EN well :-) thats why i didnt quite get what u said me to look for
@neon rampart take a look at this client code i made the other day https://file.io/pKTWm8
i dont have any server code, but you can make it yourself its not very hard
Hello. I've been using basic bi-directional socket functionality with WebSocketSharp. It came with this asset store: https://assetstore.unity.com/packages/tools/network/master-server-framework-71391 , which is now open source on GitHub. (not that it's hard to make Client and Server Sockets with WebSocketSharp, just posting in case it helps).
I've opened the ports and removed any security issues (firewall). I'm currently having problems with connecting from a remote PC to the server (locally it works perfectly). Funny thing is, sites to check if a port is open show the port as open.
The best I could narrow down to is this. There seems to be an issue based on Unity Versions. If I'm using Unity 2019 (any) as Server and Client, connection won't be established. If I'm using Unity 2017 as Server and 2019 as Client, it doesn't connect. If I'm using Unity 2019 as Server and 2017 as Client, it connects. If I'm using Unity 2017 as both Server and Client, it connects. Both 2019 an 2017 connect locally.
Any ideas would be extremely helpful, as this has suddenly hindered my development process by a lot!
@gusty niche thanks man :)
Hi. Can someone give me a rundown of Photon vs Azure PlayFab? I want to make a cards versus humanity style multiplayer and I'm trying to figure out if I should use both or just one and what the differences are between them
So I am making a project using UNet in unity 5.2.1 and every time I try to build to webgl i get - Error building Player: Exception: C:\ProgramFiles\Unity\5.2.1\Editor\Data\Tools/UnusedByteCodeStripper2/UnusedBytecodeStripper2.exe did not run properly!
I can build it in windows fine though.
I have also looked on the forums but I cant find a solution.
My player is changing armor mesh when he equips item from inventory, so for each armor part he has a different mesh, now when im in the room with other players and changing my armor they don't see that im changing meshes. Im using Photon Pun and i'm wondering which method would be the best to use here. Should i set RPC on method where i instantiate mesh and send that rpc to everyone, or is something else better?
Im usually using rpc for methods like "takedamage" and simillar, would it work the same in my case?
can I turn an already existing gameobject into a photon network gameobject?
@weak plinth using RPC functions is though in order to do that because you can only pass in very simple variables through it
what ill probably do is is make an array containing all the meshes for the armors, and an enum to number them all
and then just pass the enum number through the rpc function and use the enum to figure out what it corresponds to
not sure if that makes sense
i could try something like that
I can show you how I have it setup
Hey guys so I'm wondering about something, I'd like to one day get into game dev, for now just watching youtube videos about it.
So, let's say I make Unity game, some kind of multiplayer survival, players vs bots. And I want people to be able to make dedicated server.
But what about that bots. I need to simulate them somewhere. So what do I do?
I see it like that:
- So I launch the game on the server like normal player (but it's tweaked so there is no player and it acts like a server not client)
- So the game world on the server spawns
- I just simulate the behavior of AI
- Send the positions and actions of the AI to all players
Is that how (roughly) it's done in games? Or is there other way?
Because if there wasn't any AI bots I could just make simple console program that just receives and routes simple data about player positions and actions. But with them it's not possible. I'll be glad if you @tag me in answer.
@worldly plinth Networking packages like Mirror handle this just fine because the headless server is still a Unity app and can have all that functionality.
Hello. Does anyone know perhaps any deterministic multiplayer engines like Photon Quantum, but open source? I'm prototyping a brawler game and I need a solution that works for a wide range of latencies, but I can't afford Quantum at this stage.
There is nothing like Quantum for free
or even for charge
nor will there be likely - its a massive undertaking
Eventually some more paid deterministic libs will pop up I would expect, but making a generic just works system that doesn't decimate CPUs/memory while still being usable and bulletproof would be a lot of work for anyone to make and then give away for free.
The best you can do right now is get some free libraries for some of the aspects - like the deterministic physics or deterministic fixed point math
Hey,
I've got a bug where my network request times out because of an interruption (connection disabled / enabled and the IP might have changed too afterwards). What is the usual practice in this case, reusing the same HttpWebResponse but with a different servicepoint or flush the previous connection and establish a new one?
the download is interrupted (at green text), the stream is closed. Then after some time connection is restored, and I create a new instance and try to run my thread with new HttpWebRequest but I get
After closing the application and running anew everything works again. The first request is successful - I receive the response stream, but after a reconnect (even with the same network, I am testing with LAN at the moment on my PC) it keeps throwing timeout error. I think that I am not disposing something correctly, here is the code for disposal.
Debug.Log("Naturally Closed " + GetHashCode());
DownloadFile.Flush();
DownloadFile.Close();
DownloadFile.Dispose();
DownloadFile = null;
response.Close();
response.Dispose();
response = null;
_isbusy = false;
AsyncThread.Join();
I found and answer in stackoverflow that says the connection lease is by default set to 4 minutes and that seems to be the problem, but trying request.ServicePoint.ConnectionLeaseTimeout = 5000; returns a NotImplementedException -_-. Any help please?
... is the built-in or the in-alpha unity network stuff suitable for any use at all?
it appears that the alpha network stuff is mostly implemented in C#, which I suspect makes it a complete non-starter for absolutely anything
because i'm pretty sure that MTGA's network is implemented with it, and I can see that it's not suitable for anything, if it is
The new unity multiplayer system is hot garbo right now, unet+mirror is the best choice imo
Multiplayer still needs a loooottt of time in the oven
hey @remote sail thanks for the input. mirror?
basically, i'm working on a plan for a non-game application, that will need to have at least 2, maybe more, systems rendering potentially different views into a 3d world . . which is probably wanting to be served from a dedicated headless server.
seems like something like that should be pretty easy to implement if you have any kind of multiplayer anything... but my searches to figure out how unity multiplayer works, has really only come up with broken documentation, people complaining about how useless it is, and unity themselves deprecating it without having a replacement.
@crimson dune Mirror is fork of old UNET if I'm not wrong. I'm using the new Multiplayer for my long term project, you will need to get your hands a bit more dirty to use it, as it's not as user friendly as other things. There are also other 3D party stuff you can use like Photon and DarkRift2.
basically, what we want to do, is just have a 3d world, with a server keeping track of it, and replicating the things in that world to all the clients. the clients will just control a camera, which theoretically, the server should never even need to know exists. i think i'm just going to have to start an empty project and screw with some things, because studying for the problem seems fruitless.
@crimson dune What you describe is a first person "game". I know yours isn't a game, but it's mechanically the same. Jaws is correct that Mirror is a much improved replacement of UNet.
https://assetstore.unity.com/packages/tools/network/mirror-129321
certainly. nicely, that asset store page tells me more about it, and how to operate it, than i managed to learn yesterday about the entire topic.
i wonder if this suffers from being framerate bound, as i suspect is a thing that happens by being built in C#, and is absolutely a problem in the one multiplayer Unity game I'm aware of
@crimson dune Please stop by Mirror's Discord (linked from that Asset Store page [Chat]) to get all your technical questions answered π
Is there any way to test netcode without first building a copy?
This is abysmally slow
Do iterative testing in separate projects that isolate small bits of your game before merging them into the large final project.
Yup, what Gadget said. Do your networking code in its own smaller project if need to. You just want to work out your controller code and networking code without any of the design/level stuff that isn't critical to that.
When you structure your game code in your projects, do your main folders separate by server/client/mixed folders, or are you do split it on leaf, or doesn't mark it except maybe connection code? ^^ : )
Alright, another question re: developing netcode. I'm working on a VR application, so when I try to run two clients they compete for control of the HMD. Currently my approach is simply to disable VR while running multiple clients on the same machine, but this isn't a great solution as I might at some point need to test VR + netcode. Can anyone think of a way to do this without using multiple machines? I can do that if I have to but I'd rather not.
Has anyone here used DarkRift2 and Mirror? If so, could you tell me a little about your experience with the two?
@ripe axle I've used DarkRift 2 a bit. It's somewhat of a socker wrapper with some awareness of connection , and seralization. It's sort of in the middle of low level and high level code. You can create whatever you want very easy if you're familiar with writing network code, else you might want to look for something more high level : )
I've been playing with it for the past couple of hours and it immediately makes a lot more sense than Mirror/UNET. Guess that low level networking module at uni paid off!
You can choose of using the dakrift server or using your own by adding the server script in code. They have an active discord channel as well if you need help : )
If you want to do physics n' stuff on server I would recommend for simplicity doing unity server : ) Else you have to add that logic as plugins on darkrift server
silly networking question : to connect to the game i have to 1) open the ports to the server local ip, 2) host the game with said local ip and 3) connect with the public ip. Right ?
Hey I was thinking of how could it be possible to create a unity online multiplayer game that won't be playable without a game client. I want to make a matchup search in a client with users and run the game made in unity through the client sending as arguments the user to the game and connect then together and at the end of the match terminate the game and send the results of each player back to the game client, any idea?
@solar garden Yeah
@ripe axle just brainstorming, you could use VRidge with your smartphone as another headset and install the game on another PC (you don't need perfect perfomance, any old pc should do)
That'd be fine, but that means constantly updated the source on two machines - kinda long :s
I'm thinking of using Mirror for my current gameproject. I've used it in tests before and it works nicely. But my current project has a simulation running on another thread (it's a factory game, kinda like factorio).
Now I'm trying to figure out if mirror would work in this situation and how to implement this.
Is there a way to sync the state of the simulation (bare in mind it's running on another thread)?
Every gameobject that is using the simulation has a reference to it's simulated object. Is it a good idea to not sync the simulation and simply sync the gameobjects on clients (only the host knows about the simulation)?
So basically I want to know:
- Should I sync the simulation and calculate all gameobjects from that simulation?
- OR should only the host run the simulation and clients directly sync gameobjects?
Still wondering this^^ ; When you structure your game code in your projects, do your main folders separate by server/client/mixed folders, or are you do split it on leaf, or doesn't mark it except maybe connection code?
As you know I'm knew to multiplayer games... however with server/client architectures in general I prefer to keep them as entirely separate codebases. I'll get back to you next week on how well that works for a Unity project π
@solid veldt Depends really what you mean by your simulation
Good networking is all about isolating your Inputs/States out - ideally as numbered ticks
your sim should look like Inputs[x] -> State[x] = State[x+1]
if that is your case, you should be able to isolate your inputs into a ring buffer, and your states into ring buffers as well
which leads you to what you are after... which is..
Messaging <> Buffers <> Simulation
Messaging and Simulation should never touch one another, nor really even be aware nor care about one another
Messaging is used to replicate the inputs/states across machines, and populate the buffers.
Simulation pulls inputs and states from the buffers, to produce new states which go back into the buffer.
That just leaves dealing with missing data (late/lost packets) with extrapolation, and resolving desyncs.
You are having this convo in two places, so no need to respond both here and in Mirror btw
Gadget is going to give you a wildly different set of answers
But it really will come down to what your Simulation is
Well that would be true if I went full low/mid-level networking, but I want to use Mirror which afaik already handles all that stuff.
So to keep it simple a progressbar is a good example I think.
Let's say a building has some kind of progress in the simulation (e.g. at 50%).
Now the options are: I'll send over the whole state of the simulation and the progress bar that the client sees will be set according to the received simulation or the client doesn't care about the simulation and I just sync the progressbar as is
Well, more answers = more ideas π
It doesn't actually handle this particular thing. It can't be aware of your state/input arrangement. Mirror is mostly messaging layers, so when you start talking about your simulation sync - doing it correctly is going to require some more work from you, but for huge gains if done right.
otherwise, if you go with Mirror's RPCs/Syncvars - they create their own state system, which runs on an arbitrary timing. That might not be what you are after.... but again comes down to how good your sim is currently at abstracting itself into inputs and states.
You can stay within it if you use RPCs and send out like a byte[] of your serialized states
RPCs are just MessageBase with some restrictions
The process for getting your entire state into an RPC will look about the same as doing a NetworkClient/Server.Send() - so little difference there really
The messaging conduit you choose isn't important - what is important is that if you have a tick based sim, that you make your networking take advantage of that.
Whats the best way to flip the board for a multiplayer game? Rotating most things seems weird but it looks like its the best way to do it
Im trying to make a multiplayer fire emblem game
If that helps visualise what I am trying to achieve
Why not have a dummy obj at 0,0,0, and make the camera a child of that? @spiral glen
and rotate that dummy 180? Your lighting may be an issue, but that keeps everything static
Problem with that is the fact that I then have to rotate all the units
Is there a reason I need a dummy object instead of just rotating the camera?
Just easier, since the camera wants to rotate around the center of the world
ah, if the units all have to turn to face as well... not sure there is a basic simple answer.
I have a player with networkIdentity. The player has a child-gameobject with an attached Weapon-behaviour. The weapon has an int magazine. I want to sync that int in the Weapon-Behaviour. That's not really possible, is it?
Because I would have to make the Weapon-Behaviour a NetworkBehaviour in order to use [SyncVar]. But that network-behaviour requires a network-identity on the weapon. But the weapon can't have a network-identity because there can only be one per prefab
(Using Mirror)
cross-post - answered in Mirror's Discord.
To someone who knows little to none about multiplayer - What would you recommend? Where to start learning, Which APIs (like Mirror, Photon but without service and not p2p) to get, Which unity assets to get, etc?
is there anyone here who can help me for a few moments 1 on 1 regarding setting up a client/server relationship that can pass information to one andother?
Example: i have created a scene that has a "Server" game object with a custom "Server" script i wrote which creates empty game objects with blank string variables. I would like my "client" build to be able to connect to the "server" build and tell the server code to execute a command within th server C# script and pass it information. for a quick example ill say i was my client to send":
Server.GetComponent<Server>.AddInformation,("Hello", GoodBye");
so that the seerver running build would then create the blank game object with parameters "Hello" and GoodBye" passed ot the variables within.
note: my server code for the AddInformation function already contains 2 string paramters to add the information into it
Anyone have resources how to deal with like database flows in multiplayer games? Like if a player logs into a game, and joins a gameserver etc
what size game? what DB are you using, and what language is your server-side software?
size = playerbase here
I would recommend sqlite for a "project". On a professional level there is a package in package manager that allows the use of external services/processes on the clientside which could help with that bottleneck
"Subsystem-Registration"
@proud ice I'm more of looking into the theoretical right now. But for example lets say look at dungeon defenders. They have some lobby where you can run around do shopping etc, and actual game rooms. I would imagine that the lobby and gameplay room are different servers, would both need to lookup player information like items etc, or would that be transferred between servers? Also some simple stuff like, if server A is connected to client, and want it to connect to server B. How is this made? Do server A tell server B IP/clientID or generated ID?, and then tells the client to connect to server B IP with generated ID or something? π
Usually all the data is on the same server
@candid igloo How do you mean?
Hello friends,
I'm developing MMORPG with Unity.
I am writing Server with .Core.
I'm going to share a video of my play. Could you please watch the video and give me your opinion?
https://www.youtube.com/watch?v=_Brh7w-LjOg
ArtΔ±k EΔitim Γcretsiz !! KanalΔ±ma Abone Olarak Kendi Online Oyununu Yapabilirsin. WhatsApp gibi bir program yazabilirsin. C# Windows FormlarΔ± OluΕturabilirsi...
Hello! Anyone have any suggestions for analytics in Unity? Basically what I'm looking for is a paid solution with proper data security/privacy, in other words, the data isn't used by the service provider or sold to third parties
Hi guys, I'm wondering is there anyone know how to sync LocalAvatar for Multiplayer VR?
Im working on running project using Photon Classic and Oculus Integration. I've done following tuts here https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/oculusavatarsdk but it seems that for Photon v2
I've done something similar for HTC Vive before using VRTK and Photon classic and I was successful. but somehow for Oculus SDK I'm stucked
Maybe you have some similar experience ? any help / clue would be appreciated. Thanks !
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!
@stray scroll If you want to learn about game networking, learn about game networking. Avoid any high level api's like mirror and pun. Learn about the actual concepts of networking
I actually learned with Unet HLAPI, so I think you can - but you HAVE to dig into what it is doing and know what it is doing. Don't let the netlib be a black box or you will cripple yourself. Over time you likely will start to use less and less of those HLAPIs until you basically are ready to go right at the Transport yourself
The benefit of starting with a HLAPI is you can get right to having working connections and netobj ids... so you can get right into learning serialization. Then you can at some point create your own net objects and middle layer if you choose to.
The other option is start from the bottom up, just connecting and sending hello world.
@jade glacier o/
Heyo
Just finished our coffee and breakfast out on the ocean front patio here in sunny Mexico. π @graceful zephyr Things getting chilly up there in the great white north?
yeah negative degrees last night
Gack.
Marissa really wants to hit your region, maybe even for raising a kid... but we are traveling almost non-stop chasing summer - so I am a bit worried we may be so declimatized we may never be able to live north again.
ish
Connecticut USA
which is New England... so very cold winters, very hot summers
But that was ages ago
last decades have been like Oregon/Texas
Oregon you get rain in the winter, Texas you get no winter in the winter
we had around -20 to -30C coldest where i grew up during winters, -25C is -13F for reference
Christ
So i was born in the cold, molded by it... you merely adopted it π
the north remembers.
we saw negative F a few times in Connecticut... even as kids that was ouch
well yeah, your vehicles probably thanked you for not trying to start them at those temps
oh volvos and shit work in those degrees
the volvos sold up north in sweden are equipped with special... idk wtf it is, stuff
to make them work in those weathers
The engines must have some special alloy and ring choices maybe?
May be why they always had legendary longevity
Other countries can be sloppy with mats and tolerances
@jade glacier tons of stuff for those cold weathers
Fucking swedes
I am seeing more and more Swedish related news/industry stuff/etc lately. Sweden seems to be really popping up more lately on the world stage.
@graceful zephyr
@weak plinth I don't really understand your comment :p I never said anything about APIs? I asked if anyone have any resources of how databases are used with games, where player connection moves between servers.
Does unity have a build in a system for websockets? The only info I found was marked as obsolete. If not is there recommended alternative?
Mirror is the nearest replacement to abandoned UNet and supports WebGL and secure web sockets
https://assetstore.unity.com/packages/tools/network/mirror-129321
@native fossil
Thanks I will try it out 
Can someone help me with unity PHOTON weapon selection menu?
If the stored data amount is relatively small itβs just straight replication
The way it exactly works depends on the database engine
@stray scroll
When you scale up quite a lot you can look into a micro service architecture and data sharding
Question, how do people tend to go about peer to peer solutions? I've read about NAT punch through and relay servers. But do we always use one over the other, a mix of both? I can see why you might always want to use a relay server. At the cost of more networking usage, but oh well. I'm also curious how people get relay servers, I've found that Steam has them, but couldn't really find other companies selling those kind of services. I also couldn't figure out if Steam has some sort of limit, or that you always have to pay for that. So do people in general just use Steam or are there better options? Since as far as I understood Steam only allows you to use it with Steam based games, so what about other shops / platforms?
@void burrow In reality, P2P games are really really rare, cause of security issues, firewall issues, etc. People usually use a mix of both nat puch and relay. Relay servers are usually hosted by yourself, on a VPS or a dedicated server you have
And what about using something existing like Steam their network relay system?
Do people use that, or is it just one big mess?
A relay is a server, its just a dumb server. The main advantage is that if your game type doesn't actually need much/any server logic you can develop and deploy in the exact same environment in one shot. You do lose the ability for server authority, so if your game is like a competitive shooter, you will have to wrestle with that and likely want to have a game server. @void burrow
A Nat punch removes that server entirely, which has other good and bad side effects
In my case I'm interested in looking into co-op, so one of the players would be authoritive. In that case I can safely use a relay system right?
Depends what you want that host to be responsible for
relay adds a hop, so leaning on the Master too much will not be ideal, since its an extra trip for any Master authority stuff.
So for relay I tend to bias toward total player trust, and only use it for games where that is fine (friendly coop for example)
Master can act as an authority, but be aware that all comms to it from other players isother -> relay -> Master -> relay -> other
The benefit of a relay is when you aren't trying to make a master have too much authority, is players aren't tied to the Hosts connection quality, they all connect to a relay that is on a great internet connection, and if other players have icky connects, it won't degrade the entire game.
For PUN and I suspect other relay types, one of the players is always designated Master - so you can do some host-like authority stuff there - it just is best avoided
But still then there needs to be someone with authority over the others, otherwise you'll most likely get a lot of strange issue's.
What if 2 players pick up a weapon at the same time, who wins if both clients think they picked it up? And that are a lot of cases, from movement to picking up items, to shooting with a weapon. I don't think you can avoid a host.
Yeah, then you are face first into the limitations of not having a real server
you can make the host the auth, but be aware there is a latency cost there
and the Master will always win that race
For shooting, you definitely don't want to go down the road of rewind and shot verification on the Master
I made an networking asset that does that for both PUN and UNet, but I never recommended anyone make use of it in PUN
What you are describing sounds more like it wants to have a server
But then you've the problem that people need to set-up servers if they want to play with a couple of friends.
I am talking to Tobi about the prospect of adding Relay Owned Objects to PUN2, but that is little more than a discussion at this point.
yup, welcome to networking π
Sigh π
There is a price for every choice
You can make use of Master
just know what the cost is
In my eyes
Latency + the host which will win in every situation that has latency involved.
Which in a MP game is almost always lol
I would in your case make the weapon grabs master auth, but make the weapon shooting fully player auth
You were talking friendly here
You can come up with other methods, and there are such things as server plugins for PUN
so you can compile in a little packet adjuster that for example lets the server time stamp all messages going through it...
and you could have your players determine after the fact who grabbed first
however, you can maybe get away with an easier fix
When you grab, that grab message goes to all players, the grabber included
So you can try to sort out who got it first just from that, but you may need some cleanup code in case the two machines got those packets in a different order
spot sending those grab requests as reliable may ensure agreement on the order
I haven't messed with that, so can't confirm or deny how that would play out.
You can flag a message on an unreliable stream to be reliable with PUN2
Make the Master at the very least not just "get" the item when it grabs it.. make it wait for the relay message to come back
That gets everyone on nearly even footing for that race
I am making a component system right now for PUN2
and item grabs is on my todo list, so this is a good exercise.
So basically 2 choices.
Let's say I still want my co-op, but I don't want to exclude the possibility for a bit more competitive gameplay. I would have to go for a server on it's own.
But if I do exclude the possibility for it I could probably get away with a relay system and then have to live with some latency for authoritive systems.
Right?
https://cdn.discordapp.com/attachments/515987760281288711/624609723928412190/2019-09-20_09-11-56.mp4
This is PUN2
Connecting over a tethered 3g phone in Mexico to PUN2 relays in EU and back... so those two screens are two trips to EU and back.
The middle answer is don't let the master just have its way instantly. Make it send out its requests like everyone else... and then respond to those requests from everyone (itself included) as the come in from the relay
That makes everyone's grab latency the same... they all have to bounce their request through the relay
For weapon fire, I would just fully favor the shooter. Full player authority on weapon fire. You WILL not stop/deter cheaters in this environment. You are just not likely going to have them if its a small friendly game. Best to add other tools for that, like letting players vote kick.
Why can this never be simple π
because its networking. You are trying to make believe two people 100s of MS apart are int he same room.
The less you care about hiding the fact that they are across the world, the easier it gets
Though what I am suggesting is in fact pretty easy
That's something I understand, I've seen a lot of talks about the subject. And all are about hiding latency. π
Make the Master process its own events just like all others.
When you try to pick something up... send a message to the Master (even though it is the Master) and process that request the same way you process all players requesting a grab
It in fact, may be easier
hiding latency, and dealing with desync yeah.
If we totally exclude the possibility for competitive gameplay against other players yeah.
Hmmm
you will not make a really competitive game without hosting servers
But there's still a big difference between a shooter like CS:GO and playing with some friends against each other.
But in terms of networking not really of course.. You still want a authoritive server in that case.
My problem with trying to get a dedicated server up and running is that players would have to host and set it all up their selfs.
Which will not succeed for a lot of players. Since my guess would be that most people would want to host it on their own pc.
So that would require port forwarding. Which I don't think too much people do or know how to do.
Or simply don't want to spend the time in researching how to set it up.
And me hosting servers will probably not work for the main reason, that it costs too much money xd
You will actually magnify your problem if you Natpunch and player host, since in that case there is no relay you can bounce the hosts inputs off of.
Natpunch is really just about cost avoidance
it is the worst of all worlds for competitive play, because you REALLY end up giving the player hosting a massive advantage that is hard to hide.
I really see your best bet being to bounce the masters requests to itself through the relay like all other players.
That at least gets everyone on even footing
You could also fake the latency of course, instead of bouncing it to the relay. Less networking for the host π
faking latency on a host is a huge headache, but if you want to avoid the relay costs, that is possible.
Keep in mind natpunch can fail, and you need a natpunch server
Which again, lots of choices, just know the price you pay for each, either in time, player experience, or actual cash.
One question though, imagine using the relay system. Would Steam be an option for this, or should I really go for something hosted by for example Photon?
I haven't touched the steam stuff so I can't actually comment sorry
Alright, still thanks a LOT for the help! β€
I'll be looking at the options, and see which fits best π
https://partner.steamgames.com/doc/features/multiplayer/steamdatagramrelay
I assume you are referring to this for the relay?
Haven't touched it, but the concepts are likely similar. It isn't a HLAPI though, so you would likely need to work out that layer for things like object ids and such.
I doubt they have the equivalent of PhotonView or NetworkIdentity
Steam? That's literally sending a byte[] to other players.
Maybe that someone has created something for it in the mean time.
But last time I took a look at it, that was all.
all networking pretty much is just that anyway
Oh well π€·
https://assetstore.unity.com/packages/tools/network/simple-network-sync-134256 For my lib I bypass of of PUN/Unet serialization and am actually just sending a byte[] every tick. Its what all of the HLAPIs are doing, they just hide it.
I'm still wondering how people use physics server side, the main issue I just can't seem to figure out or find a proper explanation for.
I sort of understand a concept for it, you buffer input from all players and then you apply that in a next tick. But how to exactly do so. No idea xd
And applying other forces / objects to it, and all of that in a playable map of course. π
Still all seems like black magic to me x)
Basically how you want to think about it is Simulation
Physics is just one kind of simulation, your own code each tick that produces states is simulation
the kind of games you are talking about use the formula Inputs[x] -> State[x] = State[x+1]
what you are networking is the inputs and or the states that system produces.
That really is networking... not the messaging
Messaging <-> Buffers <-> Simulation
Messaging and Simulation should never directly touch
Buffers = Inputs and States
I was talking about the simulation part π
So simulating physics based on the buffers.
That's the part I just can't figure out how to do.
The buffers are just inputs and states as @jade glacier stated above. If you f.ex. have a multiplayer game where you race with other wehicles (clients), and you increase the speed, then you will first let the server know about this (input[x] -> serverState[x]), and the server will in return apply this action to your game instance and the other clients as well to let them know you did so (serverState[x] -> all other clientsState[x]), so everything is the same for all clients. The physics gets done locally on the relevant game instance, thats all the "magic" there is to it. This kinda network distribution isnt very effective on fast-paced games, as it can become very laggy, so in those cases you would like to use techniques such as client prediction and server reconciliation and other techniques to cope with that. This is a pretty good article about those techniques: https://www.gabrielgambetta.com/client-server-game-architecture.html
But @burnt axle imagine having a client say they just clipped into the floor. How does the server simulate that and sees that itβs not possible what the client just did if all physics are client side? Iβll be reading your post btw π
Well, if the client just clipped the floor after getting commanded by the server to do something, then that glitch is on the clients physics engine. In order for the server to detect that, it would match the states, if they are different then it either means the player glitched or cheated. Thats not my post btw.
And exactly that is my issue, I just don't know how I can simulate that moment and correct it. Or in general simulate how a player moves through the world π¦
Well, i dont know how to produce glitches within Unity, and i hope its hard lol. If it does happen however, you could just clarify it as cheating. If you are new in Unity, there are plenty of Unity learning resources to get you going: https://learn.unity.com/
There aren't really any up to date networking solutions from Unity it self, so I doubt they have a solution for this.
But I think I'm explaining my problem in the wrong way, since I'm not talking about a glitch in Unity it self. I'll draw something hold on π
The upside is if you build your simulation out and separate it from the messaging layer... you code will adapt a LOT easier down the line as things evolve.
This would cause the server state to unmatch the client state, and you could look at it as "cheating", when technically its an impossible action. When you make the multiplayer game, its up to you how to handle this stuff, but i guess starting with letting the player move in valid directions is a good start π
When you make the multiplayer game, its up to you how to handle this stuff
And that's the part where it goes wrong for me, I just don't know how to handle this and was hoping someone in here had some kind of example or anything at all which could get me started on doing so.
Something a little more than just the concept on how to do all this networking stuff.
if the server and client come up with different sim results, that is a desync, and that is part of your networking how to resolve that... the most common and most solid is "resim"
that is the client that disagrees takes the incoming server state, rewinds to where they disagreed... applies that state... and then resimulates all of the inputs and ticks that followed back to current
that has the highest chance of getting back into determinstic sync
Once the thing causing disagreement clears, they should be happily back in agreement
But @jade glacier how do I create the simulation in the first place? I get the concept of it, but I just can't figure out a way how to exactly simulate it inside code.
You should only let the players do legal movements. In order to avoid mismatch between server and client states, in such scenario, you could check if there is a valid distance between the floor and the player BEFORE you move send the input to the server. Or you could go with @jade glacier's solution, which is better since it covers more scenarios.
Desyncs typically are a result of the timeframe difference
or, they can be from just flaws in the physics engine that prevent determinism
or, they can be due to lost packets and the server having to guess inputs and getting it wrong
Players walking into one another if they can block one another is a common cause of desync, and why in most games where players can block one another things get squirrely when you bump into other players
@burnt axle yeah, I would always go for keeping the inputs legal - though that should be happening anyway since you are passing player inputs.
But things can still desync even with that agreeing, because of either the timeframe difference (the player lives in the future locally) for non-deterministic... or because of a bad input extrapolation guess for determinism.
But how do I go about creating the simulation part on the host/server in code? Because I can't find any examples, barely anyone makes posts about networking in general. Let alone me finding how to create a simulation system.
basically look at physx
Create a project in Unity, then do some illegal inputs, then log the server states.
FixedUpdate = PreSimulation where you apply inputs to the State (physx) and it produces internally a new State.
You need a way to store/serialize your states after the simulation, be it PhysX or your own code.
I cant use isServer method of NetworkBehaviour in my script, any idea on why this is?
Unet
You might be checking it before OnStartServer has happened?
I usually just use NetworkServer.active in most cases
That did it, i like that intellisense suggests methods which only are available after an event. Does even NetworkServer.active and NetworkBehaviour.isServer indicates the objects that its called from is the server/host? Cause thats what i want.
@jade glacier Imagine I've the peer to peer solution with 1 host again, thus the host is running the networking code inside Unity. Unity has PhysX abstracted behind all kind of stuff. You can't simulate states etc. from within Unity as far as I'm aware. You could literally add them as game objects, but I don't think that's something you want as it then would be updated at Unity it's 'tick rate' instead of your own and probably costing a lot more CPU power. And it sounds like a real bad idea to include PhysX as a separate dependency in Unity. How am I suppose to simulate it then?
You can mostly get States out of PhysX
its just the rb. values
rb.position, rb.velocity, rb.rotation etc
I actually made a PhysX server auth with player input sync test with 2018's physics update
and it worked very well. Some missed syncs, but mostly rare so not a lot of resimming
Is it open source?
Nope, its my personal lib and taped together with rubber bands and duct tape just to complete the test.
But how are you syncing the objects if you're just using plain rigidbodies?
Just sending out the data every physics step?
And predicting it on the client?
Players each own like 10 of those balls
and simulate them locally, and any disagreements from the server sim show up as a red widget on them for a tick
For the samples with player input, yeah - I sample that every fixed and send that to the server
This one isn't applying player inputs, it was just a test of resim
But I have tests with player inputs as well correcting
The inputs are applied locally to objects the player owns, and applied on the server based on all of the players inputs it collected for those frames
Then it sends out the resulting complete state (all of the balls results) to everyone
each player checks their owned objects history against that, and determines if any balls need a resim
@mellow beacon Thanks, I'll check them out tomorrow π
Hi I'm looking for Programmers but MAINLY Designers for a small game development company i'm making. We're just making those 2d simple addicting games you would find on the app store and we just need programmers, but mainly designers to join the team! The money situation is based on percentage based revenue split. Please private message me if you're interested!
@jade glacier How are you resimulating the physics to catch up to the present frame?
Second physics scene has lightweight clones of net objects
Those get rewound on the client side to what the server state was, then previous inputs are reapplied and Physics. Simulate () is run for each tick back to current. Results are copied to the primary scene..
@fading pawn
any idea if any of the new physics options in Unity support individual rigidbody simulation rather than multiscene hacks?
since there's like 5 options now
If it's one Rb, you can just resim that in the other scene. Though you may want other objects to be part of that sim. Depends on your game. Not aware of a per request resim option without a scene, but haven't looked that close.
yeah that's what my sample does, but Unity has new physics options I haven't looked into https://blogs.unity3d.com/2019/03/19/announcing-unity-and-havok-physics-for-dots/
Hey friends, so I'm making a networking application with physics objects. I would like server authority over the physics to keep everything in check, and I have that 'working'. However, it's also important that clients be able to manipulate these objects, so my question from a high-level perspective is how should I go about this? Do I give clients temporary authority over the particular objects they're manipulating? Is there another way to go about it? Gimme a ping if you have any insight, cheers :)
@graceful zephyr thanks, I am aware of client-side prediction. However that doesn't really answer my question as to whether I should be switching authority for objects at runtime.
Yes it does
Prediction implies there's no authority
Because if you have authority, you don't predict
Well, assuming you have a server and all that.
It should push the object on the server, predict on the client side(so everything is smooth) but still do everything on the server.
I'm making a multiplayer game. Only my host, not the clients, can see networked objects.
The networked objects have a Network Identity component and are registered in the Network Manager. They don't have "Server Only" or "Local Player Authority" ticked.
Why can't my clients see the networked objects?
It is
Now suddenly it isn't working anymore
Well I do, my player prefab is local
You have a local player object spawned on all of your clients?
Yes
Then you need to go to the mirror discord for help
It's just the environment that is missing. All NPCs, trees, food to pickup
because what you are describing is what happens when you don't have a local player object
Hm, even considering the following?
I just tried running it with two build clients (no client in the Unity Editor).
Both host and client can see the objects here
What you are describing sounds like a very common problem with Mirror, which is if you have no local player object spawned yet, all net objects will remain inactive.
You have a player on the client that you are moving around, and it appears on the host moving around?
And are you in the Mirror discord? They can walk you through that.
Yes, I have a player on both clients, and they can see each other moving around
I am in the Mirror discord π
Sounds like you need MrGadget then. If you have local players, then it is something different I am not aware of.
Well, thank you for looking at it π
np, gl
What is the easiest way to message a server from a client? Alot of the message methods in the Unity docs are obsolete
I assume UNet from the context of your question?
[Command] is the "easiest", but also the most restrictive. It has to be on your player object to work.
The alternative is to register your own handlers and either send a MessageBase derived message, or send a writer directly.
Yeah Unet. I totally forgot about Command lol. But since it wont work with non-player-objects i need to do the alternate. How would i go about doing the handler way? I guess its also the best way to create a static class, that can handle all this stuff, so i dont rewrite all the code in every object that needs to do it
@burnt axle Mirror is the replacement for UNet https://assetstore.unity.com/packages/tools/network/mirror-129321
Cmd's can be invoked on the player object or any networked scene object that the client has authority over.
Beyond that, scene objects maybe don't need to talk to the server much, since the server should already know what's going on around a networked object. Player scripts can also call a Cmd that takes a GameObject as a parameter, as long as it's a networked object in the scene, and do GetComponent<> on that object inside the Cmd to invoke methods, set prop values, etc. so you can leave the code on the objects and just call those methods from inside a Cmd.
I just want to debug the remote player with simple logging, and using the Cmd works fine for that since it runs server side. The networked gameobject parameter sounds neat
I believe in UNet command is localPlayer object only (based on their own docs). Can't speak to Mirror or if they changed that restriction. @burnt axle
Yeah, i forgot to remove a Cmd method from a networked gameobject which no local players has authority over, and it gave a warning saying "Trying to send command for object without authority", so i guess thats right!
What may be wrong in the docs is that you may only need authority, as Gadget suggested. Their docs say otherwise though.
Unet explicitly says command only works on YOUR player object.
Mirror may also have changed that restriction.
I think it only works on the local player and the objects it has authority over. I havent read the docs for the command so im not sure.
That is what is in question... secondary authority objects
UNet/Mirror you have localPlayer, and that is a very different thing from authority
Command I believe USED to (and may still) only care about the object being the local player object (every connection can only have one of those - a bad design choice, but they made that bed - now everyone lives in it)
I would have to trial and error it to know the correct answer - but sounds like you are doing that right now.
Yeah, i just tested with a object that a local player (client, not server) has authority over and it worked
But have you tried it with a non-player object? That that connection has authority over?
Regardless, the primary use is that... the player object... with authority. Not sure what other variations do and don't work.
Yes, it didnt work as it gave me an warning.
You now officially know more about it than MrGadget or myself π
Hi do you guys got / know any resources about Gamer Servers - Architecture,Client - server archritecture and stuff like this. I'd like to know more about that topic.
gafferongames.com used to be the place to go
https://web.archive.org/web/20181130233124/https://www.gafferongames.com/
No idea how messed up web archives for it will be... graphics and animations were kind of important.
I am not sure if this is the right place to ask, but I was wondering where to begin learning about networking in unity. I have nothing extravagant planned, just a coop game with three players so preferably peer to peer since that would mean no servers to maintain(?).
PUN2 is typically the go to for starting with serverless
Thanks! Would it otherwise be hard to turn some old computers into servers?
Make a few demo games with some of the various libraries first
Before you even start trying to think about deployment
by demo, I mean garbage... because first net game attempts will be dumpster fires. Don't make anything you care about for those.
And you really don't want to host on some old servers... deployment is a whole study in its own. Make some stuff so you get familiar with the landscape before trying to guess any of this.
Ok, but is it even realistic to hope that I would be able to create a multiplayer game with no upkeep costs?
I do not want to get my hopes up since this is just a hobby of mine
if you have users, you will have costs
for very small scale, you might get away with hosting on your home connection
But that is pretty much a failed business model right out of the gate
If its just for a hobby and you expect no real users, sure - you can deploy at home
Okay nice so basically if I have no users I can just deploy it at home for me and my friends and if I actually make something good I will hopefully have some small amount of revenue to cover the upkeep costs, nice
Thanks for the advice, will check out PUN2
PUN2 doesn't require you to host
Forge, Mirror, UNet you can host
you need to make that choice based on your game type
Ok. One more question though, what do you mean by "various libraries"? As I said I am merely a hobbyist.
Forge, UNet, PUN2, Mirror, Bolt, MLAPI are HLAPIs
Then there are the transports, that do nothing for you but set up connections, which I am guessing will be too low level for you.
I have not set my mind to anything yet so I'll see
And you will not make any money with small scale networking games
Got to go now though, but thank you so much for the advice!
who's there
Hi everyone! Is there anyone here who could help me solving why most of the scenes and assets disappear from the editor after testing the unet network hosting and then stopping the hosting? I am using multiple scenes and everything disappears except the lobby scene when I stop the hosting. There are no functionalities in the game yet, these are just the "Lan host" / "Stop" buttons. If it helps, when I make a build and start it, nothing appears in the game.
Update: solved. Looks like everything will be destroyed, except the lobby scene, therefore I created a small script that only calls the DontDestroyOnLoad(this.gameObject); in the Start method and I added this script to all "Common" folders I wanted to keep, so now it works properly with multi scenes, too.
@jade glacier You said to use a ringbuffer for storing of inputs right? You know of a good rb implementation?
Hello! I just got started with the new unity transport layer
My code is this:
And I get the following errors
I followed this guide for the code
What could be wrong? I've been trying for hours and can't figure out, please help β€
So I sort of got it working
Took some time but it seems to work
Only two warnings left
The code works. However the warnings are kinda scaring me off lol
I'll try to fix them, if anyone here knows how to fix them, please message me β€
@weak plinth Fholms does look quite nice
https://github.com/fholm/UnsafeCollections/blob/master/UnsafeCollections/Assets/UnsafeCollections/Collections/UnsafeRingBuffer.cs
@gray pond @dusky storm
https://github.com/vis2k/Mirror/blob/master/Assets/Mirror/Runtime/MessagePacker.cs
Does the current store version of Mirror still allocate? I thought those ToArray() calls were all removed? But with the current store version it is calling them every sendtoall call. It leads to a MemoryStream.ToArray() call which allocates a new byte[] every time unless I am mistaken.
Are you sure you don't want MemoryStream.GetBuffer() there instead of MemoryStream.ToArray() ? Or that your Pack<T> wants to be using ToArraySegment()?
And the fuck is this? This is a primary conduit (one I need right now to get around your garbage generation)... why is it internal?
We've a couple PR's in the works for allocation-free messages...stay tuned.
I thought this stuff was all finished months ago?
Maybe you want public virtual bool TransportSend(int channelId, byte[] bytes)?
If you override public virtual bool Send<T> you can call TransportSend directly from your override
nope, you have no spec in your transports is the core issue I think Vis and Paul are dealing with
the transport base needs a send(byte[], bytecount) and or a send(arraysegment<byte>)
without those, they need a presized byte... which means an allocation
All of the transports need to be able to accept byte[] and length, or arraysegment - or else this problem isn't going anywhere
Also looks like the whole send process queues the byte[] data, which is going to complicate reuse of any buffers.
So yeah, not an easy fix the way things are currently wired.
@gray pond I can't override Send<T> in an asset, and it wouldn't matter anyway. TransportSend() is exactly what Send() calls.
So for some reason Send(byte[]) with all of its checks and warning messages is NOT safe for users to use and is hidden, but TransportSend(byte[]) which has none of those IS public? That seems a bit backwards.
Not that it matters, neither of them currently are conducive to nonalloc sends.... so its all moot at this point.
// for when we want to dequeue and remove all of them at once without
// locking every single TryDequeue.
public bool TryDequeueAll(out T[] result)
{
lock(queue)
{
result = queue.ToArray();
queue.Clear();
return result.Length > 0;
}
}```
The whole system is storing the byte[]s sent to the transport for some deferred writing, so Vis has some work ahead of him it looks like @gray pond
I can see why this knot is taking so long to untangle.
So if you make an online game and publish it on steam do you need a server of your own? Or steam handles?
That not what steam does
Whether you need servers or not it is up to you and what kind of game you are making
Steam provides a subsystem to manage your server fleet and handle credentials and extra features
Anyone have any suggestions how to store credentials locally for relogin? (or if this is done in some other manner?) What I've done so far is to create a loginServer which gets sent username and password, hash the password with salt and checks vs database.
You can create a session token and store that locally @stray scroll
So each time the player send data to server it includes the token in the header of the request
How does that work in practice? Random int from server, stored in database along with userID, sent back to client. Then next time client sends token and username instead of password? Isn't that just short term? Else somone can just grab the token as well π
No no
I mean when the user is authenticated
Server creates a unique token
That the client holds
And on every other request it uses the token in the header of the request
Ok, so it's just a session token
So the server do not need to hold a session anymore but process requests based on the private + public token
Basically a salt in the protocol
Yes and no
You can look into oauth
Which provides standardized strategies
Pretty commonly used on web projects
Ok, will check it out. But my question was more aligned in, if the player wants to log in a second time (not same session), and not type in credentials. Is this covered as well? : ) Will check out anyways.
Logging in another device at the same time you mean ?
No same device. Just another time, but don't want to type username, password.
Thatβs exactly that
Hey
I've got a question (actually a large plea, after checking out the amount of text I wrote) regarding networking: I'm taking over as the programmer in a 2-man team for a MOBA-like game. It initially started development in early 2018 and had implemented a networking approach using a combination of Unity's HLAPI and LLAPI (I believe at least? Not too versed in either networking or Unity networking). Taking over and noticing the deprecation of UNet we decided it'd be best to update our project's version to leverage new Unity features and possibly recreate our networking side of things. I'm currently investigating the options available.
I've not done more than a few days of research into the topic but I have come across 2 possible solutions via deprecation FAQ and personal experience, those being Unity's (new) LL multiplayer solution found on GitHub and the Photon Multiplayer Engine (and affiliated products and services) by Exit Games.
Could you help me decide which one I should go for?
Currently Unity's solution seems promising as it allows me to possibly leverage, well, obviously Unity integration with things like Jobs (and very possibly but unlikely ECS in the future), along with documention, and I've researched their GitHub repo for it a bit.
Photon is something I've only heard of but never used myself and I'm just starting to look into it.
I'm also open to other available solutions. I've toyed a tiny bit with the idea my own handmade networking solution but that seems a bit overkill unless I dedicate a few months into it (which is possible but not desirable).
TL;DR; New programmer on project developed using UNet. Read about deprecation (the networking code already present isn't great anyway), decided to replace networking with either new Unity LL networking or Photon or something else entirely. Any advice?
@mellow beacon most examples I see are services wanting privileges on another service on clients behalf. :/ the other info I find is kind of trivial, just saying - have expiration, use secure protocol when sending, and store safely (?).
What I don't understand is how do I store it safely? And is the only benefit from using a token instead of the password itself that it has a set expiration and can't be used for other applications?
@nocturne sierra There are plenty of people asking where to go with your networking solution in this channel.
I should explore the history here then
If you're not going to use Entities, I'd advice against using the new Multiplayer
Unitys diagram of how you should do x)
https://blogs.unity3d.com/2019/06/13/navigating-unitys-multiplayer-netcode-transition/
You can use mirror (built form UNET) https://assetstore.unity.com/packages/tools/network/mirror-129321, if you want to stick to similar code I guess.
Or you can use Photon, which I find very simple to use. But I think you need to use their cloud services(?).
I guess those two are the most popular options of what I've seen so far.
@nocturne sierra
Alright, thanks for your guidance, @stray scroll
@mellow beacon Yeah, so what I think I'll do is generate a token with an expiration date, which is only usable with sent MAC adress of computer.
I guess this is relevant here as well https://www.youtube.com/watch?v=P_-FoJuaYOI
Dive deep into the networked future of Unity using DOTS. Hear how we made the DOTS Sample a networked game, and what we learned on the way. Speaker: Tim Joha...
Another question. How do you limit the player to only have one session active? Lets say my login server sends the user to lobby/hangout server, which might send the client to a game server. The only thing I can think of right now is to have a sessionDatabase, where the PlayerID is stored with serverID/(IP?PORT?), so on a login, I lookup if there is an entry and send a disconnect message to the server that might have a duplicate player?
@stray scroll Which networking package are you using?
what do you mean networking package? I'm using Multiplayer if that's what you're asking : )
Unity's new thing? ok
There's a couple ways to tackle this but either way they involved the game server and lobby server having a link back to the login server or a common database they all have access to.
Shared DB: Login sets a flag when logged in, checks it against subsequent successful logins, and lobby and game both can clear it on disconnect.
Heartbeat: Login keeps an in-memory list of who's on and Lobby and Game servers call back to Login on Disconnect. Might want the Login to ping the others periodically to verify they still have the logged in user if there's some possibility either Lobby or Game can crash or otherwise fail to reset the flag or make the callback.
SharedDB Doesn't seem to disconnect user on second login, but will prompt that a user is already logged in.
Heartbeat seems to be the thing I'm looking for here : )
If it can prompt the client that the account is already in use it can send a disconnect
Not if the connection is not between it and the client, but another server and client?
I mean, it is two connections going on here, one is clientA, and another clientB , both trying to use same account.
No opposite, kick out A because B is connecting.
Really? Why?
That's how I normally see its done? π Guess more foolproof as well.
And when a customer gets their creds hacked or guessed, he gets randomly kicked and doesn't know why?
He would probably know why when it prompts that somone else logged in. And he can interrupt what the other guy is doing as well by logging in? Not that this is using credits π
creds = credentials
If the 2nd is legit, the player knows he's already in, and the 2nd just should be told, "Account already in use" and kicked. If the 2nd is not legit, the 1st isn't bothered, and if the 2nd is from a different network than the 1st, admin should probably be alerted.
Blizzard logs you out if someone else is using the account, same with music players like spotify, deezer. (at least gives the one that clicked played last to get music)
Blizzard logs you out if someone else is using the account
That's what I'm describing
eww
I think overall it's better user experience if something unpredicted happens to a server that causes the client to look like he's logged in, so he can't get in.
To each their own...wouldn't be my choice π
That last bit is what the heartbeat is for: to unblock the account if it's gone dead without notifying the login server
maybe that ping is only fired if a 2nd login occurs, but if you're going to just kick the 1st in favor of the 2nd, then you're assuming the 1st is always a dead client.
+1 to logging out old user, much better imo
too many times i've not been able to log in because i had to wait some absurdly long time for the old connection in some game to log out
or even worse, you disconnect and try to reconnect "cant log in, user already logged in" on the same machine
I hear ya, but that's a solvable problem on the server side to get dead clients out of the system expeditiously. Killing the old with the new is a work around.
in what situation would you not want to log out the old user? what benefit do you gain from denying a log in?
in the blizzard situation, you're logged out and it displays a warning "if you dont understand why you were logged out, your account is probably compromised" - which is true, if you didn't intend to be logged out you need to know your account has been compromised
but if you did intend, it's great. i can be playing wow on my desktop, then gf calls me into another room so i pickup my laptop and just log in there. don't need to get up again to go log out first at the old machine
@stray scroll you can go that way
Hi - I'm having an issue connecting using my external IP. I have correctly portforwarded and when using https://canyouseeme.org it says success when I have a Terraria server open on the port I use. However, when using Unity (LiteNetLib), this port refuses to open and canyouseeme times out. (All other servers being closed).
It works fine when using 127.0.0.1 or my local IP address
Solved; combination of two things:
- Open port checkers use TCP to check, LiteNetLib is UDP
- The editor most likely blocks external connections; it works when using a server build outside of it
Follow up question:
How do you usually test networking related elements? Do I have to build every time so I can open multiple clients?
I'm using LiteNetLib4Mirror and I'm getting this error when I try to use uPnP to start my server
uPnP failed. Error 718: Conflict in mapping entry
How do I fix this?
Hello, i have a problem using PUN 2 : joining random room suddenly stopped matching existing rooms; i have created rooms but joining room gives the error: no match found
Maybe related, but the editor often finds a different region
so best during testing in settings to hard code eu or us for region @ripe maple
That may not be your issue, but it comes up super often
and how could i do that please @jade glacier ? ( bc i tried PhotonNetwork.ConnectToRegion("eu");) but it looks llike it doesnt works
OMG !!!!
i added eu to the photon servers setting and it worked !!
i love you so much thanks a lot
np
@weak plinth probably best to ask in the litenetlib channel in our mirror discord. Petris can help, he developed LiteNetLib4Mirror
@dusky storm I did, nobody answered tho
Asking this on behalf of someone else, anyone have an idea of what this guy in this thread is talking about? https://answers.unity.com/questions/190028/multiplayer-jitter-caused-by-camera.html "set the networking to a low speed (1 hz)" ?
Not going to read it, but most likely is because of mixing Fixed and Update based timings
There are about 20 places you can create jitter when networking and dealing with Unity timings.
@manic solstice
@jade glacier Thats what I initially thought as well, though this one instance is odd in that the jitter can happen on the server's actor simply by switching the server camera and making it follow the clients actor.
3rd person camera has two points and they have to agree on timing segments
If you eyecam the player object that seems smooth? Or hard parent the cam to the player? Still smooth?
Without seeing the code I can't even guess where its getting boned up... but jitter is a timing disgreement
yea what ever object the camera is on is smooth, it's the other actor it jitters.
What is moving the cam itself?
This happens in the base RCC Unet project
All of the sample projects fuck it up
Mirror and UNet have no concepts of proper tick/timing handling
So people just take wild guesses, and are always disappointed
If its tracking a rigidbody, that rigidbody will either be autointerpolating, or they should be translating the kinematic rb in update
Which if the camera attached is smooth, that sounds like it is happening
What is moving the cam itself?
Really though, without some code to peak at... this will end up being 100 questions.
Sorry just took a quick look at the code (it's not my project) it's using the Realistic Car Controller camera, which seems to be updated in late update and it's tracking the transform of the target and doing a look at lerp on the rigidbody it's attached to.