#archived-networking

1 messages · Page 95 of 1

still pier
#

same way Console.WriteLine(); won't work but rather Debug.Log

weak plinth
#

Google is your friend

still pier
#

But this is saying make an external forms app

#

I was asking if I can read input from within the headless build

weak plinth
#

Read the thread...

still pier
#

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?

gray pond
still pier
#

ok thanks

still pier
#

yeah thanks I was making a logger class and this has helped alot

opal kite
#

How to sync LineRenderer.Positions with clients?

#

Seems like ClientRPC is the intended way

slow monolith
#

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

high night
#

@slow monolith are you going to predict local player only? or all players?

slow monolith
#

I'm just predicting the main player's movement and the movement when he's in a car

#

nothing else is predicted

high night
#

the reason you change scenes and stuff is because you dont want to disturb other players rigidbodies?

slow monolith
#

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

high night
#

if you are not predicting other players then why do you want to have rigidbodies on them?

slow monolith
#

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

high night
#

you should do that for the car local player is driving

#

ah

#

its for proper hit predictions?

slow monolith
#

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

high night
#

you wanna predict that collision between cars

#

right?

slow monolith
#

essentially yes

#

I think

high night
#

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

slow monolith
#

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?

high night
#

yes but that car is in collision with the ground

#

so it holds some internal states

#

and you are not recieving that info

slow monolith
#

then reconciliation should be able to clean that up, right?

high night
#

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

slow monolith
#

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

high night
#

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

slow monolith
#

I tried doing that, but it seemed that every time I would call physics.simulate, my main scene would lagspike

high night
#

hm

#

how so?

#

you are simulating one player, and all the cars

#

thats going to be the cost of physics.simulate

slow monolith
#

you're doing that all in a single frame, right?

high night
#

i'd be doing all that in a single frame and multiple times per frame when i recieve new server data

#

which happens commonly

slow monolith
#

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

#

?

high night
#

position velocity angvel, rotation

#

wheel angvels

#

anything you have

slow monolith
#

but that all only gets set once, at the beginning, right?

high night
#

everytime you get new state from server, you replace these data first yes

slow monolith
#

alright

#

I think I'm complicating it way too much by doing a second scene so yeah im gonna try the single scene again

high night
#

second scene could help with the internal state issues

slow monolith
#

well my resim only happens when the positions are mismatched for that tick on client/server

#

so it won't be happening a ton

high night
#

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

slow monolith
#

why so?

high night
#

because your prediction is wrong %99 of the time

#

because you didnt know remote player inputs

#

what inputs do you feed remote cars hugh

slow monolith
#

I don't think I'm predicting players

#

I'm just predicting the local player on each client

high night
#

you are predicting their cars' rigidbodies arent you?

slow monolith
#

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

high night
#

thats an odd system

slow monolith
#

I'm going mainly for performance

high night
#

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

slow monolith
#

yeah thats what I had in mind just without the extrapolation part

high night
#

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

slow monolith
#

mine only ticks at 20ms, so won't be too much

#

generally players dont have more than 100ms ping

high night
#

if you have like 100ms ping, when you switch the car into simulation mode, it will move itself into 100ms future

slow monolith
#

Btw what if I need to simulate a ragdoll? Do I have to keep track of the position of every single limb?

high night
#

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?

slow monolith
#

More of an open world game

#

so pedestrians and other cars and such

high night
#

you need the ragdolls synced?

slow monolith
#

Server will control ragdoll physics

#

but yeah

#

they need to be synced

high night
#

you could do the same rollback resim stuff for ragdolls i guess

slow monolith
#

so I'd need to save the rotation/position of every limb right?

high night
#

but its going to cost some data

slow monolith
#

like arms, legs

high night
#

no need for positions

#

local rotations would be enough

slow monolith
#

alright

high night
#

only hip position

#

and angular velocities for all libs

#

i would probably try to fake it though

slow monolith
#

