#archived-networking
1 messages · Page 95 of 1
Google is your friend
But this is saying make an external forms app
I was asking if I can read input from within the headless build
It says many other things too
Read the thread...
ah right. The entire forum didn't load up the first time
Thanks for your help
@weak plinth so does this mean I need to run --batchmode instead of a server build?
Server build alone is all you need. Yes it's a normal console app, yes you can do command input and colors
ok thanks
yeah thanks I was making a logger class and this has helped alot
How to sync LineRenderer.Positions with clients?
Seems like ClientRPC is the intended way
During client reconciliation, when it's re-simulating, do I need to reset other gameobjects to the positions that they were at during that specific tick?
or just reset the player's position and then replay his movements
I'm doing all of my resimulations in an a different additive scene, so I'm not even sure if I'm doint it right in the first place
Maybe something like this
@slow monolith are you going to predict local player only? or all players?
I'm just predicting the main player's movement and the movement when he's in a car
nothing else is predicted
the reason you change scenes and stuff is because you dont want to disturb other players rigidbodies?
correct
except it doesn't change scenes
it just calls physics simulate in the other scene
then gets the position after it's ready
that all happens in a single frame on the main scene
if you are not predicting other players then why do you want to have rigidbodies on them?
cars need to move with physics.simulate
when the client receives the snapshot
so the player's rigidbody car knows that it got hit
instead of just lerping the transform
you should do that for the car local player is driving
ah
its for proper hit predictions?
not really predicting a hit
it's just so the main player knows that he just got hit and can react
so you don't have to rely on reconciliation to tell you that your car is now flipped over
because it got t-boned by another car
it looks like so
but unity physics will make it difficult for you
it looks like when a collision happens, outcome is determined by the physx internal states
which you cant send back and forward
well if the client receives a snapshot that says "somecar[i].velocity = xyz" and then that velocity change causes a rigidbody car to smash into the player's current predicted car
that would be close enough, right?
yes but that car is in collision with the ground
so it holds some internal states
and you are not recieving that info
then reconciliation should be able to clean that up, right?
if you try to revert the car to a previous state, by changing pos/velocity etc, internal state will probably remain as its past state before reconciliation
so it will be slightly different
and these small differences make collision trajectories quite different
my question though, is when I'm reconcilating in my second physics scene, do I have to have the scene be EXACTLY the same as my main scene?
or do I just have static stuff like buildings and such
GameObject.SetActive(false);
GameObject.SetActive(true);
i figured calling these two like is probably resetting that internal state,
i think if you call these at the start of each physics frame, you have yourself a stateless physics engine which shouldnt make these issues while losing some multiple box stacking capabilities
but i didnt test this further
@slow monolith I wasnt really using multiple scenes at the end in my experiments
I was just doing "reconciliations" on my objects and that was it
in same scene
i'd revert the objects to the past and resimulate in the same scene
I tried doing that, but it seemed that every time I would call physics.simulate, my main scene would lagspike
hm
how so?
you are simulating one player, and all the cars
thats going to be the cost of physics.simulate
you're doing that all in a single frame, right?
i'd be doing all that in a single frame and multiple times per frame when i recieve new server data
which happens commonly
and for the cars, I only need to set their position once, at the start of reconciliation
right?
then I just let it play out with the player's movements
?
but that all only gets set once, at the beginning, right?
everytime you get new state from server, you replace these data first yes
alright
I think I'm complicating it way too much by doing a second scene so yeah im gonna try the single scene again
second scene could help with the internal state issues
well my resim only happens when the positions are mismatched for that tick on client/server
so it won't be happening a ton
i think there are hacky ways to get around that internal state issue but its just going to be too messy
@slow monolith if you are predicting other players, pretty much evertime you recieve data from server, you will have to resim
why so?
because your prediction is wrong %99 of the time
because you didnt know remote player inputs
what inputs do you feed remote cars hugh
I don't think I'm predicting players
I'm just predicting the local player on each client
you are predicting their cars' rigidbodies arent you?
Nope, only applying the velocity for that physics tick that the server just gave to the client
so yeah it won't be predicted and collisions might be a bit wonky
or I could just predict only during collisions
thats an odd system
I'm going mainly for performance
i guess best approach would be to switch between two modes
prediction via simulating
and just simple position extrapolation
if another player is nearby, you switch its car to simulation predicting mode
yeah thats what I had in mind just without the extrapolation part
would be fine without extrapolation too
but it would be more noticable when you switch the modes in realtime like that
there will be bigger position difference
the more your latency, the more the difference
mine only ticks at 20ms, so won't be too much
generally players dont have more than 100ms ping
if you have like 100ms ping, when you switch the car into simulation mode, it will move itself into 100ms future
Btw what if I need to simulate a ragdoll? Do I have to keep track of the position of every single limb?
depending on how fast it was moving, there will be some positional difference
@slow monolith i assume these ragdolls will appear only in unfortunate situations where how good its synced doesnt matter much?
as this is a racing game?
you need the ragdolls synced?
you could do the same rollback resim stuff for ragdolls i guess
so I'd need to save the rotation/position of every limb right?
but its going to cost some data
like arms, legs
alright
only hip position
and angular velocities for all libs
i would probably try to fake it though
wym fake?
you probably have a capsule collider for chracters
yes
i'd try to do a ragdoll mode
and let the ragdoll mode be free without any syncing
but also somehow make sure its not seperated from the capsule
so essentially only sync the "hip" position
and when the character gets back up, switch to capsule mode
yeah that could do
i wonder how they do capsule ragdoll stuff
i play mordhau and i some see some weird ragdoll action
still-alive ragdolls sometimes act as if they are doing helix trajectories
which makes me think that theres that invisible capsule and the ragdoll is orbiting it by its hip
So wait, how much more expensive is physics.simulate with more rigidbodies
will 100-200 rigidbodies be a problem?
i think that will make a problem imo
yeah thats sort of why I was doing it in a separate scene, so I could actively control what I'm simulating
yeah but then they lose any velocity they had, right?
if you still need their collisions
i am not sure if setting kinematic will set velocities zero
if they do, i guess you'd have to restore them
i dunno, i think two scenes is going to messy to deal with
duplicating the static objects and stuff
I think I can just duplicate the static objects over at the creation of it, and then whenever I need to simulate something that I collided with, I can probably move it over pretty easy
unless im missing a step
or just simulate all of the objects in a proximity like you said
@slow monolith yeah its pretty much that no big deal
i guess
i forgot most of my experience with two scenes, i did the switch to single scene not long after
i guess i just liked this representation:
State(t) + Inputs(t) = State(t+1)
with two scenes, it gets weird
but it also gets weird predicted and not predicted objects
so i dont know anymore
I mean it seems to work, my physics stay in sync even after reconciliation happens, like if I drag my server player across the map, the local player reconciliates and stays synced fine
but idk, I guess I'll find out sooner or later
Syncing ragdolls is weird though
There's hardly any games where ragdolls are synced.
If I smash something into a ragdoll on exactly the same simulation twice, will I get around the same result?
or will it be pretty different?
physX is not deterministic, so answer is no. Especially with ragdolls, should be even worse
You don't want to sync every body part transform and rotation
maybe only the transform of the whole body
short answer: no for networking
long answer: physx is guaranteed determ for same build, same machine, exact same inputs. Many things in Unity are not deterministic, like Destroy(). Physx I've found is determ on different machines, same CPU vendor (intel/intel) but not cross CPU vendor, so not useful for networking. Even if floats arithmetic is deterministic in a setup, Physx has an internal cache that is not accessible by Unity that affects the outcome of simulations. Setting the state of rigidbodies and pressing play will not always yield the same outcome
Awesome answer 🙂
@floral turtle I can't remember if I asked you this before, but my players move with .velocity and are rigidbodies, so if my server CPU is intel and my client has some AMD cpu, will the client be reconciliating a lot?
I'm just trying to find out if it's going to be a problem or not
I think Erick said something like they won't instantly differ, but they'll slowly drift apart
It is a butterfly effect, so there is no solid answer on how much they will disagree without testing. But you have to code for worst case.
if we're just talking floats, they'll butterfly like emot said above. But at 60HZ the effect can happen quick, a single tick where the player tries to jump but slightly fell off due to inconsistencies etc.
for PhysX specifically, due to the caching issues above I've done experiments injecting the "true" state every 10 ticks and still have noticeable pop during large collisions, like knocking down a stack of boxes. But I do find after injecting states it converges well enough
I really wish Unity had free test server hosting for around 4 players...
Run it locally?
@dense crystal use hamachi
puts you and your friends in lan
over internet
you will be able to type your friends hamachi ip and join just fine
it is another app not related to unity
As a programmer you probably should be able to figure out how to portforward, assuming your setup isn't terribly special.
Kids putting together Minecraft servers can (usually) do it 😄
what do i need to host a mmo? (its like clubpenguin lol and i want to play the game only with my friends, i dont want it to be public)
"i want to play the game only with my friends"
Not really an mmo then is it?
The examples of PUN or Mirror are probably are you need for that spec, apart from the rest of the game 😄
exactly, but i couldn't find anything better to describe it