wym fake?

high night
#

you probably have a capsule collider for chracters

slow monolith
#

yes

high night
#

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

slow monolith
#

so essentially only sync the "hip" position

high night
#

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

slow monolith
#

So wait, how much more expensive is physics.simulate with more rigidbodies

#

will 100-200 rigidbodies be a problem?

high night
#

i think that will make a problem imo

slow monolith
#

yeah thats sort of why I was doing it in a separate scene, so I could actively control what I'm simulating

high night
#

you could also do that via enabling disabling objects

#

or setting them kinematic

slow monolith
#

yeah but then they lose any velocity they had, right?

high night
#

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

slow monolith
#

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

high night
#

@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

slow monolith
#

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

weak plinth
#

Syncing ragdolls is weird though

#

There's hardly any games where ragdolls are synced.

slow monolith
#

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?

patent fog
#

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

floral turtle
# slow monolith If I smash something into a ragdoll on exactly the same simulation twice, will I...

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

patent fog
#

Awesome answer 🙂

slow monolith
#

@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

slow monolith
#

I think Erick said something like they won't instantly differ, but they'll slowly drift apart

jade glacier
#

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.

floral turtle
#

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

dense crystal
#

I really wish Unity had free test server hosting for around 4 players...

weak plinth
#

Run it locally?

high night
#

@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

spring crane
#

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 😄

weak plinth
#

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?

spring crane
#

The examples of PUN or Mirror are probably are you need for that spec, apart from the rest of the game 😄

weak plinth
weak plinth
#

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)

lean flax
#

anyone know about multiplayer?

midnight bane
#

does anyone know a server authoritative movement tutorial with mirror ?

#

can't find any

silent zinc
#

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

weak plinth
#

For playtesting? Obviously

silent zinc
#

OK!

weak plinth
#

There are applications you can use to simulate latency, jitter, packet loss etc

wise lily
#

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.

sonic marsh
#

Just wondering if anyone is using Unity.Transport?

trim belfry
#

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

misty shale
#

Hello! Wondering what backends people are using to store game items? Crouchbase? Firebase? Raw AWS S3 with lots of custom APIs?

jade glacier
slow monolith
#

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

jade glacier
#

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.

weak plinth
#

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

stiff ridge
#

The tutorial is a good first step (didn't see that reply before I wrote).

trim belfry
stiff ridge
#

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.

misty shale
#

Hello! Wondering what folks are using for online persistent storage? Couchbase? Firebase? Something else?

amber trench
misty shale
#

I have no idea 🙂 I’m just starting this journey

amber trench
#

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

misty shale
#

I don’t think photon or Steamworks offer an actual database for storage but yeah I’ll look into the others

amber trench
#

it's not like someone's going to be playing two instances of the game at the same time

misty shale
#

True but I’ll need to be querying and saving that fairly often, probably from a server for authority

amber trench
#

for a single player game?

misty shale
#

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

amber trench
#

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

misty shale
#

Can you elaborate on why that’s a bad idea? Always trying to extend my knowledge and let it influence the architecture

amber trench
#

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

misty shale
#

Nice, this is really clear

jade glacier
#

You can always develop knowing you will need to revisit code later

misty shale
#

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?

jade glacier
#

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

amber trench
jade glacier
#

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.

amber trench
#

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

misty shale
#

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

jade glacier
#

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"

amber trench
#

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

misty shale
#

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

amber trench
#

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

slim ridge
midnight bane
#

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.

amber trench
#

as long as you use transforms and physics to "store" game state you will not be able to do authoritative servers well

iron stump
#

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)

sonic marsh
#

@iron stump pretty sure there are tutorials for this, check out mirrors github for docs and links

weak plinth
silent zinc
#

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

iron stump
#

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

high night
#

@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

sonic marsh
#

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));
            }
shut yarrow
#

@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

sonic marsh
#

theres no general Write(anything) 😦

shut yarrow
#

If not then probably have to either use a float, or use BitConverter.GetBytes(time) and pass the byte array in the write function

sonic marsh
#

actually it works!!!

shut yarrow
#

I'll try to check myself because I just took a quick look on the website

#

It does?

sonic marsh
#

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

shut yarrow
#

Ok well carry on then 😛

sonic marsh
#

tyvm

iron stump
#

hi can i ask a question

#

how to check if ur d host

#

isServer? (btw on mirror)

#

or just !isClient?

sonic marsh
#

@iron stump all that is explained very clearly in the mirror docs

dire blade
#

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

south palm
#

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

jade glacier
#

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.

hoary kernel
#

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.

slim ridge
spring crane
#

@hoary kernel Check browser console for hints. Could also try building a native client to quickly rule out any general build issue

iron stump
#

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?

slow monolith
#

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

slow monolith
#

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?

gleaming prawn
#

Only@if you want to predict the movement of cars

#

Which you should

#

Otherwise cars from@others would look behind

slow monolith
#

I'm only going to be predicting if the player is touching it

gleaming prawn
#

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

slow monolith
#

Cars on the server move normally with wheel colliders

#

it's just getting the client to replicate it that I can't figure out

gleaming prawn
#

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

slow monolith
#

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

gleaming prawn
#

If it is not close, no

slow monolith
#

Alright

gleaming prawn
#

There is movement to predict

#

Depends on what your game is

#

In a racing game you need to predict cars in your vicinity

slow monolith
#

open world, city based game

#

with lots of rigidbodies

#

so I'm trying to predict as little as possible

gleaming prawn
#

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

slow monolith
#

I want it to be as responsive as possible, so yeah Im probably gonna try to predict car crashes

gleaming prawn
#

Either predict or not predict, but the replicated data is same

#

It’s the rigidbody data

gleaming prawn
#

You don’t know if they will collide you unless you predict them

slow monolith
#

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?

gleaming prawn
#

That should be a bit obvious

gleaming prawn
#

You must predict if you want to predict collisions

slow monolith
#

I'm talking about cars far away

gleaming prawn
#

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

slow monolith
#

so would it be easier and faster in terms of performance to just not predict car crashes?

gleaming prawn
#

It’s up to you

#

And what you want for your game

slow monolith
#

hmmm alright

gleaming prawn
#

Car crashes based game should have prediction imho

slow monolith
#

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

gleaming prawn
#

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

slow monolith
#

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?

gleaming prawn
#

Even with prediction it can never be perfect

slow monolith
#

only move the actual car with .velocity?

gleaming prawn
#

Without it just looks very broken (on collisions)

gleaming prawn
#

Snap server data, resimulate forward with input as if the object was local

#

There should be no difference for an offline version code

slow monolith
#

alright

gleaming prawn
#

Except you are running from your network update

#

That’s all

slow monolith
#

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.

gleaming prawn
#

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

slow monolith
#

Nah this is my fault, it's my first build of any network system whatsoever

#

I'm just bad at understanding stuff

gleaming prawn
#

My tips assume@you have a tick system

slow monolith
#

I was under the impression that I did

gleaming prawn
#

Forget everything...:)

#

You did not

slow monolith
#

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

iron stump
#

why does everytime i spawn my bullet it says NetworkServer is not acitve?

#

some 1 pls help me

slow monolith
#

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.

slow monolith
#

"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

gleaming prawn
#

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.

slow monolith
#

So when I predict which tick the server is on, does that tie into this?

gleaming prawn
#

this is the best theory source around the toipic

gleaming prawn
#

it's not something I can just add a snippet

slow monolith
#

So if I just keep doing what I'm doing, what sorts of issues will I run into

gleaming prawn
#

realize this is what took experienced developers YEARS to create

gleaming prawn
#

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
slow monolith
#

You have to realize I'm not trying to make some super competitive CSGO shooter