Purely for hosting, you just need a machine that everyone can reach, through any means
And especially since you want to only play with your friends, consider privately hosting
Or perhaps even make a game where the client is also the host (like Borderlands for example)
anyone know about multiplayer?
thx!
does anyone know a server authoritative movement tutorial with mirror ?
can't find any
Is port forwarding my router, a faster networking solution than aws free instances, when it comes to multiplayer game server that run one TCP server and one UDP server? I have an FTTC network... sometimes i get max 40 Mbps Download and 15 Mbps Upload....
I just want to test play it, before moving it on a definitive hosted instance
For playtesting? Obviously
OK!
There are applications you can use to simulate latency, jitter, packet loss etc
Having an issue with a TLS connection at the moment, and looking for some assistance. Has anyone ever seen this before?
Exception: System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Security.Interface.TlsException: Failed to read data to TLS context - error code: UNITYTLS_INVALID_ARGUMENT
I can't seem to figure out the cause of such a thing. It looks like the certificate is good, for what it's worth. If there's any other information I could provide, please let me know. I'm using Unity 2019.4.4f1 in this project.
It also seems like noone else on the internet has ever posted about this error, as my google-fu only returned like 2 relevant pages that were not helpful.
Just wondering if anyone is using Unity.Transport?
hi guys im starting to learn about photon pun, on all the tutorials that i watched it have a onconnectedtomaster(), but i couldnt find it,i could only find onconnectedtoserver() but it doesnt get call when i run. If any1 know about photonpun please assist me
Hello! Wondering what backends people are using to store game items? Crouchbase? Firebase? Raw AWS S3 with lots of custom APIs?
@trim belfry Just start with the main Pun2 tutorial https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro
In a game server, would it be bad to prevent wallhacks by only telling the client an object's position if the client on the server has a clear view of it
obviously you wouldn't use this on players, but valuable things like cash piles or such
You have to do some amount of predicting though, if you are doing client prediction.
Otherwise if you poke your head around a corner to take a peak, you will always see nothing - since the server doesn't know you were going to do that.
This is going to complicate your server for marginal returns imo
Will a player also be unable to hear an enemy unless they can see them?
Wallhacks also can, and have been made using spatial audio
Unless you are doing this for an exercise (and there's probably better ways to solve this still), first establish people are wallhacking in your game, because you go through an effort to "stop" it
Why not just send a despawn packet for a specific entity (ie the player you are removing from a room) and all clients receiving this despawn that entity
To get callbacks, scripts need to register first. Use: PhotonNetwork.AddCallbackTarget(this);. Or inherit from MonoBehaviourPunCallbacks (if you override OnEnable or OnDisable, make sure to call the base methods to keep the registration in place).
The tutorial is a good first step (didn't see that reply before I wrote).
thankyou, the monobehaviorpuncallback solved it i found it after a while, worth it lol
Glad you found it, too!
It's important to call base.OnEnable() and base.OnDisable() when you override those 2. Aside from that, it should be straightforward.
Hello! Wondering what folks are using for online persistent storage? Couchbase? Firebase? Something else?
does couchbase's sdk work in unity?
I have no idea 🙂 I’m just starting this journey
i think most people use something with an actively maintained unity sdk, like photon, playfab or gamesparks
you can also use unity's built-in wrappers for the biggest mobile platform's backends, through UnityEngine.Social
firebase is maintained
if you are targeting steam use the steamworks sdk for unity on the asset store
I don’t think photon or Steamworks offer an actual database for storage but yeah I’ll look into the others
you can do cloud saves in steam
it's not like someone's going to be playing two instances of the game at the same time
True but I’ll need to be querying and saving that fairly often, probably from a server for authority
for a single player game?
Yes, there are lots of single player games which have tight control over the player’s inventory. Any game where collecting stuff is the big draw, basically needs to prevent against cheating
i think authoring the business logic of your single player as a hybrid of random server code and a unity client is a really bad idea
and it's probably premature to worry about cheating
the cloud save feature in steam works extremely well
Can you elaborate on why that’s a bad idea? Always trying to extend my knowledge and let it influence the architecture
exactly zero people will be cheating in your game that doesn't exist yet, but you'll be slowed down by having a piece of source code that needs to live on a server every single time you hit the play button
in my experience, everyone who has said "everything starts at zero, you should worry about cheating from day one" was completely and utterly wrong, and the people who said the opposite ("focus on just developing a good game, and stop if it's not good") consistently delivered good games
you don't want to deal with firebase cloud functions
preventing cheating has to do with having something at stake
Nice, this is really clear
You can always develop knowing you will need to revisit code later
So here is a follow up question... any recommendation for writing the code in a flexible way so that some of these logic functions can be replaced with server calls later?
If you know that you might have to move your item data elsewhere, just keep that in mind when making your data structure so its not a tangled mess later to move. Abstract it in a way that makes it not care where it comes from.
Abstraction
i'm looking more carefully at the steam api and it has direct remote storage
Make the handler for it a black box - and the exposed parts such that it won't matter later. That might mean making it async in nature though.
i think this is probably want you want if you want to make a steam game and you're okay with the $100 fee
you're basically paying for the fact that people have their steam accounts at stake, which is why in practice people do not cheat as much in steam games and it works
I have a publishing account for steam so that’s not really a problem
Ok, good tips. Going to think about how to abstract this. Gets hard to simulate when the response times can vary a lot
Once you are thinking Async, you will be dealing with callbacks
So rather than just "mything = GetThing()", you will do something like passing a delegate to the method you want the "thing" sent to when complete, as well as a delegate for "FailedToGetThing"
you can look at the signatures for Azure Serverless to get an idea of what's the minimum level of abstraction you need
in practice using the nicest and simplest server code authoring frameworks is hamstrung by the fact that they do not have good unity SDKs
you will have this cumbersome user account management thing with everything
Hrmm yeah the async and account management stuff is probably the most complex for me as most of the code I’ve written prior has been synchronous.
Like I’m used to just doing HUD.CoinBalance = Inventory.FetchCoins() on every frame. But I can’t really do that with a cloud db solution
Well actually I can
I can cache the coins locally and still run that function every frame
Would you poll the backend on a timer and update the cache say every 10 seconds? Or is there a better way to do this?
Starting to wonder if what I actually want is a web socket connection which call inform the client of stuff has changed and then just use the dev to save session periodically or on server shutdown etc
Also I’m not really doing any of this to release a thing, I’m just looking to learn how to connect all these moving pieces
i think what you actually want to do is write how you've always been writing, and then do something like
var save = new Save() {
CoinBalance = Inventory.FetchCoins(),
Items = Inventory.GetItems(),
...
}
SteamSDK.RemoteFS.WriteAllAsync(JsonUtility.ToJson(save));
when you finally want to do the cheat thing, you can do
PrivateServer.WriteAllAsync(JsonUtility.ToJson(save));
and on your private server...
async Task<Save> LoadSave(string userId) {
return JsonConvert.Deserialize<Save>(await AzureOrAwsApiBlobStorage.GetBlob($"v1/saves/{userId}"));
}
async Task WriteAll(Save save) {
var userId = RequestContext.Principal.Identity.GetUserId();
var oldSave = await LoadSave(userId);
if (oldSave.CoinBalance / save.CoinBalance > 100f) {
throw new Exception("cheated!");
}
...
}
etc. etc.
you can only detect cheaters heuristically
honestly though i think it's a waste of your time
if your game is maintaining a connection you can use pushes from the server to your advantage. Clients should update in real time what they think the values should be but when the data in the database actually changes the server should push this to the client. the server should have write permission and clients only have read permission + cached values.
Hey, i need some advice
what would be the best way to do a server authoritative skill bar and cast mechanism ?
So i was handling the casting ( shortcut , precast, and cooldowns ) on the canvas object that represents the skill bar element ( the icon ) on canvas
but i cannot use rpc to make everyone instantiate the ability locally. because it doesn't have authority, and i decided to keep the mechanism on the player object as well. but i cannot make up my mind for something like that atm.
the best way is to engineer the game logic to be fully embedded (like a library) but unity is sort of ill suited for that
as long as you use transforms and physics to "store" game state you will not be able to do authoritative servers well
I know no one will answer me but its worth a shot soo
how do I connect my client to an existing server in mirror? I have a button that's starts a server but I want it to make a like a join code then there's a place where u can place d code and click a button that will join you on there server. IDK how to do it cuz me nub. (Im using mirror btw with parrelSync for easiness)
@iron stump pretty sure there are tutorials for this, check out mirrors github for docs and links
ok imma check later
https://github.com/DennisCorvers/ByteStream
Great performance update; feel free to check it out and leave a star!
Is it more performant to send game status packets that have all the player status in one buffer, or sending multiple packets, each one for each player status?
i mean from server -> client
can some one walk me thro how a client can connect to a server?
i need my client to join a server
but idk how
@iron stump you can use hamachi and type hamachi ip to connect
for easily testing with an online friend
if you wanna test it yourself on same pc, just make a build and test with editor
Is anyone using Unity.Transport, I'm trying to use DataStreamReader and DataStreamWriter to send a double, but it's missing a Write/Read double so I'm trying to use the WriteBytes method and grab a pointer to the double data. Unfortunately I have no idea what I'm doing and it's not working :p
writer.WriteBytes((byte*) &time, sizeof(double));
{
reader.ReadBytes( (byte* )timePointer, sizeof(double));
}
@sonic marsh you should be able to pass a double into the write function like this
writer.Write(time);
Just going by the example I'm seeing in the documentation leads me to believe you can pass any primitive type
theres no general Write(anything) 😦
If not then probably have to either use a float, or use BitConverter.GetBytes(time) and pass the byte array in the write function
actually it works!!!
turns out i was being dumb and not cleaning up my list of data to send, so i kept sending Time=0 over and over
Ok well carry on then 😛
tyvm
hi can i ask a question
how to check if ur d host
isServer? (btw on mirror)
or just !isClient?
Hey guys
I have a little issue
I created a DGS. My DGS is all set but I want everyone from around the globe to be able to connect without port forwarding or something. I have it built as a server build with Linux as the target platform. I just need to know HOW to upload this to cloud or something. Like Dani did. Please help
hey can anyone recommend some free, quick and dirty ways to get multiplayer up and running? I've got a website that I put single player unity games on, but i've never done any networking and i'm not sure where to start
Free is relative. Mirror and MLAPI are free, but you will have to sort out either hosting, or nat punchthrough/relay.
I wouldn't even ask that question really until you have completed tutorials for Mirror and Pun2 - since those are the most common "Just starting" libraries.
hey can anybody help me? I develope a webgl multiplayer using PUN2. Everything working when i test it as a app but when i use it in the web it don't connect to the Photon servers.
Most ppl try to keep packets under 1500 bytes so it depends on how many players there are and how much data each requires.
@hoary kernel Check browser console for hints. Could also try building a native client to quickly rule out any general build issue
simple noob question
if im d host i call NetworkServer.Spawn
and if im d client wat do i call? or can a client call NetworkSever.Spawn?
So everytime I need to update a rigidbody car's position on every single client, should I first make it snap to the correct position/rotation, and THEN apply the velocity?
or will that fuck with the physics
They operate on wheel colliders so I'm still trying to process how I'm going to do this
my first thought would be to only apply the velocity through the wheel colliders, but then that's no good if another object smashes into the car
okay so yeah applying the velocity on just the car seems to work fine. Just to clarify, I shouldn't be moving the car with wheel colliders, that a player isn't controlling right?
Only@if you want to predict the movement of cars
Which you should
Otherwise cars from@others would look behind
I'm only going to be predicting if the player is touching it
Look like they are in the past
You should predict the cars driven by others as well
At least that is what car games should do
Rocket league, racing, etc, requires this
And it seems you are confused by how car physics works
It depends on how you are moving the cars in the first place
Cars on the server move normally with wheel colliders
it's just getting the client to replicate it that I can't figure out
Cars are normally regular rigidbodies, wheels only apply forces to them in the anchor points
Wheel colliders do not move the car, they apply forces
It is the same on clients, snap to the server data, replicating velocity
Then let your tick prediction system resimulate forward as of this car is a local car (you need the input state telling if it is accelerating or not)
That’s it
I shouldn't need to resimulate if the main player isn't interacting with it right?
Because there's nothing to even predict if the player isn't in contact with it
If it is not close, no
Alright
There is movement to predict
Depends on what your game is
In a racing game you need to predict cars in your vicinity
open world, city based game
with lots of rigidbodies
so I'm trying to predict as little as possible
If it’s a shooter and you have lag compensation, you may not need@to predict
It really depends on what you have as cat mechanics
Car
But the point is
I want it to be as responsive as possible, so yeah Im probably gonna try to predict car crashes
Either predict or not predict, but the replicated data is same
It’s the rigidbody data
Then you need prediction of any car close to you
You don’t know if they will collide you unless you predict them
So wait just to clarify, when the client receives info about other cars driving that the client is NOT predicting, all I have to do is snap the position, rotation, and set the velocity right?
That should be a bit obvious
No
You must predict if you want to predict collisions
I'm talking about cars far away
These then no
These you probably don’t even need data at all
But any car you can see should probably be fully predicted if you want collisions
There’s also the problem of smoothing the transition from non predicted to the prediction zone
To be clear
You will have a hard time with physx performance
so would it be easier and faster in terms of performance to just not predict car crashes?
hmmm alright
Car crashes based game should have prediction imho
Think of grand theft auto, that's sort of what I'm trying to replicate, just on a smaller scale
so you will be driving, just not 24/7
lots of other stuff
Single player is easy
Online you are talking about 500 developers
You can make without prediction, it will just look very very sloppy on collisions
So to clarify, because I seem to still be confused. When the client gets info from other cars, I shouldn't touch the wheel colliders on those cars right?
Even with prediction it can never be perfect
only move the actual car with .velocity?
Without it just looks very broken (on collisions)
I told this several times (because it’s the same for everything, not only cars)
Snap server data, resimulate forward with input as if the object was local
There should be no difference for an offline version code
alright
got it
LocalEntities_Car[Index].BodySet.rotation = JsonReceive.Entities_Car[i].RotationX;
// Apply wheel turning here
// Apply motor torque to wheels here```
So every time a packet comes in, it should look something like this?
I send/receive packets at 50hz btw, so it should only have one player control input per packet.
since that's what my physics ticks at.
Just want to make sure I'm doing this right.
That’s not how a network tick system works
You should be driving the physics engine from@your own code
Sorry, I will stop giving you tips
This is not a tick based system from what I can see
Nah this is my fault, it's my first build of any network system whatsoever
I'm just bad at understanding stuff
My tips assume@you have a tick system
I was under the impression that I did
My client predicts which tick the server is going to be on. Server ticks on it's own.
and client sends the packet aimed at that tick
and then the server sends back data at 50hz
and the client just takes that and processes it. Is that not correct?
server drops all ticks in the past
God damn this is stressful
See this is why I ask questions more than once
why does everytime i spawn my bullet it says NetworkServer is not acitve?
Shooting code:
https://hatebin.com/qsczrbvjfe
Bullet code:
https://hatebin.com/dbhbefoggb
some 1 pls help me
I'm so confused because the movement and interactions all seem to be fine.
player stays synced with the server properly and such
I really don't know what else I'm missing.
Take an in-depth look at how the netcode of a fast-paced multiplayer shooter like Unity's FPS Sample works. Learn about snapshot generation and compression, client-side prediction and lag compensation. See how the game code has been structured into server and client parts to enable a small, dedicated server to run the game.
The FPS Sample is i...
"Every frame the client sends out a user command"
thats literally what I'm doing but every fixedupdate
and yes I am stepping the physics engine manually, I'm just calling it at the end of every fixedupdate.
If anyone wants to step in and tell me what I'm doing wrong, please do. Because I'm having a heart attack right now
it's NOT the same
when there are two machines involved (client and server), FixedUpdates are NOT aligned
You need to control a custom FixedUpdateNetwork
with a tick system
They did this for their sample ECS netcode (it's the only Unity-made sample with a tick system - the other libraries I know have it are: Photon Bolt, Photon Fusion, and the stuff from other engines like UE4, Source Engine, etc)
People who write their own libraries also have tick systems working
If you don't understand what this means, it might be beyond your current level of understanding.
This might be the case
So when I predict which tick the server is on, does that tie into this?
this is very complex
it's not something I can just add a snippet
So if I just keep doing what I'm doing, what sorts of issues will I run into
realize this is what took experienced developers YEARS to create
a lot
it will be sloppy
there are different goals:
- if you want to learn how to do networking yourself, don't try to write a GAME... Go study networking, write small prototypes
- if you want to finish a GAME, use something that's production-ready
- if you ALREADY know networking really well, you can do both... but that is out of the question
You have to realize I'm not trying to make some super competitive CSGO shooter
you are doing something as complex
just something fun to play
which is realistic car collisions
hmmm
if you just want something fun, go use a production-ready simple library
The thing is, GTA multiplayer is super sloppy. Cars teleporting everywhere, hackers everywhere
and everyone still buys it
and its at the top of steam charts
or was
and don't try complicated stuff like (these are all PITA to solve):
- DON'T car collisions
- DON'T moving platforms
- DON'T lag compensate projectiles (just accept client hits)
- DON'T server authority + client prediction
You wiull NOT be able to do a game that is similar to a multi million dollar project
People play GTA online not because it's good (the netcode is horrible). People play it because it's GTA
So:
- ye, do something fun, donÄt bother with perfect netcode... Just use Mirror or PUN2, or anything off the shelf
but don't compare yourself to GTA
I think im gonna try to move forward with my rats nest piece of shit netcode
It's apples to oranges
¯_(ツ)_/¯
but yeah idk
it does not...
if it was working correctly you would have a prediction basis to work on (for cars or anything - that means a proper tick system)
And you would not be asking any question
that's just a fact
but you've been asking the same questions for months
Unless im retarded, it does in-fact seem to be working fine. Reconciliation only gets triggered when I walk into an object which isn't predicted on the client's end, and the client gets out of sync
I've ran numerous tests on it
Client stays in sync
Client receives packet from server with his last known position with the tick that it occurred at; client compares from his list of stored ticks. If positions differ, teleport client back to that position and run all inputs using physics.simulate all in a single frame up until the present tick
I've tested it and 99% of the time, no reconciliation needs to happen, unless, as I stated, the client walks into something that he shouldn't, or isn't predicted locally (I have debug logs whenever reconcilation gets triggered)
which sounds about right logically
I was just confused about simulating the cars, which I seem to understand a bit better now.
But yeah I do ask a lot of questions which I apologize for, I just like to be 100% certain about things before spending a week building it, only to be doing it completely wrong.
I'm having a new issue. Whenever I get the car's rigidbody's position from the server and apply it to the client car rigidbody, it messes with the velocity
and causes the car to spazz out
is there any way to avoid this?
@slow monolith when you are restoring the cars state from servers car state,
you should restore
rb.position // this is necessary if you have interpolation/extrapolation on
rb.rotation // using transform is same if you have interpolation off
rb.velocity
rb.angularVelocity
@high night And the wheel collider info too?
i guess its angular velocity should be restored
if it can be steered or something, that info should be restored too
@slow monolith
alright yeah
basicly restore anything you can that affects the outcome
got it
btw what do you mean if I have interpolation/extrapolation on? My visual part just lerps to my rigidbody car
if you got interpolation/extrapolation setting enabled in rigidbody, that concerns you
but I should be restoring the rigidbody's position regardless of that?
if rigidbody you wanna restore has these settings enabled you have to change position/rotation via rigidbody instead of transform
oh I see what you mean
rb.position and transform.position wont be same when you read
if thats the case
because transform.position is interpolated rb.position
So if a user presses W on the server in a car and that sets the wheel collider motor torque to 400 and propels the car,
I shouldn't replicate that on the client when he receives info about that car that he isn't driving?
I should only just set the velocity of the car CAUSED BY the wheel collider?
and not the motor torque of the wheel collider?
and only use the wheel collider to steer cars on the client that the player isn't controlling?
I think erick tried to explain this to me yesterday I'm just special and don't seem to understand everything 100% the first time around
@high night
@slow monolith the wheel velocity would be part of the "state"
other player pressing W is part of the "input"
state(t) + input(t) ----simulation----> state(t+1)
.
i would want to restore the "state" to servers "state"
lets say i want to simulate 5 more ticks on top of that "state"
i need some inputs to simulate 5 next states right?
@slow monolith
to show client the future
alright.
lets say i want to obtain state(t+5)
i have state(t) and inputs(t)
what i do is:
state(t+1) = state(t) + inputs(t)
state(t+2) = state(t + 1) + inputs(t)
state(t+3) = state(t + 2) + inputs(t)
state(t+4) = state(t + 3) + inputs(t)
state(t+5) = state(t + 4) + inputs(t)
@slow monolith
i use inputs(t) because thats the last true thing i know, which would get me a decent prediction
expect for local player, local players inputs are known
.
@slow monolith For the torque stuff, you would simple apply the input for that car
and it would generate your torque
But you also told me to apply the velocity of the car for that server tick
thats part of the state
torque is not a state
i mean, you wouldnt look at a rigidbody and say that it has "torque"
you combine inputs and state
and you get the next state
or
in another words
you apply inputs to your objects and simulate one tick, you get the next state
.
the situation/state of the scene at 150th tick
+
what buttons players pressed on 150th tick
->
the situation/state of the scene at 151th tick
So let me give you a situtation and you'll tell me if I'm right
Client receives packet from server
- Apply position, rotation, velocity, ang velocity
- Client ALSO receives input of every player from that tick. If other client player is in a car and pressing W, set the motor torque of that car's wheel collider to 400 (or whatever). If client is pressing A, turn the wheel collider left
client is a different client other than player
that is correct
Okay
but the way you say it seems to imply writing duplicate code?
i mean you wont need to recreate your car control logic
you just feed its inputs and go on with running your tick
alright
car0.FeedInput(input0);
car1.FeedInput(input1);
car2.FeedInput(input2);
RunMyUpdateLogic();
Physics.Simulate();
and before the feedinput, you would obviously apply the position, rotation, velocity, etc
correct?
alright I think I'm understanding this better now
FeedInputs(int tick):
feed inputs for all cars
if input for that tick is missing for a car, use latest instead
int currentTime:
current tick number, it advances when you run RunMyUpdateLogic();
regular:
FeedInputs(clientTime);
RunMyUpdateLogic();
Physics.Simulate();
on new state receive:
newState = // the state data just came from server
newStateTime = // tick number of the state just recieved by server
RestoreState(newState);
while(currentTime < clientTime){
FeedInputs(currentTime);
RunMyUpdateLogic();
Physics.Simulate();
}
@slow monolith
@grizzled narwhal It's generally like this as i see:
Servers time is realtime
Client is in future
when servers state is recieved by client, its basicly from past (realtime - latency)
@grizzled narwhal server doesnt resimulate yes
@slow monolith You also recieve new inputs from server along with states
You're confusing me with that while loop
when you restore the state like that, you are going to the past
@slow monolith
right
and you wanna go back to future
the way i'm imagining your system is
you are basicly doing this reconciliation for all cars
so its basicly rocket league
yeah I think I see what you're trying to say
so restore, and then re-run the entire simulation
including local player inputs
right?
yep
local and known remote player inputs
@slow monolith
this is rocket league style networking we are discussing right now if i am not wrong
I'll only be predicting objects in a certain radius to the local player as erick suggested
since I'm going to have 200+ rigidbodies
my reconciliation happens in an additive scene btw
yeah, you are doing rocket league networking within a radius
alright
yeah I see
and all things running on that state
So from a performance standpoint, is doing reconciliation in a separate scene going to eat up more CPU than just doing it in one scene?
nothing from the additive scene gets rendered
only uses calculations
I have another problem, when I restore all of the values from the server to the client for the car, it still thinks the car is moving, and the wheels are spinning in place, extremely slowly, infinitely @high night
nah I'm really close
almost got it working
I'm fairly certain rust uses wheel colliders on their cars
and they made it work perfectly
What do you suggest then
I'm not that smart
F
rust literally uses the default wheel colliders
oh hey Luc you here too
I'm certain of it
too much time on my hands 😦
@grizzled narwhal yeah same this is the bottom of the barrel channel when all other discords are quiet and im waiting for a build
how long are your build times?
Imagine trying to find an il2cpp and having to rebuild every time
and I'm debuggin lnl to check if the reliable packets are actually reliable
oh lol
I'm making good progress
I just cant figure out how to fix the wheel spinning in place
I could probably fix the problem by just lerping the rotation of the client visual wheel to the server's wheel
but that might look a little bit funky
How do i fix that error over there
you cant set the angular velocity of the wheel colliders, i guess you cant get away with using them
@slow monolith
hmm it says in the docs wheel rpm is read only
looks like only interface to restore the wheel rpm is via adding motor torque to adjust wheel velocity
but velocity will probably be applied after a physics step so looks like you wont be able to restore that value correctly
@GaryS#2698
i would probably not use wheel colliders
using rigidbodies is also not very good because of the internal states
well thats a massive roadblock that I wasnt expecting
I'm fairly certain that the game rust uses the default wheel colliders
they look and feel exactly the same, suspension and everything
i would probably try to roll my own raycast based wheels
i'd read a little here and try to make something not too bad
https://github.com/unity-car-tutorials/Unity5-WheelColliderSource/blob/master/Assets/GTWheelColliderSource/Scripts/WheelColliderSource/WheelColliderSource.cs
rigidbody internal states are a problem but i believe doing disabling and enabling all simulated rigidbodies in your fixeduldate code (before everything else) should reset the internal states
which will probably make your collisions more deterministic
@slow monolith
i havent tested that one though
i am talking disabling and then enabling all rigidbody gameobjects at the start of every tick before anything else
I think I tried to disabled the rigidbody and then enable it, it didn't really do much
anyways hopefully erick has some advice for this problem
I think this is his specialty
unless he uses custom wheel colliders and not unity's, then im sorta fucked
@slow monolith disabling enabling probably wont help woth wheel colliders
thats not why i suggested it at all,
i believe that might make car collisions deterministic
as far as determinism with floating points goes
oh alright
This guy just sends the wheel rotation over the network to the clients
but it's not predicted
This guy also does wheel colliders over a network, not sure if its predicted or not
Halo
So....this is a code of my spawning system, for this I use mirror. As it stands, the Command tells the server to instantiate and spawn a specific object, based on the given parameters. It as well gets the netId from said spawned object and passes it to the getObject() function: https://hatebin.com/cprihfjeco
I am attempting to give the client's script access to this spawnedObject. But I am unable to. Whenever this code is run on a host it works just fine, but clients do not get the Debug, and as can not get the netId. How am I supposed to get around this? I just want the client to be able to locate/have access to the spawnedObject
So my client's car's rigidbody is kinda jerky whenever I set the server's position to it, so I lerp the visual model to the rigidbody collider which also contains the wheel colliders
the problem is, if the car goes too fast, the lerp sorta gets left behind. If I speed it up, I can see the jerkiness. How do I go about this?
@slow monolith I tested what i said about disable/enable thing, it just doesnt work
i can't make a deterministic rollback with simple cubes
https://hatebin.com/yzyqrlmjet what i did basicly if you are wondering
you can save/load two states
i tried to save in different timeframes
and play each one out, results are different
pls suggest any good playlist for learning netowrking
i want to convert my singleplayer game to multiplayer
@high night Is it truly that big of an issue?
like worst comes to worst, I just reconciliate every single tick
why only 100?
@simple yew google gafferongames
How do game servers handle networking? Do they just send data using UDP and periodically use TCP for correction?
I use no TCP at all. The library I'm using has a reliable layer on top of UDP to make sure packets arrive, I can mark packets as reliable so the framework makes sure it gets deliverd
I use that functionality mainly for chat and RPC's
Why not just make those components TCP?
Also, anyone got info handy for encryption?
From my understanding, you'd transmit actions done once using TCP, while actions that need to be constantly transmitted would use UDP instead. For example, walking is UDP, but let's say pressing a button to open a door, that would be TCP
@blazing pilot Most games use UDP
Some games do use TCP
Very few games ever mix UDP/TCP, it's not a good technique
Your assumptions of what would be TCP, UDP, etc. is wrong
For most modern games, especially fast paced, all traffic goes over UDP
nowadays, the significant distinction between TCP and UDP is that TCP provides a fully featured Connection class, so to speak, on top of the same underlying uh, physics, of UDP
if you are making a mobile game, TCP's idea of Connection really gets in the way. a disconnected TCP Connection does not correspond to a user disconnecting from the game
Mobile games are 90% of the time state based
usually that just means the user switched to wifi, or briefly lost connection, or etc. etc.
so for example, when you play clash royale (a realtime mobile game), the game keeps going regardless of whether or not the user is "connected"
a lot of games do this
Carrying identification is enough over multiple networks
the user might bein a subway
etc. etc.
if you're making a PC game for PC networking, the reality is... do you have to worry about people with spotty Internet connections?
if you're Riot I guess you do. but they will eventually have a fully mobile League
that will obviate that idea
reimplementing TCP over UDP is something that people do, and there are interesting reasons for that, but among the giant companies that do that and actually force adoption of what they do, it is very strongly motivated by better support for mobile device networking
in my opinion, you will gain little from using UDP and reinventing your own Connection object over using TCP's sort-of built in ideas for PC desktop users. this is not a super orthodox answer, Blizzard and Valve and that one guy whose blog everyone references for example uses UDP for everything, but on the other hand, they were writing networking for a day and age where maybe connectivity issues were far more prominent on the PC than they are today
there are libraries that do this for you, they are opinionated and usually good
so it's sort of immaterial
Well, I wanna write one of my own
like for the ceremony / education of it?
On a side note, it's not uncommon for packets to get lost
That too
Especially UDP packets
i think you'll learn a lot 🙂
the thing is
And that's just on my router
you know, it's a lot like supporting android
malformed packets
do you use an android phone?
Yeah
yeah
litnetlib is a good example of a reliable udp library: https://github.com/RevenantX/LiteNetLib
an ios user, how much more do you think they spend than an android user, on games, or on anything?
I'd say a bit more
games do handle things like jitter and packet loss, but fast paced ones do it over UDP
you know, my estimate is about 4x, that's if you punch it into google
Well, missing a packet in a shooter isn't that much of a big deal, as the next packet will fix everything
they'll have better internet connections, so it's also easier to develop for them
you see what i mean?
you target the xbox platform, someone spent $300-500 on hardware, $20-60 on the game, they will have cable internet
etc. etc.
your game will not be less fun on TCP
That's marketing >.>
it's networking
that's the Big Reveal at the end of my speech here
it's sort of a waste of time to worry about people with spotty internet connections... at first
you would be better served by writing the ceremony / learning the abstractions around the channel of the networkig not mattering
the end of that road is, wow, why am I using Unity when Unreal already makes all these decisions for me?
because if it's an FPS
that's where that road goes
Because Unreal is owned by Epic and Epic bad
I don't see the appeal for Unreal, really
So, I guess I could put in a byte specifically for confirmations on packet reception
you can study the steam networking library for some good insights as to how to concretely do this
if you want something more modern i would study grpc
everything will eventually use or look exactly like grpc
that is what i use for my realtime game
hmm
I mean, it's not like I'm lost or anything
I think I know exactly how to do it
usually what everyone ends up reinventing is grpc
they just don't know it
which is a huge stack of stuff
I think that's very abstract
it only sounds that way but if you look at every part of the stack they did
how does grpc work
like http/2 (SPDY)
like, a short version
it's a standard for remote procedure calls
it uses http/2 in a very raw way, and contiguous buffers for messages, and it's own interface definition language that is written with client-server applications in mind
i think it will soon support http/3, which improves its latency in a way that makes it suitable for something like games
at least over the bottom 50% of internet connections
so you can either use something that will be supported forever that everyone is migrating to
or you can write your own bespoke thing
if you are making mobile games it matters
"
At SafetyCulture, we have estimated that using HTTP/3 would save thousands of hours in latency to our combined user base. This is the conclusions we have come to based on some micro-benchmarks over WiFi internet connections. Overall, the latency improved by 20 to 40 ms when using HTTP/3.
Our findings are actually aligned with the outcomes of Cloudflare research while comparing HTTP/2 and HTTP/3. The interesting aspect of this extensive study is that the picture is not so bright, in fact HTTP/3 can perform worse than HTTP/2 depending on the size of the payload.
However, these studies do not take into account substantial latency improvement when migrating between mobile and WiFi networks. This improvement could have a massive impact on our users since SafetyCulture’s main product, named iAuditor, is used in a wide variety of places with disparate quality of internet access (e.g., Ethernet, WiFi, mobile networks). We are still assessing ways to gauge those benefits for our customers.
" https://medium.com/safetycultureengineering/grpc-over-http-3-53f41fc0761e
QUIC (HTTP/3) will be the way we do things for at least the next decade
by hook or by crook, because chrome will mandate* it through higher search rankings, and it's the largest networked application in the world
i don't enable QUIC on mobile, but you can.
Good read
what do i put here if im using spacewar to test on pun 2
@slow monolith like i said a few days ago ... we have done networked vehicle physics and we made everything custom
WheelCollider sucks
I was aware of what you said, I just don't feel confident enough to build my own wheel system and have it be good
People have networked wheel colliders successfully, I'm just trying to figure out how
@slow monolith the wheel collider is basically impossible to network successfully with prediction and reconciliation
Because you can not reset all its internal state
Properly
You can ofc apply all kinds of interpolations and smoothing algorithms on top to make it look better but can never make it 100% proper
Guys, I'm making a photon multiplayer game, I have a property been synced using
PhotonNetwork.SetPlayerCustomProperties(hashtable);
Is supposed to be done by the master player to make the changes locally and sync it with the other players, but in my case what happening is like it syncing from the master players to other, but the changes are not happening locally in master client
private void connect()
{
if (PhotonNetwork.IsMasterClient)
{
setPlayerProperties();
PhotonNetwork.ConnectUsingSettings();
PhotonNetwork.LoadLevel("Game-c#");
}
}
this is my code
any help would be appreciated
private void setPlayerProperties()
{
var playerFlag = PlayerPrefs.GetInt("PlayerFlag");
var playerFormation = PlayerPrefs.GetInt("PlayerFormation");
Hashtable hashtable = new Hashtable();
hashtable.Add("Flag", playerFlag);
hashtable.Add("Formation", playerFormation);
PhotonNetwork.SetPlayerCustomProperties(hashtable);
}
@graceful zephyr Can you sort of walk me through the basic idea of making a good wheel collider
sorry i am busy with work
alright
Hi guys, I'm using mirror and have set up a lobby with chat functionality. Everything seems to work until the 2nd client joins, then I get the error message:
Replacing existing prefab with assetId '2fce3758-etc'. Old prefab 'EmptyRoomPlayer', New prefab 'EmptyRoomPlayer
Then they overlap and the host cant start because UI buttons overlap. Anyone any ideas?
Hmm, should you package things in a UDP packet to send or should you fire off everything immediately?
@blazing pilot fewer packets / sec is usually preferred
What's an accepted interval? 10ms?
A good standard rate is 30 packets/sec
so 30-40?
Transform data
Yeah that’s not what I meant but w/e
Well, I'm essentially planning on making an object transmitter
No clue what that is
ie drop it on game objects and have it transmit data from the game object
So you would pack the object's ID along with transform data and other components and send them off to the server
That seems kind of arbitrary and not very useful
and the server would send back updates like that
Essentially it's a wrapper for object properties you want to tell the server/client
¯_(ツ)_/¯
For example, a player moving would transmit their transform and all translates called
30 packets/sec is a good target, that doesn’t mean you can send every object 30 times/sec
If you have a lot of objects
Yeah, that's why I'm packing all the data in one packet
I mean, let's assume you have 30 objects you're sending
Transform data would be 28 bytes per object plus ids
That’s basically all you can send then
Say 34x30
28 bytes?
Assuming you don’t do any compression or similar or have no other data
12+16 for pos+rot
Yeah I know I’m right :p
A byte for each property
because you'd want the receipient to know that this part's a transform, so it's 32 bytes
what if it's another component's data?
Because transforms don't always change
So just for transforms, 33 bytes, +4 bytes for the client's session key
So 1 transmission would be 37 bytes. If 30 objects change, 990+4=994 bytes, shortly under 1kb
Thus a player will send 994 bytes to the server, 30 players would send off 29820 bytes, or 29.1kb in total
Then the server would have to send off 994-33 bytes to each player for an update
so 28830 bytes sent to all players, 864900 bytes in total, or 844kb
More often than not, scale and lossy scale don't change, so we could avoid sending them, and that would be done through the byte we've assigned before
have fun ¯_(ツ)_/¯
thanks, lol
Anyone got any ideas whats causing this prefab / assetID issue?
Unity: im converting an image into bytes then sending the bytes across a tcp connection to the server. when received, i convert them back into an image but the image is corrupted. (the conversion is 100% working correctly, the sending message across works 100% for strings but not images) anyone got any suggestions on why images get corrupted when sent across TCP?
hmm
I'm not 100% sure on how you're doing this, but I'd use a 4x4 pixel image
send it over
and observe the hex data
hmmm gonna try that
There's a couple of things that could be going on
I know the theory of tcp, but have not worked with it much
It probably depends in your execution
but any tcp datagram beyond 1500 bytes will be fragmented due to the ethernet frames' limitation
Normally, it would get reassembled
use something like this
fragmentation istn the issue
somethign else is
tcp will handle hundreds of megabytes fine
if you transfer it properly
normally, yeah
"normally"... no, it will
i'm assuming its the fact that TCP is a stream protocol and not a message protocol
that's biting him in the ass
i.e. trying to convert the data back into an image before all of it arrived
That's probably something inspecting the data would show, too
If the small image sends correctly, that means the issue is larger images
larger data, rather
Heck, he could just send a huge lorem ipsum
But yeah, I think you're right on the stream thing
i am right
I haven't messed with tcp for over 10 years or something like that
but I do remember screwing up on the stream part
great, vs decided to blow up my diagram
Correct me if I'm wrong, but in a 2 way connection using RSA you have to generate two pairs of keys, right?
One for the client and one for the server
Look into Mirror, DarkRift, Forge, MLAPI...
Bolt also
You can also consider adding support for joining through something like Discord: https://discord.com/developers/docs/game-sdk/networking
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
anyone in here using photon 2?
i have an error i cant seem to figure out after updating from pun1 to pun2
using the pun setup wizard i readded my application id. i then start my game and get the following error: "GetRegions failed. Can't provide regions list. ReturnCode: -2: Empty application id"
however in the PhotonServerSettings, the appid is defined
any ideas?
Could it be possible to have a duplicate PhotonServerSettings? I would probably just look into how it's grabbing the app ID
Hello everyone.
There are a few questions I want to ask. First of all, I must say that I don't know much about networking and backend systems.
I want to make a game that offers a more advanced AR experience than a game like Pokemon GO, but I don't know how to do the backend systems and networking of this game.
Which technologies should I learn? I would be glad if you enlighten me about the systems running in the back of Pokemon GO.
Thanks.
@vocal cipher If you don't care about cheaters or just want to ban them on a per-basis, then it could be as simple as just sending positions back and forth
I've never played pokemon go and I don't know how the internals work, but I don't think it would be hard to spoof your GPS address to cheat (if that's even how it works)
AR would be hard to prevent cheaters, because to prevent most cheaters, you need to be able to create an exact re-simulation on the server's end. Pretty impossible with AR since everything is always changing
@slow monolith you are absolutely right, thank you for your suggestions
@vocal cipher I prototyped pokemon go after it came out, really fun
Basicly
Game ===Websocket ==> Region Based Web Server ===> Project orleans backend
project orleans was a really good fit
@sonic marsh thanks a lot i will research the orleans and websocket things
the webserver was a asp.net core signalr server (Websocket was singalr)
all really good tech, well supported
and i had the whole stack in azure
i used openstreetmaps for the maps
not google
i was planning google 😅
there are differnet solutions now too
some things on unity appstore
and mapbox? or something like that
btw with websocket can i handle realtime events like player skills or something like that ?
the reason i didnt pick google was i wanted raw XML access to the map data
yes ı heard mapbox
web socket is any normal socket
so can do whatever you want with it
tho whats interesting is pokemon go dosnt use web sockets, just a ton of webAPI calls
actually I haven't decided yet, but I liked the personalization events in the map data provided by google.
that may have changed tho
yes it may be, by the way can i add you to ask questions during the development phase 😄 it will be a pretty long project for me
Hey. I'm still looking for a tutorial or explanation on how to setup a local multiplayer network. Anyone have any good links for that?
@slate otter Read the pinned topics, the best wealth of information related to your question.
i'm not sure if this is the right section... but what do you guys use to save information for online multiplayer games? like usernames, passwords, etc
@odd oracle Just never handle user/pass yourself
look at oAuth and use google/facebook ect
ok ill look it up
I would be really happy to help😩
I want a project in GitHub or something I can play FPS multiplayer game and of course edit the game.
I would love if something could help me find such a project
Thanks, I did have a look before and couldn't seem to find anything specific to local discovery. I know unity Networking was a thing designed for LAN play but it was discontinued (https://docs.unity3d.com/Manual/class-NetworkDiscovery.html) so what replaced that for Unity LAN?
Ah I actually see it's integrated into Unity now under Network Manager. You can set it to LAN, I guess this is the new NetworkDiscovery! Thanks!
did anyone ever come across "Curl error 51: Cert verify failed: UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH" ?, it started happending on every web request (other team members dont have this issue).
and google turned up nothing useful
Is it bad practice to reconciliate local physics on every packet received?
@high night You seemed to be right about wheel colliders not being good for prediction. My cars don't want to stay synced on server/client no matter what
trying to decide if I should go through the trouble of making custom wheel colliders or just reconciliate every tick
they are not too bad but because you just have too much going on with wheel colliders and all
i was seeing one guy (roboserg guy) here doing a rocket league clone and he was doing some custom raycast based wheels as i recall
i dont know if his work was multiplayer though
yeah this is very annoying. Not exactly sure how I'm going to approach this further yet
I suppose reconciliating every tick isn't the worst idea in the world, since Roystan did reconciliation on 1000 rigidbodies with 10 tick rollback at 60hz
with optimal performance
with all of them colliding at once
One thing I notice with wheel colliders is that whenever you apply a steer angle, even if it's absolute 0, it causes the velocity of the car to bug out in extremely small increments. Like 1.372892e-07 and then spazzes around at that number
which I'm guessing is most likely where the discrepancies are coming from.
I suppose I could always have a feature to turn off prediction for vehicles if the client was ever lagging too bad due to reconciliation
I might also be able to get away with reducing the tick rate from 50hz to 30hz
@rocky bramble
A friend had made this for me once
You can find a simple example dll function called from unity
with its cpp source
with solution files and all
should be simple to get it to work
I know it's preference but what do you guys think of vultr vps for a fast paced game (in playtesting not live), and is there an amazon equivalent (vpc?)
Hi, is there a good sample game with AWS based server (It can also be Firebase if you give me a good reason for it)? I found the official aws-samples github but it is all old stuff, is there a more recent one? I am in beginning steps of developing a 2D Space MMO with static instances for solar systems and private instances for the home world
what is the best way to sync a small integer array, i am using mirror
Hey, I'm creating this game and I eventually would like it to be multi-player with around 4-5 players hosted on their machines. I don't have much networking experience but would I be able to make it singleplayer and convert it into multi-player later or will I have to tear apart basically the whole gamr to implement multi-player?
Start by doing a tutorials for Mirror and Pun2 - without even thinking about your game.
Converting single player to multi rarely goes well, even with experienced networking devs, so I would set your expectations low.
@jade glacier Have you ever done any sort of driving over network?
Okay so I think the game Rust doesn't use prediction for their cars. Which is probably how they solved the wheel colliders not being deterministic
@floral turtle When you did your 1000 rigidbody rollback test, did you notice any tiny lagspikes at all?
no, but that was an entirely offline demo—so not really a test of how it perform in actual network conditions, just seeing how physx itself would behave being resimed
well you did 60hz and resimmed 10 rollbacks at every tick
so that's currently way more than I'm expecting even over a network
I'm at 4 resims on lan and if I crank my game back to 30hz then I really should never exceed 10 rollbacks unless the user is at like 200 ping
So whats the advantage of having the server running at less then 60 hz?
Basically im running my server as fast as possible, BUT the bits which figure out what data to send and triggers commands runs at fixed update (currently at 30hz)
so my server can process and send as soon as something comes up but most of the heavy work is in a slower update cycle
Is this a good approach or should i slow down my Network send/receive too?
@sonic marsh You'll never need to send data more frequently than your player can execute commands
so like if your player moves with physics inside fixedupdate (which defaults to 50hz) then 60hz is 10hz too much
but they players could send stuff that needs to be processed asap
I don't know how fast human reaction times are, but after a certain amount it doesnt help at all
30hz should be plenty
hmm true
fyi rust servers run at 10hz
garrys mod servers run at around the same rate
thats 1 tick update every 100 milliseconds
for a game at the top of steam charts, that's alright Id say
but this is for a RTS, so something like a unit move command comes in, it would be nice to do the 'auth' asap and then queue the movements for next fixed update
How fast hz/tickrate you need for your game completely depends on what type of game it is and what ambition level you have.
Hello and good morning 🙂 before I do so, is it allowed to post code in here with a question?
yes, sure
use Markdown code syntax
but if BIG stuff, post on hatebin or so
then a link here
How do you structure your code for a system that requires:
-prediction via simulating and rollback for local player (server authority)
-fixed timesteps
-simpler extrapolations for all other objects like snapshot extrapolation
I am particularly interested in:
1-How do you update your world on tick
2-How do you deal with visual things that needs to be separated from regular tick update
(like character movement animations that may hold their own states which might be different for different clients)
3-How do you treat simulated objects and other objects
4-How do you handle object creation/destruction
That's an ignorant statement.
It's evident from many videos on Rust that it does not have the best netcode out there (putting it lightly)
You know CSGO has servers running at tick rates of 100+ right?
Hi. does anyone know how to use #if directives with server builds
I am making my client and server project into one project but having a little difficulty with the preprocessor commands aas my ide greys out the code sometimes
That's not to say games with low tickrates and/or poor netcode won't sell (we have ample examples of games that do). But stating that Game X does Y and it sold well, therefor it's good to do is an ignorant statement
Split them up by logic, not by preprocessor directives
Have a Server class and a Client class that both fulfil other roles. (To put it very simple)
I do
Then you don't need directives
I have a server class. I just do not want it to be compiled if I am building a client build
Why not
Oh no, your program is 1kb bigger now?
no. basically I have a server class which creates a "Client" object on the server when a client join. The client also has it's own instance of a client class
I'm trying to acheive this
Oh well, there's your problem
Capturing and trying to apply inputs directly in the Update of the character controller
I don't think you should use this as a reliable source for networking
If you need a complete resource, use the Unity FPS Sample project
It has client and server in one project. With the option for dedicated server
I'm not fullly following this
I have the client sending pos every tick
so it is client authorative. Idc about cheating as it is a coop game and I have commands available if they want to get items and stuff
Then there's even less of a reason to follow the link you've sent
Ok so how would I go about making it one project? I do currently have 2 put I find it isn't a good workflow and I will be having duplicate code as the map is procedurally generated. Which means that both the client and server need the same code so it is duplicate. I therefore opted for one project so I can have a "shared" folder
If you need a complete resource, use the Unity FPS Sample project
It's a complete vertical slice of a fully working game
that uses dots tho
my point is that I am not making a server authorative game like that fps. I am learning to make my own netcode at the same time so I have developed my own system. I just need a solution for bringing the client and server together
Which is something that the FPS Sample does