gleaming prawn
#

you are doing something as complex

slow monolith
#

just something fun to play

gleaming prawn
#

which is realistic car collisions

slow monolith
#

hmmm

gleaming prawn
#

if you just want something fun, go use a production-ready simple library

slow monolith
#

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

gleaming prawn
#

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

slow monolith
#

I think im gonna try to move forward with my rats nest piece of shit netcode

gleaming prawn
#

It's apples to oranges

slow monolith
#

it seems to be working semi-fine

#

reconciliation works perfectly fine

gleaming prawn
#

¯_(ツ)_/¯

slow monolith
#

but yeah idk

gleaming prawn
#

it does not...

slow monolith
#

only time will tell

#

how does it not?

gleaming prawn
#

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

slow monolith
#

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.

slow monolith
#

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?

high night
#

@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

slow monolith
#

@high night And the wheel collider info too?

high night
#

i guess its angular velocity should be restored

#

if it can be steered or something, that info should be restored too
@slow monolith

slow monolith
#

alright yeah

high night
#

basicly restore anything you can that affects the outcome

slow monolith
#

got it

#

btw what do you mean if I have interpolation/extrapolation on? My visual part just lerps to my rigidbody car

high night
#

if you got interpolation/extrapolation setting enabled in rigidbody, that concerns you

slow monolith
#

but I should be restoring the rigidbody's position regardless of that?

high night
#

if rigidbody you wanna restore has these settings enabled you have to change position/rotation via rigidbody instead of transform

slow monolith
#

oh I see what you mean

high night
#

rb.position and transform.position wont be same when you read
if thats the case

#

because transform.position is interpolated rb.position

slow monolith
#

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

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

slow monolith
#

alright.

high night
#

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

slow monolith
#

But you also told me to apply the velocity of the car for that server tick

high night
#

thats part of the state

slow monolith
#

so if I applied the velocity + applied torque to the wheels

#

alright

high night
#

torque is not a state

#

i mean, you wouldnt look at a rigidbody and say that it has "torque"

slow monolith
#

sorry I'm a tad bit confused

#

you lost me at the whole state = state + input thing

high night
#

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

slow monolith
#

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

high night
#

that is correct

slow monolith
#

Okay

high night
#

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

slow monolith
#

alright

high night
#

car0.FeedInput(input0);
car1.FeedInput(input1);
car2.FeedInput(input2);

RunMyUpdateLogic();
Physics.Simulate();

slow monolith
#

and before the feedinput, you would obviously apply the position, rotation, velocity, etc

#

correct?

grizzled narwhal
#

Once

#

On the tick you received

slow monolith
#

alright I think I'm understanding this better now

grizzled narwhal
#

@high night the server is in the past right?

#

So the server never resimulates

high night
#

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

slow monolith
#

You're confusing me with that while loop

high night
#

when you restore the state like that, you are going to the past
@slow monolith

slow monolith
#

right

high night
#

and you wanna go back to future

slow monolith
#

are you talking about local player reconcililation?

#

and movement prediction?

high night
#

the way i'm imagining your system is
you are basicly doing this reconciliation for all cars

#

so its basicly rocket league

slow monolith
#

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?

high night
#

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

slow monolith
#

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

high night
#

yeah, you are doing rocket league networking within a radius

slow monolith
#

alright

high night
#

my psuedocode was considering one scene though

#

one state loaded at a time

slow monolith
#

yeah I see

high night
#

and all things running on that state

slow monolith
#

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

slow monolith
#

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

graceful zephyr
#

trying to network unity car physics?

#

just give up

slow monolith
#

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

graceful zephyr
#

too much internal state in physx, it's garbage for this

#

100% utter garbage

slow monolith
#

What do you suggest then

graceful zephyr
#

implement your own wheel/car logic using raycasts

#

and network that

slow monolith
#

I'm not that smart

grizzled narwhal
slow monolith
#

rust literally uses the default wheel colliders

graceful zephyr
#

oh hey Luc you here too

slow monolith
#

I'm certain of it

grizzled narwhal
graceful zephyr
#

@grizzled narwhal yeah same this is the bottom of the barrel channel when all other discords are quiet and im waiting for a build

grizzled narwhal
#

how long are your build times?

graceful zephyr
#

il2cpp master

#

takes a lil while

#

not that long

grizzled narwhal
#

Imagine trying to find an il2cpp and having to rebuild every time

graceful zephyr
#

i only do it for benchmarking

#

otherwise i use mono

grizzled narwhal
#

and I'm debuggin lnl to check if the reliable packets are actually reliable

graceful zephyr
#

oh lol

slow monolith
#

oml this is so fucking annoying

#

the wheel just spins super slow in place

graceful zephyr
#

We made fully networked car physics

#

It's fun

slow monolith
#

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

rapid horizon
#

How do i fix that error over there

high night
#

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

slow monolith
#

hmmm

#

well that sucks

high night
#

i would probably not use wheel colliders

#

using rigidbodies is also not very good because of the internal states

slow monolith
#

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

high night
#

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

slow monolith
#

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

high night
#

@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

slow monolith
#

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

placid gulch
#

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

slow monolith
#

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?

high night
#

@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

#

you can save/load two states
i tried to save in different timeframes
and play each one out, results are different

simple yew
#

pls suggest any good playlist for learning netowrking

#

i want to convert my singleplayer game to multiplayer

slow monolith
#

@high night Is it truly that big of an issue?

#

like worst comes to worst, I just reconciliate every single tick

high night
#

it should be good enough

#

for up to 100ms of prediction i guess

slow monolith
#

why only 100?

grizzled narwhal
#

@simple yew google gafferongames

blazing pilot
#

How do game servers handle networking? Do they just send data using UDP and periodically use TCP for correction?

shut yarrow
#

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

blazing pilot
#

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

graceful zephyr
#

@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

blazing pilot
#

What about packets that NEED to arrive

#

That must not be lost

grizzled narwhal
#

Reliable UDP

#

Most transports use UDP but implement their own TCP

amber trench
#

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

blazing pilot
#

Mobile games are 90% of the time state based

amber trench
#

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

blazing pilot
#

Carrying identification is enough over multiple networks

amber trench
#

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

blazing pilot
#

You actually do

#

Packet loss is a thing

amber trench
#

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

blazing pilot
#

Well, I wanna write one of my own

amber trench
#

like for the ceremony / education of it?

blazing pilot
#

On a side note, it's not uncommon for packets to get lost

#

That too

#

Especially UDP packets

amber trench
#

i think you'll learn a lot 🙂

blazing pilot
amber trench
#

the thing is

blazing pilot
#

And that's just on my router

amber trench
#

you know, it's a lot like supporting android

blazing pilot
#

malformed packets

amber trench
#

do you use an android phone?

blazing pilot
#

Yeah

amber trench
#

yeah

floral turtle
amber trench
#

an ios user, how much more do you think they spend than an android user, on games, or on anything?

blazing pilot
#

I'd say a bit more

floral turtle
#

games do handle things like jitter and packet loss, but fast paced ones do it over UDP

amber trench
#

you know, my estimate is about 4x, that's if you punch it into google

blazing pilot
#

Well, missing a packet in a shooter isn't that much of a big deal, as the next packet will fix everything

amber trench
#

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

blazing pilot
#

That's marketing >.>

amber trench
#

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

blazing pilot
#

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

amber trench
#

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

blazing pilot
#

hmm

#

I mean, it's not like I'm lost or anything

#

I think I know exactly how to do it

amber trench
#

usually what everyone ends up reinventing is grpc

#

they just don't know it

#

which is a huge stack of stuff

blazing pilot
#

I think that's very abstract

amber trench
#

it only sounds that way but if you look at every part of the stack they did

blazing pilot
#

how does grpc work

amber trench
#

like http/2 (SPDY)

blazing pilot
#

like, a short version

amber trench
#

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

Medium

In this article, we discuss how to serve HTTP/3 traffic while focusing specifically on gRPC and gRPC-Web.

#

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.

blazing pilot
#

Good read

slow monolith
#

Has anyone in here done networked wheel colliders?

#

In dire need of advice

random matrix
#

what do i put here if im using spacewar to test on pun 2

graceful zephyr
#

@slow monolith like i said a few days ago ... we have done networked vehicle physics and we made everything custom

#

WheelCollider sucks

slow monolith
#

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

graceful zephyr
#

@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

lapis vapor
#

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);
        }
slow monolith
#

@graceful zephyr Can you sort of walk me through the basic idea of making a good wheel collider

graceful zephyr
#

sorry i am busy with work

slow monolith
#

alright

humble swift
#

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?

blazing pilot
#

Hmm, should you package things in a UDP packet to send or should you fire off everything immediately?

graceful zephyr
#

@blazing pilot fewer packets / sec is usually preferred

blazing pilot
#

What's an accepted interval? 10ms?

graceful zephyr
#

A good standard rate is 30 packets/sec

blazing pilot
#

so 30-40?

graceful zephyr
#

Depends on the game really

#

What you are sending

#

Etc

blazing pilot
#

Transform data

graceful zephyr
#

Yeah that’s not what I meant but w/e

blazing pilot
#

Well, I'm essentially planning on making an object transmitter

graceful zephyr
#

No clue what that is

blazing pilot
#

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

graceful zephyr
#

That seems kind of arbitrary and not very useful

blazing pilot
#

and the server would send back updates like that

#

Essentially it's a wrapper for object properties you want to tell the server/client

graceful zephyr
#

¯_(ツ)_/¯

blazing pilot
#

For example, a player moving would transmit their transform and all translates called

graceful zephyr
#

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

blazing pilot
#

Yeah, that's why I'm packing all the data in one packet

graceful zephyr
#

You still can’t send all 30/sec

#

If you have a lot of objects

blazing pilot
#

I mean, let's assume you have 30 objects you're sending

graceful zephyr
#

Transform data would be 28 bytes per object plus ids

#

That’s basically all you can send then

#

Say 34x30

blazing pilot
#

28 bytes?

graceful zephyr
#

Assuming you don’t do any compression or similar or have no other data

#

12+16 for pos+rot

blazing pilot
#

you have 3 sets of 4 bytes and 1 of 4

#

for the quaternion

#

oh wait

#

yeah

#

right

graceful zephyr
#

Yeah I know I’m right :p

blazing pilot
#

yeah, i'm a bit fuzzy today

#

So, 32 bytes in total per object

graceful zephyr
#

960 bytes

#

For 30 objects

blazing pilot
#

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

graceful zephyr
#

have fun ¯_(ツ)_/¯

blazing pilot
#

thanks, lol

humble swift
#

Anyone got any ideas whats causing this prefab / assetID issue?

real trail
#

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?

blazing pilot
#

are they 100% corrupted?

#

Like, do they show up on an image viewer?

real trail
#

they don't

#

if i open them it shows "we dont support the file format" and its a .png

blazing pilot
#

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

real trail
#

hmmm gonna try that

blazing pilot
#

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

graceful zephyr
#

fragmentation istn the issue

#

somethign else is

#

tcp will handle hundreds of megabytes fine

#

if you transfer it properly

blazing pilot
#

normally, yeah

graceful zephyr
#

"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

blazing pilot
#

That's probably something inspecting the data would show, too

graceful zephyr
#

well it wont show up/happen with a small image

#

or small amounts of data

blazing pilot
#

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

graceful zephyr
#

i am right

blazing pilot
#

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

spring crane
#

Look into Mirror, DarkRift, Forge, MLAPI...

graceful zephyr
#

Bolt also

short pewter
weak plinth
#

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?

spring crane
#

Could it be possible to have a duplicate PhotonServerSettings? I would probably just look into how it's grabbing the app ID

vocal cipher
#

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.

slow monolith
#

@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

vocal cipher
#

@slow monolith you are absolutely right, thank you for your suggestions

sonic marsh
#

@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

vocal cipher
#

@sonic marsh thanks a lot i will research the orleans and websocket things

sonic marsh
#

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

vocal cipher
#

i was planning google 😅

sonic marsh
#

there are differnet solutions now too

#

some things on unity appstore

#

and mapbox? or something like that

vocal cipher
#

btw with websocket can i handle realtime events like player skills or something like that ?

sonic marsh
#

the reason i didnt pick google was i wanted raw XML access to the map data

vocal cipher
#

yes ı heard mapbox

sonic marsh
#

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

vocal cipher
sonic marsh
#

that may have changed tho

vocal cipher
#

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

slate otter
#

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?

white stone
#

@slate otter Read the pinned topics, the best wealth of information related to your question.

odd oracle
#

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

sonic marsh
#

@odd oracle Just never handle user/pass yourself

#

look at oAuth and use google/facebook ect

odd oracle
#

ok ill look it up

weak plinth
#

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

slate otter
#

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!

brisk lance
#

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

slow monolith
#

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

high night
#

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

slow monolith
#

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

slow monolith
#

I might also be able to get away with reducing the tick rate from 50hz to 30hz

rocky bramble
#

Is it possible to indluce c++ dll to unity to project?

#

sorry, its not right place

high night
#

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

somber drum
#

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?)

cloud dawn
#

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

midnight bane
#

what is the best way to sync a small integer array, i am using mirror

signal oracle
#

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?

jade glacier
#

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.

slow monolith
#

@jade glacier Have you ever done any sort of driving over network?

slow monolith
#

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

slow monolith
#

@floral turtle When you did your 1000 rigidbody rollback test, did you notice any tiny lagspikes at all?

floral turtle
#

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

slow monolith
#

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

sonic marsh
#

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?

slow monolith
#

@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

sonic marsh
#

but they players could send stuff that needs to be processed asap

slow monolith
#

I don't know how fast human reaction times are, but after a certain amount it doesnt help at all

#

30hz should be plenty

sonic marsh
#

hmm true

slow monolith
#

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

sonic marsh
#

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

graceful zephyr
#

How fast hz/tickrate you need for your game completely depends on what type of game it is and what ambition level you have.

nova mural
#

Hello and good morning 🙂 before I do so, is it allowed to post code in here with a question?

gleaming prawn
#

yes, sure

#

use Markdown code syntax

#

but if BIG stuff, post on hatebin or so

#

then a link here

high night
#

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

weak plinth
#

You know CSGO has servers running at tick rates of 100+ right?

still pier
#

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

weak plinth
#

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

weak plinth
still pier
#

how do you mean?

#

some code is common so i have put it in a shared folder

weak plinth
#

Have a Server class and a Client class that both fulfil other roles. (To put it very simple)

still pier
#

I do

weak plinth
#

Then you don't need directives

still pier
#

I have a server class. I just do not want it to be compiled if I am building a client build

weak plinth
#

Why not

still pier
#

Because it isn't needed?

#

I want to have the host run a dedicated server

weak plinth
still pier
#

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

weak plinth
#

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

still pier
#

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

weak plinth
#

Then there's even less of a reason to follow the link you've sent

still pier
#

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

weak plinth
#

If you need a complete resource, use the Unity FPS Sample project

#

It's a complete vertical slice of a fully working game

still pier
#

that uses dots tho

weak plinth
#

It doesn't, it uses a hybrid

#

But that's not relevant to the netcode

still pier
#

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

weak plinth
#

Which is something that the FPS Sample does