#archived-networking

1 messages ยท Page 93 of 1

worthy gale
#

that makes sense, I am sorry for this newbie question

jade glacier
#

It won't be valid until OnJoinedRoom has fired

worthy gale
#

alright, I'll test this later then, thanks!

analog venture
#

I saw on a forum that it was internal Unity bug with the input system so I just remade the input asset and now there are no errors, BUT the jump system just doesn't work ๐Ÿ˜‚

brazen flume
#

how do i sync rig layers in photon pun 2

vernal compass
#

Extremely Entry-Level question here, but i'm looking for a networking solution i guess? Something that would allow me to take a game and create "servers" in the style of Runescape / Rucoy (Android mobile) / Curse of Aros (Ios mobile) / while having either a webgl player / mobile app.

Any leads on packages / leads / etc that are available nowadays i'd appreciate.

worthy gale
#

I can't drag and drop a script component into the Observed Components on a Photon View component, does anybody know why?

#

using Unity 2019.4.13f1 and PUN 2 - 2.25

grim violet
#

does the script have something to observe?

#

OnPhotonSerializeView

worthy gale
#

it does yeah

#

oh nvm, it is working now! I just deleted the component and add it again

#

and suddenly it worked, thanks

jade glacier
#

you can just leave that on autofind

#

The whole manual drag and drop is just for backwards compat.

#

@worthy gale

#

Or hit find, same outcome.

worthy gale
#

Yeah, just figured that! thanks ๐Ÿ˜„

iron stump
#

some 1 help me why wont my bullet spawn

#

pls

#

idk why

#

also how do i fix an error it says server not active

#

im using mirror

analog venture
#

Can anyone look at my code and tell me why my character isn't jumping? I linked everything correctly with the input system, and my character is able to move and look around properly.

https://hatebin.com/zyctuezawp

slow monolith
#

So is someone able to tell me why we make the client/server match tick rates instead of just having the client send the server packets with instructions every 0.02 seconds and not keep track of the server's tick

#

is it so the client doesn't get too far infront of the server or something like that?

slow monolith
#

Also when finding the RTT / 2, can I just send a timestamped packet from the server to client?

#

Or does it have to be client -> server -> client

slow monolith
#

I'm having an awful time trying to get tick prediction working. I'm having to predict 4 ticks ahead on a LAN connection just to have them arrive on time

#

3 and under arrive too late

slow monolith
#

Currently I'm just polling for new items on the queue in my fixedupdate, which is what's causing it to run so slow

#

I don't know how else to check for new info without polling

iron stump
#

can some one pls help me when i spawn my bullet i get this error: NetworkServer is not active. Cannot spawn objects without an active server.
I have seperates scripts for my weapon player and bullet my weapon is a child of the player but it doesnt create the bullet all the weapon does it call a function inside the player and lets the player spawn it in i dont know whats wrong since im fairly new to networking.

silent zinc
#

Hi, is there someone that can clarify my custom network protocol? I'm using python non blocking TCP/UDP sockets in server side, and in client side i'm using TcpClient and UdpClient classes. My game protocol uses only hex bytes to communicate, with this packet structure: PacketIDbyte + BodyLengthBytes + BodyBytes i'm parsing every packet using Reflection and generic types, with BitConverter, Encoding and Array.Copy i'm doing all the serializing/deserializing in client side. Everything crucial is surrounded by a try/catch that should "properly" handle the exception.

#

I'm not concerned about the serialization/deserialization part...that seems to work pretty good!

#

I'm using TCP as the reliable game server, that should handle lobbies and players, while the UDP server is primarly used for forwarding players status packets in an active match.

#

About the status packet...

#

The status packet has a ulong counter set as the very beginning of the packet's BodyBytes, that gets increased every time the status "changes" ( which means another variable called oldStatus gets checked and copied after), this counter is useful, cause i can check, server side and even client side, if the new_status_packet_counter > current_status_counter

#

The result seems good, but if i do lots of actions, that translates in many packets x second, the opponents updates slow, if the spyke goes down for a moment, it keeps following the packets in order, moving the player slowly from the previous positions to the newest...

#

Obviously, i'm using different threads to receive the packets, i'm parsing the packet in Update tho, idk why it seemed faster if i do that..anyway, i forgot to mention that every time a buffer gets processed, and a new valid packet has been found, the packet goes to list, for game packets, my method to take packets from the list uses a List.Clear(), so i get the packet, and i clear all the next packets, so that i can still receive the latest one.

#

Sorry if i took too many lines out of this channel...

#

Feel free to DM me..

weak plinth
fossil raven
#

So I'm working on a 2D platform fighting game and from what I understand if I want to implement networking I should try and work on that from the beginning. I also know it would make sense to use a P2P connection with deterministic rollback. I've seen multiple articles on how it works, but I have no clue how to implement it in Unity. Does anyone know how I would do so?

sleek laurel
#

im using photon pun

weak plinth
#

@sleek laurel Pastebin or Hatebin it please

sleek laurel
#

ok

#

i bet its just something stupid i forgot to do

south palm
#

i'm trying to set up multiplayer for a webgl game on my website

#

but I don't know a lot about networking

sleek laurel
#

nvm i found out

#
        if (photonView.IsMine)
        {
            photonView.RPC("GetTexture", RpcTarget.AllBufferedViaServer, skinurl);
        }
#

just had to do this

south palm
#

the docs say If you need to use Networking in WebGL, you currently have the options to use the WWW or UnityWebRequest classes in Unity or the new Unity Networking features which support WebGL, or to implement your own networking using WebSockets or WebRTC in JavaScript.

sleek laurel
south palm
#

what is ti?

sleek laurel
south palm
#

oh it's a unity package?

sleek laurel
#

yeah

patent fog
#

Not really, it's an asset made by Exit Games

grim violet
#

i thought exit games owned photon

#

oh you mean not a "unity package" but "someone package"

patent fog
#

yeah

#

"unity package" is misleading, like it would be internal

slow monolith
#

@grim violet Can you explain to me why the client needs to sync his tick with the server? Why can't the client just send an update packet to the server every 0.02 seconds and not include the tick?

#

I cant seem to understand it no matter how many people try to explain it to me

#

like I get how to do it, I just don't get WHY we do it

grim violet
#

you could do it without marking the packets, thats kinda the base of udp, sending packets without caring, but then its just received in any order and can be hard to maintain
the reason people mark em is exactly for syncing, knowing what clients are at compared to server

slow monolith
#

So say the server decides to lag and is now 40 ticks behind, you wouldn't want the client to be 40 ticks ahead

#

so they would need to re-sync

#

?

grim violet
#

it cant be 40 ticks behind

#

well it could but

#

the next tick received will fix it

slow monolith
#

hmmm

grim violet
#

hence why they are marked

#

if server start sending 1000 packet to each client and at packet 500 one of the client lag until packet 600, he will still receive packet 600 when server decide to

slow monolith
#

but if they weren't marked the server decided to lag behind a few ticks, that would cause problems right?

grim violet
#

if you try to sync client from 500 to 600 while he missed all this it wont work

#

if server lag everyone lag

slow monolith
#

alright

grim violet
#

when you play those game where server has authority, you can see it clearly when you freeze, everything around freeze, other player too

#

and it resume once the lag on server stop

#

now if your game freeze and other arent, either server doesnt have authority or its your own client that laggued out

slow monolith
#

well if you weren't syncing the tick, and the server lagged at tick 500 for a couple seconds, and the client just kept sending packets

#

the input buffer on the server for that client would start filling up pretty fast

#

and the client would be behind right?

grim violet
#

if client receive nothing it shouuld be froze in palce until next packet

#

imo

slow monolith
#

ok

grim violet
#

if client continuen sending packets while no one know whats going on

#

it will end up mixed up

#

client could literally kill everyplayer while server lag then it resume, what happen

#

gotta stop it

slow monolith
#

yep

#

So when the client predict's the server's tick, about how precise should I be predicting?

#

the server's next tick? Or like 3 into the future by the time the server gets the packet?

slow monolith
#

So say my server is at tick 150 and it decides to synchronize the client. I'm ticking every 20ms and it takes 200ms from server->client, we can predict, on the client, that the server is now on tick 160, correct?

#

and then I have to predict the same way, when sending packets back to the server, to guess which tick its going to land on?

grim violet
#

yep

#

well when sending back to server it doesnt matter

#

as your server will process latest tick?

#

i mean you got an order to follow on server

slow monolith
#

Wait, when sending info to the server, do I have to include the tick number in the packet?

grim violet
#

for sure

slow monolith
#

so I'd have to predict which tick the server will be on?

grim violet
#

did you check that Server reconciliation part in the webpage

#

i think thats exactly what they are showing

slow monolith
#

I'll have a look

#

I'm still very confused. So when the client sends the server an update packet, the server will process that update packet on the next tick, no matter what?

#

I don't have to guess which tick the server will be on, from the client?

grim violet
#

well you gotta follow it close but dont have to be on the exact same tick (maybe 3 tick forward as you said, there no exact magic number as it differ with the lag etc), now if your client is ahead of 20 tick compared to server, you know something is wrong, id freeze the client until it receive the other ticks from server and get close to what you expect it to be

#

i have no idea of the proper way to do this but this is what i think it should be

#

at least thats what i see from games

slow monolith
#

alright

grim violet
#

this sums it alot

#

then you add lag compensation for the delay

#

that website i showed sums it all pretty much, just readed it all

sullen raft
#

Hey guys. Looking for people who who like to help us build community created maps for the VR FPS Alvo. Ping me if you are interested. Thanks!

analog venture
#

I have a 3D movement script written. Currently, I am able to move around, without gravity. Here's where the problem starts. I tried implementing jumping and gravity into my script. However, it did not work. So I decided to do some testing upon a users request, and I realized that when I click the space bar (jump key), the debug log only returned once. The ground check does not seem to be the problem.

Code: https://hatebin.com/zyctuezawp

dense hedge
#

How is lag-compensation done for finite-speed projectiles? (Or is it actually not done?)
Should the server spawn them in the past like it would do for hitscan traces, but then like fast forward them to catch up to the client?

jade glacier
#

answer is "Depends"

#

You have to decide which timeframe you want them in, and how to get them gracefully into that timeframe.

#

If you are shooting like rockets, and you want the other player to be able to dodge them and see them in their predicted timeframe, you need to time advance them for that player.

#

For the shooter, you may want to also try to see them in the timeframe of the other players, so you can see how much you missed by, which means some combination of inducing trigger lag, and/or lerping the projectile between timeframes - for example leaving the barrel a little late and flying a little slower than actual speed.

#

You aren't seeing "reality" but the goal is to make the object as best as possible get into the desired timeframe.

#

You don't typically spawn them in the past on the server. The server is the keeper of "reality" though, so all that matters is that everything respect its authority in the end.

#

all of the pushing time around for the projectile is just cosmetic.

dense hedge
#

So to the point on enabling other players to dodge, do mean like someone fires a rocket and everyone starts extrapolating its position?

jade glacier
#

They know when they get the "fired" message, that it is late. How late can be tricky to nail down, but its basically 1/2 RTT from the shooter to server + 1/2 RTT server to dodger.

dense hedge
#

right

jade glacier
#

You are lining with the server if you aren't pushing time around like you are talking about doing.

#

in which case, the delay is just 1/2 RTT

#

The answer varies depending on what you are doing with the server/client authority over this

#

But whatever the number is, the client who is dodging knows it is seeing the past, and it needs to try to get that projectile into its predicted timeframe

#

So it advances its travel by X ms

#

There is a balance there as well though, if that missile hits some other player, they won't see that right

#

Because the other player is in the past, and the projectile is in the present for that dodger

#

So there is never a perfect answer in state transfer with prediction

dense hedge
#

Can it be done fully server-authoritative? Like not needing any client to send a message like "hey, I think that rocket hit something."

jade glacier
#

This is fully server auth. The issue is prediction

#

The server sees reality. The issue is you as the player are predicting your own actions

#

you can not do that, but your input lag will be henious.

#

Fully server auth means you send inputs to the server, and you wait for your resulting state.

#

Only way around that is insane good pings, like Stadia depends on.

dense hedge
#

Right, I think I just need to think over what you wrote a bit more. I'm not sure which timeframe I want things to be in.

jade glacier
#

This is all just talking about state transfer with prediction. The rules change when you get into lockstep, extrapolation, and determinism.

#

As long as you get the concept of the timeframes

#

Prediction lets the player do things immediately, but that puts their actions in the future of what they see around them.

#

They are eternally in desync

dense hedge
#

Yep, I think now I've got a pretty good grasp of those fundamentals and like maintaining clients at the right lead ahead of the server based on their ping. I just got stuck on this rocket thing.

#

On a somewhat related tangent, say I have the client predict firing the rocket but I actually mispredicted (got stunned). Is there a generic way to undo locally spawned entities? I guess if I'm sending snapshots I can just overwrite the whole state and they'll disappear.

jade glacier
#

The rocket thing is a good exercise in figuring out how to deal with hiding the paradox

#

That usually falls right on the game dev to figure out how to resolve

#

This isn't deterministic though

#

so the server is the final word no?

#

you just mean how to unfire your rocket locally?

dense hedge
#

yeah

jade glacier
#

That is a cosmetics problem

#

that rocket isn't real anyway

#

predicted weapons should be considered to be entirely cosmetic, they do no actual damage

#

So you could just make it disappear, and mask it with like a screenflash or effect from when you got stunned.

dense hedge
#

that makes sense

jade glacier
#

For projectiles, I keep a tick record of them, so when the server comes back with the state I can map that to the object

#

That is useful if you intend to shift the projectile you predicted into the server timeframe... you need to know when the server finally got back to you confirming you shot it.

#

And same as with the other clients, you use that to determine where it actually should be, and lerp it into agreement.

dense hedge
#

I'll wrap my head around this eventually lol, thanks for the help

jade glacier
#

You can see the bullets change color as they shift from white (shooters timeframe) to green (lerping into agreement with server) and red (in agreement with server)

midnight bane
#

Hey, So i am using Mirror for my networking and i have an issue.
The methods tagged with [Server] are throwing warnings on clients.

[Server] function 'System.Void Class::Method()' called when server was not active.

Why is this happening ?

AbilityBehaviour : NetworkBehaviour > https://hatebin.com/ddbqhailwa
Fireball : AbilityBehaviour > https://hatebin.com/aypjiqzbyk

i want server to handle it completely, but when i cast a fireball, all of them throws this warning.
Also i instantiate the fireball with in [Command]

oblique wolf
trail parrot
#

Hi, how do u do server side profiling?

#

I dont believe i can just input my server ip into the unity editor profiler, can i?

viral spire
#

is there something i am doing wrong why am i getting this error get this error when i run it on a vps. please @ me if you may know the reason why its unloading.

dense hedge
# jade glacier You can see the bullets change color as they shift from white (shooters timefram...

So I think I get it now.

Future                        Present                 Past
How clients see themselves    What the server sees    How clients see each other

Client A fires a bullet at Client B. This bullet is cosmetic and half-A-RTT in the future.
Half-A-RTT later, the server spawns the real bullet.
Half-A-RTT after update is sent, A gets it and interpolates its bullet backward by half-A-RTT.
Half-B-RTT after update is sent, B gets it and extrapolates its bullet forward by half-B-RTT.
(We account for interpolation delays too.)

Basically "meet in the middle" and have both clients observe the bullet near its "present" position.
Is this what you meant by align with the server?

#

And to lag-compensate on the server, it needs to "fast-forward" the bullet somehow (interpolating its velocity?) otherwise I'd have to keep looking at old snapshots of the world to check for impacts.

jade glacier
#

I would consider what the server sees as "Reality"

#

What the server sees is the only correct picture of how things are relative to one another.

#

All other clients see a mix of their future timeframe for their predicted objects, and "past" - which is the "Reality" of the server that gets to that player after the fact.

#

Sounds like you are thinking about it right

#

Client A fires a bullet at Client B. This bullet is cosmetic and half-A-RTT in the future.
You may be getting into the realm of where server shot rewind comes into play

#

for shooters, when a client predicts shots, you want them to hit what they think they hit, even though in reality they are missing like mad because they are shooting at the past. How games get around that is by having the server rewind the players and their targets in time to make a guess at what that shooter saw when they fired, and tests the shot against that.

#

The other alternative which is more risky in terms of cheating, is just trusting the shooter's hit claims.

#

The handling for slow movers like rockets will be different than hitscans for this reason

#

You can't timeshift to hide the paradox... its instantaneous with a very fast bullet or hitscan.

dense hedge
#

I understand that you can't avoid the paradox. Like, okay, for hitscan, compensating by rewinding all the hitboxes and doing the raytrace there in the past is the clear solution because you know if you hit something, the ray is instant.

But for a moving projectile, AFAIK the server can't tell when that will hit anything because stuff could happen later (another client jumps in the way or something).

That's why I'm asking about "fast-forwarding" the projectile on the server. You either rewind the world back or advance the moving object forward, but doing the former, i.e. waiting until the projectile hits something and then rewinding seems like it could playout incorrectly.

jade glacier
#

For slow movers I would just let the server run things normally

#

And you make the clients deal with trying to shift time as needed to make it cosmetically give the right info to players

#

So on the server, when it gets the fire command, it applies that on the appropriate simulation tick and just moves the projectile normally.

dense hedge
#

Is the "appropriate simulation tick" the tick of the fire command or a tick in the past?

jade glacier
#

I don't know what your system is.. how ever you consume inputs from players... just do that normally

#

Apply weapon fire the same way you apply movement inputs

analog venture
#

After a while, I got my movement system to work, with movement, jumping, and not being able to jump when you're in the air. However, the new problem is that no matter how much I change the gravity value, the character always falls down at a ridiculously slow rate. Did I do something stupid in my code?

Movement Script: https://hatebin.com/qtsgpgqaew

#

^^ Mirror, although I doubt that matters since I don't think the issue has anything to do with networking

slim ridge
#

that sounds like something in controller is clamping the velocity magnitude.
It probably doesn't help that you apply gravity twice.

analog venture
slim ridge
#

oh, i had another look and realized that

        if (groundedPlayer && up.y < 0)
        {
            up.y = -2f;
        }

is probably the culprit

slim ridge
#

it wont fall much faster than 2

#

cause it's -2 + (-15 * Time.deltaTime)

#

but... i have no idea how CharacterController works.

analog venture
#

Ohhhhh wait you might be right I'll have to experiment with that too wow you're much more attentive than I am ๐Ÿ˜‚

slow monolith
#

I just read a couple articles saying they sat down with network engineers who have worked on major games, that said you don't need to synchronize the ticks, the client just needs to send an update packet and the server needs to take it

#

this is so confusing

grim violet
#

do they explain what the server do when they needs to take it

slow monolith
#

I'm pretty sure it was for a first person shooter

#

I'm not sure though, read it before bed on my phone last night

#

I have the whole tick prediction system built for my client and it works, it just seems like a messy way of doing things

#

as opposed to just sending inputs every 0.02 seconds and having the server process it

#

but there's so many problems with the second option

dense hedge
#

> Why can't the client just send an update packet to the server every 0.02 seconds and not include the tick number?
Because then the server wouldn't know what tick an input is for?

#

If you send a sequence of packets across the Internet, some will get lost; some will arrive in the wrong order; some will even get duplicated.
If you send those packets completely unmarked, you can't expect the server to read them in the correct order. Given these problems, how is the server to know if an input is late, early, a duplicate, etc. unless you explicitly tell it "this input was for tick X"?

#

You're basically asking why mail packages need addresses on them to be delivered correctly.

slow monolith
#

So say the client lags and sends 20 messages all at once, and the server queues all of them up no matter what, and only executes every 0.02 seconds, now the client is permanently 20 ticks behind?

#

with my dumb no tick solution

#

I feel like I'm asking the same questions over and over, I just can't seem to grasp it

#

I feel like I'm close to understanding it though

grim violet
#

server itself is at a certain tick, if client is behind cause of lag all those packet would be ignored

slow monolith
#

Yes, but I'm talking about a no tick sync solution

#

where I was talking about just sending instructions every 0.02

grim violet
#

well it cant work

slow monolith
#

alright, that's all I need to hear

grim violet
#

thats good for certain behavior but yeah

#

not making a authoritative server

dense hedge
#

If the server just accepts inputs in any order whenever they arrive, your avatar won't move at all like you expect.

grim violet
#

if data doesnt matter the order it come by etc and its just a flow of perpertual numberrs like a GPS or whatever it doesnt really matter i guess

slow monolith
#

Well the last solution I built, the client would order his packets with a sequence number, and the server would just drop any packets behind the last confirmed sequence number

dense hedge
#

It wouldn't even know that those 20 messages were old.

slow monolith
#

to handle out of order packets

#

but yeah I see the massive problems now

grim violet
#

you still have an approximation on server if packet come in disorder

#

but its not perfect

slow monolith
#

My main concern, however, with the client predicting the server's tick, is that if he's too far infront of the server, then he'll have more ticks to process and more physics.simulate events to call during client reconciliation

#

maybe I'm just overthinking it

floral turtle
slow monolith
#

Roystan, you know a lot about this stuff, my game is going to be fast-paced first person, I should use tick synchronization, right?

floral turtle
#

I would definitely defer to erick and emotiton, they both write networking libraries and have probably encountered a much wider variety of use cases

dense hedge
slow monolith
#

@gleaming prawn @jade glacier Just gonna leave these here. Trying to decide whether to synchronize the ticks, or just have the client send instructions every 0.02 seconds and the server processes them no matter what (as long as the sequence numbers aren't out of order) trying not to screw myself for the future of my game and you guys know a lot about this stuff.

#

@dense hedge Exactly, but if my client is predicting the next server's tick too far into the future, that's going to mean more of a gap that I'm going to have to reconciliate through

#

which means more stress on the client for however long that is

#

my players also move with rigidbodies, which means I might have to reconciliate pretty often

#

I'm not talking about seconds btw

#

like 10-15 ticks max

grim violet
#

how can the client be too far ahead

dense hedge
#

So like a really bad ping is like what 300ms? That would translate to around a ~10 frame lead @60Hz updates.

#

I think the only time a client would be that far ahead is like when the game first starts.

slow monolith
#

@grim violet Well the client has to predict which tick the server is on, correct?

grim violet
#

if the server dont get the response from the client, its not processed

#

only that client will see himself ahead

#

wont do much

#

you can still use the timestmpa on server of any of his action and know whats going on

#

if hes too far ahead (lagging bad), disconnect him

#

thats it

#

;p

slow monolith
#

this is such an anxiety producing brainfuck

grim violet
#

are you using timestamp from client

#

to send to server

slow monolith
#

For right now I'm using a whole tick synchronization system. So my server sends UTC timestamp of packet send, client gets it, finds the difference

#

calculates how many ticks have been processed

#

sets his tick to that

#

and then predicts which tick the server will be at by the time his packet reaches the server

grim violet
#

erm

slow monolith
#

That's literally what unity does for their FPS sample

jade glacier
#

yeah, typically your buffer offset is determined by the RTT you have gotten so far

#

And then you need mechanisms for that to correct, to shave or grow that if that guess turned out to be very bad.

#

Its the same mechanism that is in place for clock drift and changes in internet quality/stability... so one system for adjusting your buffers should work for all of these issues.

slow monolith
#

So, for my first person real time game, I'm going to need to use this tick synchonization system? I can't just send client packets every 0.02 seconds and hope the server gets them?

#

That's basically my question out of all of this

jade glacier
#

Are you predicting on your client?

slow monolith
#

yes

jade glacier
#

Then be ready for some harsh correction in adverse internet conditions if you aren't managing your buffer size

grim violet
#

nose bleed

slow monolith
#

So say the client lags and sends 20 messages at once (the problem I was actually experiencing)

#

that's what you're talking about?

jade glacier
#

That's a pretty extreme problem

#

I can't say really, we are talking in very vague terms. The answer is "how you coded your system to deal with this"

#

The answer to how your system will deal with this stuff... is how you coded your system to deal with this stuff.

slow monolith
#

My system didn't deal with it, when it was implemented, the buffer size just kept growing

#

so it is feasable though?

#

to not have tick sync?

jade glacier
#

The server should be consuming at a fixed .02 as you described it.

slow monolith
#

yep

jade glacier
#

No exceptions there

#

If a tick fails to arrive, it has to extrapolate one.

slow monolith
#

or just doesn't do anything for that tick, like unity did for their FPS

jade glacier
#

If a tick fails to arrive, it extrapolates one.

slow monolith
#

alright

jade glacier
#

In some form

#

either reusing the last one, or using default values.

#

The server ticks at .02.... NO MATTER WHAT.

slow monolith
#

yep

dusky zenith
#

does anyone know darkrift 2?

jade glacier
#

Then I don't get what you mean by "or just doesn't do anything for that tick"

dusky zenith
#

is it good?

jade glacier
#

It ALWAYS does something... it simulates.

dusky zenith
#

guys

slow monolith
#

but if it doesn't have any data for that tick, it would have nothing to simulate

dusky zenith
#

is darkrift 2 good

slow monolith
#

@dusky zenith Homie, you're in networking channel

grim violet
#

we dont know what that is and if its a game just google it

jade glacier
#

If no one is answering, then noone is around with experience enough to answer @dusky zenith

#

Simulation doesn't work like that.

#

there is no such thing as "no input"... you can have "default" input

#

or "use the previous input again" input.

#

But your simulation is going to fire.

slow monolith
#

Correct, but for unity's FPS, if they missed a tick, they just "do nothing" for that tick

jade glacier
#

I have no concept of what "do nothing" means in this context sorry

slow monolith
#

no input. standing still

jade glacier
#

The server always has something to do

#

then default input

slow monolith
#

correct

jade glacier
#

That is different than "do nothing"

slow monolith
#

alright

jade glacier
#

That is also a bad practice, but I don't think they do that.

#

if the player was holding down the W key running, and a tick goes missing... it is safer to assume that W is still down, than to assume they let go of all keys for that step

slow monolith
#

But if I'm just sending packets every 0.02 seconds without synchronizing the ticks, how does the server know that the client missed a tick? Does the client just send sequence numbers?

jade glacier
#

That is what extrapolation refers to.. reconstructing missing inputs or states

#

You should be numbering your ticks, for that reason.

#

you will throw your system into massive desync constantly

slow monolith
#

So if you were making this game, YOU (and probably erick too) would synchronize the client/server ticks?

#

just based off experience?

#

I'm trying to do this as correct as possible

grim violet
#

best way to know is to test ;p

slow monolith
#

It just feels like I'm doing this wrong with whatever path I take

#

anxiety is always 100%

#

all I want is a definitive answer from a smart person to tell me which path to take

#

Because when I wasn't doing tick synchro, it worked literally perfectly fine until I alt tabbed the client and he lagged and started sending messages when he shouldn't

grim violet
#

cant you stop sending message when application lose focus?

slow monolith
#

well the problem is fixedupdate, it stops sending messages then it tries (pretty awfully) to catch up with the current time

#

and fires a bunch of fixedupdates all at once for however long it was frozen for

#

at least that's what I've concluded from my tests

grim violet
#

why use fixedupdate to send stuff?

slow monolith
#

Just thought that was correct, since my players move with fixedupdate

#

then the packet gets sent at the end of all of that

grim violet
#

just gotta find a way to make it stop packaging em all

slow monolith
#

I could just flush the buffer once it gets too big like someone suggested

#

I just feel like I'm going to run into more issues

jade glacier
#

You are in the deep end of networking with this stuff, cheap and dirty fixes generally are going to be more trouble than help.

#

You just need to work up a mechanism for properly consuming your buffer so that it can dynamically adjust in size.

dense hedge
#

It sounds like the issue you ran into was that you started out synced properly, then your client stopped sending messages when you ALT+TAB or dragged the window, which messed up the pacing (client fell way behind the server), then when you came back there was no mechanism to correct that.

jade glacier
#

There should be two buffers in question here, or buffer timings at least.

#

There is the input buffers on the server, where the server buffers inputs to make sure they have enough time to arrive before simulating.

And then there are the state buffers on the client, which has to be big enough to give the server traffic time to arrive before the client moves to the next rendered tick.

#

There is a third buffer, but its timing doesn't matter... that is just your prediction state record, which you keep on the client to compare against the servers state - to check for desyncs.

#

Systems will vary from dev to dev, but those are the buffers you are managing.

slow monolith
#

Emoti, you have to tell me which method you're talking about here. Tick synchronization or just standard input forwarding

#

I'm not sure what you mean by the server's input buffer. If the client sends his command to the server, it's going to be processed during the next tick no matter what. Obviously there will be a buffer, but it's only going to need to havea max size of 2-3 inputs with my current tickrate

#

at least that's what I'm trying to aim for

#

During my testing without tick synchronization, the server's input buffer for each client would only have about 3 inputs in it maximum, until I alt tabbed and the lag occurred

#

Hopefully erick can give his input on this a bit later

slow monolith
#

I suppose instead of just clearing the entire input buffer if it exceeds 4, I could just remove index 0 and add the next one into it, etc

#

If that's what you're talking about for a consuming mechanism

dense hedge
#

Both the server and client will consume packets at an orderly fixed-rate. But any time expected packets are missing, the server or client will extrapolate from previous one it used.

On the server, if any client's input for a tick is missing when the server goes to simulate it, the server will just reuse that client's previous input. On the client, whenever it doesn't have a new snapshot to interpolate towards, it'll just extrapolate from the last snapshot it used.

Inputs can arrive to the server early, the server just puts them in a queue. If an input arrives to the server N ticks early, it will sit in that queue for N ticks, which translates to N ticks of additional latency on top of the raw RTT.

For the client, server updates don't make it through the Internet in an orderly, fixed-rate fashion. Because extrapolating other entities doesn't look as smooth as interpolating, the client wants to be interpolating most of the time, so the client will actually hold snapshots in the queue for several ticks on purpose before consuming them, just so it likely won't have to extrapolate.

#

The buffer on the server is per-client and its size is mostly related to how early that client is sending its input.

#

The buffer on the client is mostly related to network jitter.

slow monolith
#

That's the thing. In my standard input forwarding (without tick synchro) the server is going to have no idea if it missed a tick from a client

#

since it's just consuming the latest received packet from the client

dense hedge
#

yeah, your model is not the usual

slow monolith
#

I do have sequence numbers though, so out of order packets get dropped

#

if the sequence number is less than the last confirmed number, it gets dropped

dense hedge
#

If an input packet is lost in transit, the server should re-use the previous one. "Player probably kept doing what they were doing last frame" is usually way more accurate than "player did not do anything this frame".

slow monolith
#

alright

slow monolith
#

If my client packets are like 2-3 ticks ahead of the server by the time it gets there, is that too much?

#

Or is that a good prediction?

dense hedge
#

The optimal ahead amount depends mostly on ping. If you had a magical 1ms ping connection to some server, you would only need to be 1 frame ahead.

dense hedge
#

Also, I've been wanting to say that "tick synchronization" isn't some kind of separate, tacked-on idea. AFAIK it's a fundamental part of making multiplayer responsive and making it "fair" without lockstep.

Tick numbers are basically special-purpose sequence numbers. We use them because prediction/rollback and lag compensation need some kind mapping from input to applied tick.

A clients sends an input with a number and the server sends back an update with the same number. Ticks are intrinsically synchronized between clients because the server sends the same update to everybody. The tick numbers on two clients don't have to literally match. Maybe a client joined the session late. It's a tiny implementation detail whether you set a newly connected client's tick number to 546 because that's what the server's is or if you start the client at 0 and have the server remember to subtract 546 when it sends them a packet.

jade glacier
#

I personally use the offset method for my stuff, but it isn't required.

#

For example when a client connects it sends tick 1, and if the server is on tick 200, it will determine that that clients tick 1 should be applied to the servers tick 203... so it notes the offset as being +202 for the client.

#

Though that is a little more complicated than that, if you wrap your numbers for a ring buffer - which I do.

slow monolith
#

This is so confusing

#

The only reason I'm syncing my tick with the server in the first place, is literally because the client lags/freezes when alt tabbing the game and gets out of sync with the server

#

I still don't know if I'm on the right path

jade glacier
#

Unity is set to run in background?

slow monolith
#

Whenever you alt tab it like freezes the main thread for some reason

#

also if you drag the headless server application around, that also freezes the server's thread and causes the same complications

jade glacier
#

Lots of things hang it, like dragging the window, but unless its super prolonged, fixedUpdate will rush to catch up

slow monolith
#

it doesn't seem to catch up precisely

#

it tries to catch up

#

but doesn't do it accurately

jade glacier
#

Fixed has a finite number of updates it will run to catch up, so you may need to sniff out the tick count vs elapsed time to see if Unity decided to not run all the fixed updates

slow monolith
#

regardless, when fixedupdate tries to catch up, it does it all in a single update frame (I think), so like 30 packets get sent at once

jade glacier
#

I am not sure if Time.timeAsDouble keeps on trucking or not in those cases, but that would be the first thing to check

#

That may happen yeah, and your buffers should be able to make that work out.

#

Most of those updates will be too late to the server, and it will just not use them.

#

But if you are still keeping too time with your tick, they should still be in agreement

slow monolith
#

You're still talking about having the client synced to the server's tickrate right?

#

yeah

jade glacier
#

I have no idea what synced means in this context

slow monolith
#

client connects, server sends current server tick, client works out the latency and applies added ticks

jade glacier
#

You want to make sure they have consumed the same number of ticks as expected

#

if you are 50 ticks a second... and you hang your app for a second, you want to make sure that when it resumes it is 50 ticks later... whether or not it sends any of those missing ticks

slow monolith
#

But for the server to realize that those ticks are in the past, the client needs to be on the same tick as the server

jade glacier
#

or you have an offset, whatever mechanism you use

slow monolith
#

alright.

jade glacier
#

The two have to keep consuming at that fixed rate, no matter what.

slow monolith
#

Correct, that's not the part I'm confused about

jade glacier
#

If the app hangs for whatever reason, you need to make sure it picks up in the right place.

slow monolith
#

it's just when the client sends the 50 updates after he freezes to catch up, the server thinks all of this ticks are still relevent

#

and applies them into the buffer

#

which is why I now have them synced

#

so it doesn't do that anymore

jade glacier
#

Why would it think they are relevant?

#

It will see them all as being late

#

and will have already run the sim with the extrapolated values

slow monolith
#

I'm talking about the last iteration of my server, where the client starts at tick 0 no matter what

jade glacier
#

Not sure that is related to this

slow monolith
#

In the last iteration of my server model, the client would literally just send update packets, and the server would process them no matter what

jade glacier
#

if at 20 seconds in the server is applying tick 100 from the client.., at 25 seconds in it will want to be consuming tick 350

slow monolith
#

so when the 50 update packets came in at once, the server would think that ALL of those were still relevent

#

hopefully that clears it up

jade glacier
#

That's going to be a problem

slow monolith
#

yeah

jade glacier
#

For all of the reasons discussed here

slow monolith
#

yep thats why I made my client sync to the server's tick

#

seems to work fine now

jade glacier
#

Consume and generate ticks... at the same rate... all the time... no matter what.

slow monolith
#

I just wanted to make sure I'm doing it right

jade glacier
#

If the client stops running for whatever reason and Unity fails to run the right number of fixedupdates... you will have to determine how much it borked things up, and advance the clients tick number.

slow monolith
#

So when my client first connects to the server, the server sends him a UTC timestamped packet (of when it was sent), plus the user's session ID (irrelevent for this), and the server's tick. If 100ms passed and ticks occur every 20ms, we can predict that 5 ticks have passed since that value, right?

#

^ that is essentially what I do

#

then it does the same prediction for packets on the way to the server, so it sends them a little bit ahead of the server

jade glacier
#

As long as that gets you the right starting alignment, then sure.. that works.

slow monolith
#

alright

jade glacier
#

First step to fixing this, I would establish what Unity is doing to bork you. If it is dropping FixedUpdates you either have to advance your clients tickcount to compensate for the loss, or you will have to make a hard realignment option with the server.

#

You can detect that case on the client, because the server will be sending back tick results for ticks the client hasn't even run yet.

#

The server sending the client ticks before that client has run them should raise a flag that things are very wrong.

slow monolith
#

I think proper tick synchro should fix it

#

because if the server knows that it's getting late ticks, it just tells the client to resync

#

right?

#

I'm like halfway done building it, but my server does now properly detect late ticks

jade glacier
#

seems workable

#

Though the client really doesn't have much to do in that equation, the client already should be trying to hard adjust to keep the state buffer right.

#

The server in this case just needs to re-adjust its offset value

slow monolith
#

yeah Im probably going to implement a rolling average for him to adjust to

#

automatically

#

The server doesn't handle any of the offsetting on my end though, it's all on the client to get the packets in on time

#

is that bad?

jade glacier
#

Just a choice, if that is how you align it, then the client will need to correct yeah.

slow monolith
#

alright

quasi topaz
#

I'm making online game with Photon I made the online system, but there is a mistake, we cannot see the people entering the room before us, but we can see those who enter after us, what should I do?

jade glacier
#

@quasi topaz Impossible to say without knowing what your code is, and how your components/prefabs are set up. You also have to be clear on what "see the people" means. If every player is calling PhotonNetwork.Instantiate() in OnJoinedRoom, that should be getting replicated.

severe pollen
#

are questions about mirror fine there?

timber elbow
#

any devs out there not working on a project looking for a paid gig?

#

or is this the wrong definition of "networking" lol

weak plinth
#

This means connectivity between game clients/servers via internet or otherwise network

weak plinth
#

Does someone know how to instantiate players at different spawnpoints? (Photon)

shut yarrow
#

Has little to do with Photon. If you want to prevent players spawning at the same spawnpoint, then you should keep track of who spawned where, and pick a different spawnpoint from a list of possible positions

jade glacier
#

Either the player needs to do an overlapSphere test on the starting points to find a free one, or the master should, and then instantiate.

dense hedge
#

Hey @graceful zephyr, thanks for recording your Twitch streams. I just finished watching the most recent one. Will you be doing another stream soon? Really interested to learn about dynamic interpolation delay.

graceful zephyr
#

@dense hedge I'll try to do some soon again

#

Been very busy with work/family lately

dense hedge
#

totally understandable, looking forward to when you get the chance

graceful zephyr
#

@dense hedge I Will stream tomorrow (7th feb, 9PM CET)

#

time to start up again

#

(unitys bot here deletes discord invite links for some reason)

dense hedge
#

awesome! thanks

jade glacier
#

Ah, smart way to share the discord links. I'm stealing that. @graceful zephyr

civic cave
#

Hello! I just have a quick simple question. Is there a free reliable way to do multiplayer? whether it's lan or over servers, just any free way :)

#

I have heard of unet

#

from what I can tell it's free but then it says that unity multiplayer service is not

#

so I was wondering if you need unity multiplayer service in order to use unet

#

and if you do and it cannot be done for free this way, is there a different free way to do this?

jade glacier
#

Pun2 and Mirror are the most popular starting points. Free is relative when it comes to networking, since someone is going to end up hosting something, and that is never free. The only possible exception might be if you do relay through steam using Mirror.

#

Unet is long deprecated. MLAPI will be the closest thing. Mirror is a fork of the old Unet that has been expanded on.

civic cave
#

@jade glacier would it be free if someone hosted it on their laptop? like a lan?

jade glacier
#

Mirror would be free for that yes.

civic cave
#

thank you so much!

jade glacier
#

Be sure to join their discord

civic cave
gray pond
trail parrot
#

Hi Gadget-san! Working hard i see

weak plinth
timber spruce
#

is multiplayer free in unity?

fleet violet
# timber spruce is multiplayer free in unity?

Multiplayer is whatever you call or implement as multiplayer, so yes. If you mean a unity-provided all-purpose multiplayer library/integration, still yes, although there's currently not really an officially supported one; they recently posted about aquiring a youngster's github project as new multiplayer stack, that will be free too. If you mean hosting your server, then probably no.

patent fog
#

Hosting a server, def not free. Can be as cheap as a few bucks per month to begin with.
But being as new you begin with local multiplayer before thinking online ๐Ÿ™‚

graceful zephyr
grim violet
#

hey guys got a question

#

my server log is getting spammed with stuff like this

#

what is that?

#

ive been looking at it since a few days and it just doesnt stop

#

different ip all the time

#

tryed to google but people seem more clueless than anything

fair cosmos
#

PunFish is live

#

Teaching Mirror Networking live ๐Ÿ™‚

patent fog
# grim violet

Looks like random DNS lookups by bots. Though on ANY... people are savage nowadays ๐Ÿ˜›
I'd say nevermind, your firewall denied them.

#

You might also get spammed on your ssh port, or inexisting URLs on your web root and such...

#

Don't bother as long as you catch them that's good sign.

#

Just hope it doesn't hold too much resources on your serv

grim violet
#

its just spamming my syslog like crazy

#

they do it for hours 5 time a second

patent fog
#

for how many days ?

grim violet
#

about 4-5 different ip every time

#

i was thinking of banning them with something like fail2ban but then if they start spoofing i could ban legit people

#

so thats a no

patent fog
#

you could blacklist them after x attempt from same ip

grim violet
#

gonna try to disable the logging

patent fog
#

okay

#

you could also match & redirect the query to another file

#

to keep syslog clean

#

๐Ÿคทโ€โ™‚๏ธ

grim violet
#

yeah im just a noob with the logging stuff lol gonna learn how to do this things

patent fog
#

or client app*

grim violet
#

yeah clearly spam

#

oh you mean the ban

patent fog
#

Maybe legit services could do

#

not as spammy though ^^

grim violet
#

those attacker if they get blocked they can spoof the ip and get other people blocked for no reasons

grim violet
#

thats what ive read from google

#

thats why i dont want to ban them, they always changing ip

#

and its all from usa for some reasons

patent fog
#

yeah if they somehow monitor and don't brainless spam, and they wanna make you lose your time, definitely

#

alright I'd just handle the logs to another file and keep going with my day as long as it doens't put your server on his knees

grim violet
#

not yet lol

#

i dont have much traffic on my site as its not publicised yet so

#

but look at the logs

patent fog
#

Linux ? Looks like you already have a time rotation, that's good

#

2MB is not scary for me

#

but I didn't managed dedicated servs for a loooong time

#

You're afraid it explodes when you go public ?

#

I'd wait and see at that time and move on

grim violet
#

im gonna write down all the ip in a list they seem to come back often

#

if its always the same it will be an easy fix

#

seem to be some botnet, its often a single ip attacking 5 time a second every there and then over a period of an hour, or its multiple people attacking 5 time together a second for that multiple hours

#

it never goes over 5 a sec

#

anyway, at least i know its not dangerous for now

#

lol

patent fog
#

yeah honestly, 5 times a sec every now and then is nothing

#

doesn't deserve sucking so much of your time

#

just keep an eye on it 'till the end of the week before doing anything

weak plinth
#

It's pretty normal to have bots "ping" your server in various ways

#

To find holes in your firewall, to bruteforce admin logins etc

patent fog
#

yup

grim violet
#

i banned china and russia from iptables lol

#

im so fed up of those spams

weak plinth
#

gg to anyone from those regions that want to use your service

patent fog
#

or vpn users ๐Ÿ™‚

grim violet
#

they can vpn

#

or ask me to unban i will for their own ip but yeah lol

#

too many spam from those country

#

but now its usa doing it ;p

#

out of no where

weak plinth
#

Contact the host and tell them to do something about it

#

Or if it's privately hosted, install one of many available software that handles these things

graceful zephyr
strong axle
#

Im using mirror and i have am using this code

public GameObject p1;
public GameObject p2;
[SerializeField] NetworkManager NM;
    public void JoinGame()
    {
        NM.playerPrefab = p1;
        NM.StartClient();
        
    }

    public void HostGame()
    {
        NM.playerPrefab = p2;
        NM.StartHost();
    }

When i host the server and get the client to join it brings a warning
Replacing existing prefab with assetId '1c32ce8f-2c14-9794-bbb2-7a5aab8fcf4f'. Old prefab 'P2Online', New prefab 'P2Online'
and the players only update for the client. if the client moves it doesnt show anything on the host screen but if the host move it updates on the clients screen to match the host screen.

crimson saffron
alpine pivot
alpine pivot
crimson saffron
#

ok yeah, sounds good! thank you, i will try : )

patent fog
# strong axle Im using mirror and i have am using this code ```cs public GameObject p1; public...

I don't use Mirror but are you sure you can set the playerPrefab property like that ? Aren't you supposed to call a method to grant client ownership on a gameobject to switch authority (available on a list of previously declared network objects) ??? I would check the doc for that, or they prob have a tutorial to explain how to change ownership via code.
Or even use the same prefab for host and client and check isLocalPlayer or something to handle the differences, would they be tiny.

weak plinth
trail parrot
#

U need to use SpawnPlayerForConnection to set it as the client's player object

#

If its a prefab and not instantiated yet, then it needs to be instantiated first, server side

#

If its already network spawned, then u use SetAuthority

dense crystal
#

Is it normal for a website, like Microsoft to block requests after you send enough requests for the time?

#

I made a Fortnite-style live event countdown that gets the time from www.microsoft.com when the project starts, then uses it as a base to count down to the event. After enough time, it stopped getting the time, but then worked again once I switched to www.google.com.

patent fog
#

Yeah sure if you spam them they gonna blacklist your IP

#

Why don't you get the time from the system ?

lapis vapor
#

Guys, I'm making a carrom game multiplayer with Photon, I'm syncing player positions and velocities using Photonnegtwork.raiseevent. It is working fine, but issues happening when syncing positions if my network is unstable. Guys, is there a way that we can sync the key position, something like holding raiseevent and raise it once the network is stable?

grim violet
#

what mean stable? no disconnect?

#

you shouldnt have to hold any raisevent

quaint hull
#

Does a Peer to peer game still require a central server to connect/find each player?

grim violet
#

no

#

if you want to save friends or stuff online thought you would need a server

#

but connecting and finding player in same lobby is possible, matchmaking

jade glacier
#

P2P is a poor term really, and is problematic when talking about MP games.

#

P2P typically implies clients all interconnecting directly to one another, which is super rare in gaming. There is almost always a server. It just may be a relay server, or that server might be a client listen server (a player that is acting as the server).

#

So when people say P2P they really typically mean either mean that a player is acting as the server, or all players are connected via a relay server.

#

In which case, be sure to indicate which you mean.

#

@quaint hull

quaint hull
jade glacier
#

how though? How are they connected?

quaint hull
jade glacier
#

You need a server of some kind to get started yes.

quaint hull
#

yeah that was my question thx

#

Although json isn't resource intensive compared to tcp so it shouldn't really be an issue

jade glacier
#

With relay like Photon Pun, you start by connecting to the master server, and then that directs you to a game relay server. For mirror you would need a matchmaking server as well, and then a server to handle punchthrough if you want a player to serve

#

no idea what you are using json for or why, but that is a separate conversation

quaint hull
#

I don't need to send tcp packets, text works just fine

jade glacier
#

Too much to unpack here, so I won't get into that.

#

I would start by doing a tutorial for Mirror and Pun2... unless your game is completely turn based, then look into a cloud service of some kind.

#

Don't start by trying to make your game. Your first networking attempts will be a complete mess and likely failures. Start with tutorials and basic tests to get your head around the options and concepts.

quaint hull
#

Dude i'm making an airport traffic controller game where players can send aircraft to each other. That doesn't need tcp/udp packets because its not a lot of constant data

#

Simple GET and POST requests to the server works fine but I was wondering if it was possible serverless (aka P2P).

#

But what you just told me is that I need a server to connect the players together in the first place anyway

jade glacier
#

If you are doing this as a web application like that, totally different animal.

quaint hull
#

Last time I checked GET and POST requests are in the networking category so...

jade glacier
#

That is more of a cloud scenerio, do it like its a webpage.

quaint hull
#

I'm just going to use Python backend on a webserver, because P2P will require a server anyway

jade glacier
#

Not typically the kind of networking convo here, usually this is more about realtime state synchronization. P2P is still not the right convo in that case.

#

But sounds like you have some ideas you want to try, so go for it.

quaint hull
jade glacier
#

Sure. I am not the right person to answer. What you are doing is a bit out of the usual for this channel. I'll just skip out of this convo.

quaint hull
#

Your good tho, you've already answered my question about P2P

trail parrot
#

Get post.. rest?
U use unitywebrequest for that

#

Technically thats still networking i guess. Those stuff are under unityengine.networking namespace after all

lapis vapor
#

so for that any method available?

dim merlin
#

I've never had to make a network architecture for a turn based card game before but I will Soonโ„ข๏ธ
My first thought was REST API, full server authority, simulated games, sort of setup. Are there better/different ways?

weak plinth
#

"Simulated games" ?

dim merlin
#

Well, have the server simulate the game before authorising a move

#

I am not sure if I used the right terminology

weak plinth
#

With no-sim games like those

#

You can input the action on the client and server

#

And rollback the client if the server says so

#

Forward the message to the other client if the server "accepts" it

#

But no idea how you want to do that through a rest api

#

Websockets, or?

#

You need full duplex

dim merlin
#

Hm okay. I was just thinking the clients send messages to the server and then check every x tick for updates

#

Seeing as it's turn based events visuals and whatnot won't have to happen exactly simultaneously on both ends right?

gleaming prawn
#

I've done turn based on a rest-api before... It's a good enough approach

#

Has its pros and cons

#

If you are confident and experienced on the backend stack you plan to use, it's a good approach for slow paced turn based...

#

periodic polling is OK-ish, but if you could have duplex comm to notify of changes would be even better.,

weak plinth
dim merlin
#

My experience with net sockets just seem to indicate that scaling is much more expensive computationally. But maybe I'm just wrong there?

#

And are sockets similarly platform agnostic?

weak plinth
#

I think the .Net Sockets are platform agnostic, but I'm not 100% sure on that one

dim merlin
#

Ah okay. I'm most familiar with C# so would be nice to use that. I could probably also use node.js if I wanted to

weak plinth
#

There's also the option for IOCP with .Net Sockets, but I've never tried that

#

That's apparently for "highly-scalable" TCP servers according to Microsoft

#

No clue how well that works with Unity and IL2CPP

dim merlin
#

Right

weak plinth
#

But that's for the server side, and that wouldn't need to be Unity anyway

#

I would look into setting up a websocket in Unity. There's probably people who did that before

shut yarrow
#

If you want to do that from scratch look into the websocket specification

weak plinth
#

Since you have free roam over the server-side anyway

#

Might as well use .Net5.0

shut yarrow
#

It uses 'normal' sockets with a modified protocol

weak plinth
#

Cross-platform and plenty of choice of ways to solve your problem

dim merlin
#

So n players queue up for a game. They have a socket established with a server.
The server now tries to match players.
It makes a match and two players are notified of this. The clients transition to some sort of battle scene while sending a token to a different server program that sets up the battle and manages the session.
The server already knows what decks the players use as they queued up with those decks.
The clients are given data equivalent to a starting hand.
The game starts.

Does that sound right?

shut yarrow
#

.net sockets are platform agnostic though

weak plinth
shut yarrow
#

Yes

#

I don't think IL2CPP changes anything about the actual .NET implementation of sockets

weak plinth
#

Well, it has to

#

Since it uses winsock by default

shut yarrow
#

I've made both windows and linux clients with .NET sockets, they use same codebase

#

On windows it'll use winsock most likely, but that's a lower layer you don't have to worry about

weak plinth
#

I know, but I'm saying that it has to change the implementation somewhere

#

To not use WinSock

shut yarrow
#

Why would that matter

#

The low level implementation is different, but you don't use that directly anyway

weak plinth
#

Because if it didn't, it would only work on platforms that use or support winsock

#

Which is the entire point of the question

shut yarrow
#

I have a server running on linux, the clients are linux and windows. Both clients can connect perfectly fine

#

Only thing that really matters is what socket protocol you use, whether that is TCP or UDP, it doesn't matter what underlying socket library is being used because it'll support both protocols

weak plinth
#

If I write my own C++ socket implementation using winsock and use that in Unity

#

Pretty sure it's not going to work on most platforms, even though it is tcp or udp

shut yarrow
#

If you insist on writing it in C++ then yes, you're on your own

#

You intend on using UDP?

weak plinth
#

Depends on the game

shut yarrow
weak plinth
#

I know of ENet

shut yarrow
#

Written in C and has C# wrapper already

#

Why reinvent the wheel ๐Ÿ˜›

weak plinth
#

Just wondering how far that platform support stretches

shut yarrow
#

ENet supports all 3 major platforms

weak plinth
#

Yes, that's what it says on GitHub

#

But that doesn't answer the question how far that exactly stretches

dim merlin
#

For a card game I'd expect TCP

#

It's turn based so waiting should be fine

shut yarrow
#

Well define exactly

weak plinth
#

If you open the list of possible platforms to build for in Unity

shut yarrow
#

It supports windows/linux/macos and that's it

weak plinth
#

Expected as much

shut yarrow
#

No mobile as far I know

dim merlin
#

So how would you handle sockets on phones?

#

Native web version?

weak plinth
#

Using the .Net sockets then

#

I would assume

shut yarrow
#

I can't say with certainty but I think iOS and android support unix sockets

dim merlin
#

They are both Unix based right?

shut yarrow
#

Yes

dim merlin
#

So it would stand to reason

weak plinth
#

The biggest problem are consoles

#

Since they are black boxes

shut yarrow
#

At least I assume they both are unix based ๐Ÿ˜›

dim merlin
#

I could see iOS have some Apple fuckery but other than that

weak plinth
#

The "problem" arises from using .Net Sockets on a high-traffic server

shut yarrow
#

I doubt consoles do sockets very different

weak plinth
#

It's no problem at all to use them for a client

dim merlin
#

I wouldn't care about consoles for this particular usecase

weak plinth
#

Just use what .Net has to offer ยฏ_(ใƒ„)_/ยฏ

#

That's most guaranteed to be supported

shut yarrow
#

Probably .net itself isn't the problem, more likely how you allocate resources

dim merlin
#

Though if I need to support n card games at a time then what would be a good scalable solution?

weak plinth
#

The .Net Socket implementation isn't particularly good though....

#

At least, not the one we can use in Unity

#

@dim merlin Again, just use .Net

dim merlin
#

Mkay

weak plinth
#

Your server shouldn't be Unity for a card game

#

It doesn't need to be

shut yarrow
#

Well trying to support many platforms is like opening a can of worms

dim merlin
#

Well no

#

The server just needs data not unity components

shut yarrow
#

OmniOwl is right though, server doesn't even have to be C#

dim merlin
#

There shouldn't be a shred of unity in the server client

shut yarrow
#

That's where you actually have more choice

dim merlin
#

That's why I asked for agnostic tech

weak plinth
#

Well, tell me what a good, high performance cross platform language is

#

Which is easy to work with as well

dim merlin
#

Unity is unity. That will be the client side so I'm settled there

weak plinth
#

You can also use C++ then ยฏ_(ใƒ„)_/ยฏ

#

C# is just a whole lot more programmer friendly

shut yarrow
#

Sounds like music to me

weak plinth
humble holly
#

I need some help, I made a raycast gun script and everything works fine, except that I still need to make it work with PUN 2. What I have so far is just the base code, I haven't really added any networking to it, and I would like guidance in doing so since I have no idea what I'm doing; Here's the script;

humble holly
#

well this is definently an active server

grim violet
#

should start by doing the tutorials of pun2 to test out the stuff

#

there is alot to it

candid dagger
#

i have no errors, players just cant see other player names & only see DEFAULT USERNAME. its like the first player that joins has a name that works and the second player can see it, but the first player cant see the second player's name and all it says is "DEFAULT USERNAME"

candid dagger
#

halp me

merry sigil
#

sorry networking is a really specific area that not every specialises in

#

i don't have a clue about it

candid dagger
#

oh ok

#

im not sure if my problem is even networking cuz its just not diplaying stuff properly

#

do you know any other places where i can get help?

merry sigil
#

there might be other discords and forums that are specifically for networking but not anything specific

candid dagger
#

ok

#

thx

grim violet
#

well you are sending a rpc in update

#

that mean its gonna be sent 60 time a second, very bad

#

nickname should be set before connecting

proven topaz
#

Hey qick question so ive been using photon pun 2 in my game, I can load people into the main menu lobby perfectly fine but when i launch the game and both players are instantiated into the scene they can't see eachother anyone know why?

grim violet
#

probably in different region

#

you can specify one in the photon setting

proven topaz
#

Okay thanks i'll check it out and see

candid dagger
grim violet
#

before joining a room i mean

candid dagger
#

would i have to recode it all?

grim violet
#

no

weak plinth
#

Is there an easy way to create/apply an input to a simulation using the "new" input system?

#

Or does it still boil down to a bunch of if-statements

golden rain
#

I am new to Networking and PUN and i am facing a problem using RPCs. I have game in which you and the opponent throw discs towards middle to a target and when disc counts of both players are 0 the game calculates the scores and a game over UI gets activated. I cannot seem to successfully set player1Score and player2Score variables on my Game Manager script. I am trying to use an RPC method to set these variables from its respective Player Manager scripts and i have tried all the RpcTargets with no advancement. If somebody could help me i would be very happy.
Edit: it is photon2

sleek laurel
#

can someone explain to me why this only works for the master client? im using photon pun 2 btw

plain brook
#

Anyone try one of the MMO systems?

slow monolith
#

So when my client presses E to use an object and raycasts to it (like pressing E to enter a car), should the server also "press E" and raycast to it, to see if the user can actually enter the car

#

or should the server just check if the player is in the proximity of the car when the player requests to enter it, if so, let him get in?

high night
#

@slow monolith id take the second

#

a little delay before entering the car would make sense

#

i think pretty much all games to it that way

#

i am not sure how you are going to do it

#

but id just design the system so the remote character is controlled by my keyboard and nothing else

#

so it wouldnt be like client sending a "vehicle embark request"

#

it would be a natural result of servers character looking at right direction amd pressing E the right time

jade glacier
#

Anything you can avoid predicting, I would.

#

cleaning up missed predictions is always a pain. if it doesn't need immediate feedback, leave it fully server auth without prediction.

#

You can hint to interactions, like trigger an animation or something that indicates your click registered.

high night
#

let me ask something i was wondering,
are there networking approaches that involve sending states sparsely?

If my game simulation is 50hz or 50 ticks per second, is it a good idea to be sending 1 out of 5 ticks to save bandwidth?

I did something like that before with my previous approach, but it gets complicated to produce what happened between the synced frames

#

Im talking about a fixed timestep tick based system, something you can run predictions on

jade glacier
#

Most systems do some form of delta check, and only send updates when things change. But it is not super basic (unless you are using a reliable transport) because you had to factor in the need to resend and such.

#

You can send Every X as well though sure, if you design for that.

#

Typically for that you work with multiples

#

so if you sim at 60hz, you might have a net rate of 20hz, by sending every third simulation tick.

graceful zephyr
#

You can do full prediction and also predict getting into the car for sure

jade glacier
#

Worst case if the server denied your prediction, you find yourself back standing in the street.

silent zinc
#

I'm trying to send status packets only when the current status class is different from the previous. The networking code that checks this is in a loop attached to a separate thread. Problem is that it is TOO fast! I keep calling the method for sending packets, even when the status has not changed. Is there a better approach?

#

I'm posting the code...

#

I'm using UdpClient.SendAsync() as the send method...

#

Thanks in advance for all the help! : D

rare grove
#

guys

#

is there any way to multiplayer

#

for free

#

without using any paid servers

#

i heard peer2peer might do

silent zinc
#

Well, you could use a VPN like Hamachi

rare grove
#

u can like

#

make 1 player host

#

and everyone else depend on it right

civic tangle
# silent zinc https://hatebin.com/uavnyquqsm

your packet sending depends on isEqual but you've set isEqual to be false when the status hasnt been received? So the time interval between sending a packet and receiving a packet is the delay that causes the packet spam right? Shouldn't it assume that the isEqual is always true unless a status has been received, then it can evaluate whether it's true or false?

silent zinc
#

It's not about checking if the received status is equal to the previous, it should check if the playing character status is different, and then it should send the packet with the new status... For now i solved the problem by putting a Thread.Sleep(16) for every iteration in the loop.

tepid karma
#

Hello is there anyone who can help me in synchronization of variables,object.setactive synchronization in photon pun untiy?I followed photon pun docs byt I didn't get it.

Let me make this clear.
I aactually achieved synchronization but when I tried to synchronization varaiable of other scripts in another script it was not working.I am using OnPhotonSerializeView.

grim violet
#

show ur code

jade glacier
#

I guess that's a no ๐Ÿ™‚

dusky wedge
#

Does anyone have a video that teaches how to do multiplayer with no background knowledge of multiplayer

rough grotto
#

I am doing the gamedev .tv course on Unity multiplayer with Mirror. It is rather high tempo but you can follow along pretty easily and goes through the basics. Not very detailed into how multiplayer works but much of that is hidden behind the framework anyway, can recommend @dusky wedge (I got it through a humble bundle so pretty cheap)

#

@rare grove you can use Mirror with the steamworks integration. That way anyone can host and clients can connect without having tow orry about NAT punchthrough or port forwarding issues. Only available on PC (the steamworks part that is) afaik

high night
#

@dusky wedge basic background knowledge is:
you have two scenes in two computers
you want to keep these two scenes as closely synced as possible
and for that, you send some data back and forward
and keep that data as light as possible

thats the common thing for all mp projects

jade glacier
#

I would start with doing the Mirror and Pun2 tutorials. Those should at least get your head around the idea of asynchronous state transfer. But know as you are learning them that you are NOT learning good networking practices, you are just getting familiar with the difficulties of trying to synchronize states over a latent/lossy connection. @dusky wedge

#

Your goal start is just to even get enough of a concept of the difficulties to be able to start asking the right questions.

weak plinth
#

@rare grove yes, you can do multiplayer without purchasing server infrastructure and no, it doesn't have to be peer to peer. One of the players acting as host and synchronizing everyone is still client server, not peer to peer. The correct avenue to go down depends entirely on your games needs. As mentioned above, if you go user as a host, you may have NAT concerns and just general user understanding of networking pains unless a lib helps with that. Like steamworks. This is how it was done alot in the old days, but, kids these days won't want to deal with I suspect. "Enter server ip!?! Wtf Is that" :b If you have a ton of people connecting, this can also not work well because generally end user pcs are not as powerful as dedicated servers. I personally like this model because it's cheap and I'm technical. I also like this model because games that do this usually allow me to run my own server for my friends. Totally depends on the game. As others have mentioned, mirror is a good place to get started, but be prepared. You'll be taking on a great challenge. Tell us more about your game and maybe we can give more direction.

#

@dusky wedge, multiplayer basics comes down to computer networking basics. Depending on where you are in your programming journey, we can offer different appropriate materials. Im a big fan of learning the concepts separate of gaming and then applying to gaming with use of a library and engine. Networking can take a bit to wrap your head around. But start with basic socket programming in c# (I'm guessing 5hats what you know because this is a unity forumn). The documentation on the system.net namespace is pretty good, but, there is an older book on the subject https://www.amazon.com/dp/0124660517/ref=cm_sw_r_cp_apa_fabc_2SHWYC6QCVZMV3M4TGPJ

Unfortunately I am not aware of any video materials.

#

I know what was asked for is multiplayer game programming, but, I believe anyone without a bit of computer networking knowledge will be very confused.

rare grove
#

tysm

rare grove
#

since its dependent on user we cant make the host calculate every single thing i assume

#

and client also have to do some of the calculations

swift stratus
#

Hello, im trying to learn how to use Mirror and discovered the Network Discovery component. So far, that component works locally on my network but i would like it to work globally (wan) to search for other servers in the internet.

#

Is there a way to do so?

#

Or are there any sources explaining how to search for a server globally?

weak plinth
#

hi all

silent zinc
#

I finally was able to create my own custom networking protocol, and after lots of tries and fixes, IT WORKS PERFECTLY! I'm so happy!

#

If anyone would like some tips on how to create their own networking protocol for their game, i'll be happy to share some๐Ÿ™‚

rich narwhal
#

does anyone know why i can shoot a particle with a collider through someone on the machine getting shot at, but the other it shows it getting hit, i know it has to do with like adding a rpc or something somewhere or maybe its external i am not sure though, this is photon pun

silent zinc
#

@rich narwhal You could try sending to server the collision details, the server checks if the collision really happened, by looking at updated player's stored positions. And if the collision really happened, the server sends a message to all clients, notifying of the collision.

rich narwhal
#

that would be like if photonview.ismine correct

#

i just started networking like 3 days ago

silent zinc
#

I don't use photon, i created my own networking solution using sockets

rich narwhal
#

oh ok

zinc hull
#

How hard is it to setup a multiplayer fps/ rpg? What is required in terms of server etc

#

Am i going to write the networking myself or does any asset make this for me?

grim violet
#

depend of how many feature your game have, there is many network library already and you can make your own too but that will add alot of time to the making

#

if you want to save data online you need ur own server (or use a service like steam or whatever else there is, not sure how they work i make my own)

#

some fps are just shooting game with no record so it all depend on what kind of game you making

silent zinc
#

@zinc hull

#

it is hard

#

and fun

#

i personally use python non blocking sockets on python, and c# sockets in client side, with a custom packet structure.

upbeat kayak
# zinc hull How hard is it to setup a multiplayer fps/ rpg? What is required in terms of ser...

It'll be at least twice as much work as an equivalent singleplayer mode, even with a HLAPI. More, if you're new to gamedev and/or network programming (you are both). Some features will take 3-4 times longer to create. You'll have to fix bugs that can take hours/weeks, which simply wouldn't exist in singleplayer. Everything you create must be funneled down a narrow tube, with little wiggle room in terms of architecture. Planning on using dedicated servers? Make that at least three times as much work. Can players run their own dedicated servers? If not, add a mountain of extra work for the server operation. Oh, does that game have PvP? Don't forget to add another multiplication to that workload for anti-cheat, and server-authoritative design.

#

This is all a multiplier to the enormous workload that even a small RPG can be.

weak plinth
#

Has anyone ever had an issue with Mirror networking where calling NetworkServer.Unspawn within the OnStopServer function causes the object to still get destroyed?

upbeat kayak
#

Ah, discord links are bant. But yeah, Mirror has their own discord.

#

Absolutely full of people who use it every day

weak plinth
#

oh nice, must have missed that. Thanks for the heads up!

weak plinth
#

@rare grove correct. Not everything needs networked, only the things that do for your game. For example, you don't need to hear their music or menu sounds. But you might want to sync footsteps

rare grove
#

is it usually just sends a simple data constantly?

#

or more complicated than that

severe owl
#

look up gdc networking and you can dive headfirst

high night
#

@rare grove you just try to send as little info as possible to keep all players scenes in sync

rare grove
#

got it

high night
#

if you were doing a chess game for example, with only sending players inputs back and forward every turn, you can keep the scenes in sync @rare grove
input would be like
what pawn will move, where it will move

rare grove
#

yeah

#

only when the player moves

#

except dont send?

high night
#

in chess?

rare grove
#

yes

high night
#

yea

#

but

#

also one more thing

#

you generally wanna have one of the players/devices or server have authority on everything

#

authority can be split among players and stuff

#

.
but if you wanna keep it simple for now, you can think like this:
server instance is where the game runs,
clients are just sending inputs and trying to keep their scenes in sync with server depending on the data they recieve from server
@rare grove

rare grove
#

yes

#

client sends input, host calculates it and sends output to all clients, clients do the rest based on the output

high night
#

yes

rare grove
#

got it

high night
#

but that sort of thing will result in input delay proportional to clients latency to server

rare grove
#

so if i set a player as a host instead of a server

high night
#

so you explore more options if thats what you need

rare grove
#

can different ports join?

#

or local port only can join

high night
#

if you use mirror for example, you can host just like you host a minecraft server

rare grove
#

like multiplayer without using a seperate server

high night
#

your lan friends can join,
if you are on a static ip i think everyone can join with that ip

#

or you make a hamachi room

#

i dont know low levels of networking much

#

but i think that answers the question

weak plinth
#

TCP/UDP punchthrough and UPNP are also two options

#

Last option is port forwarding manually

#

Session Traversal Utilities for NAT (STUN) is a standardized set of methods, including a network protocol, for traversal of network address translator (NAT) gateways in applications of real-time voice, video, messaging, and other interactive communications.
STUN is a tool used by other protocols, such as Interactive Connectivity Establishment (I...

zinc hull
steady quail
#

If you start making a 2D mmorpg in unity 2020/1.
Which of all networking solutions available would you use? (and why)?

Mirror looks like the best option by far, but it leaves out so good updates for 2D cause is locked in LTS.

shut yarrow
#

You shouldn't choose a networking solution based on if it can do 2D or 3D because all can do both. The more specific you want a library to be, the less flexible it'll be as well

steady quail
#

I would agree with you if I were working on a library, but when you are working on an specific product, having a "flexible" solution usually takes you to problems like poor performance, bloated code, etc.

If I know I want to make a topdown 2D rpg, I dont care if the networking solution can handle physics or not. Even better if it does not.
Same goes for the "mmo" part, not all solutions works for a large number of users present at the same time.

grim violet
#

Depends of many things, is the game real time? turn based? do you care about cheater?

#

Plans change depending of library, some are free but limited, other you gotta pay by concurrent connections

#

Now handling multiple people wont only depends of your library, but alot more things

shut yarrow
#

With flexible I mean not everything decided for you already so you have to do more work yourself, it doesn't mean the library is bloat (it actually is more likely to be very lightweight)

grim violet
#

starting from scratch is prone to error if you just beginning, while libraries have years of experience and multiple developper behind

#

if you think you can handle that heat, go for it ๐Ÿ˜›

#

but just that is a project by itself

shut yarrow
#

It is and I would go so far to say that if you have to ask what solution to use that you probably have to reconsider and first do some more research to get a better idea of what is out there and what the best solution is for your project

steady quail
grim violet
#

i dont know what that game is but seem to be real time fighting

steady quail
shut yarrow
#

Don't ever rely on unity multiplayer, they have a terrible trackrecord of multiplayer implementations

grim violet
#

using something like photon cloud would work but cheater will be happy, since its client authority
if you want a safe anti cheat game you need server authority over real time, so either Mirror or photon server (or any other library out there, i just name those cause they are common)

steady quail
#

I have to say, also... that my last time working on a "simple" multiplayer project was back in Unity 4.6
I was away from this topic far too long to just know "what is working" now.

On my everyday work , I'm working on a DOTS+NETCODE , but this doesnt apply at all for what I want to do.

shut yarrow
#

If you want a free library that is also scale-able I can only think of Mirror and ENet. There are many others but if it were for me to decide I pick either of these two

steady quail
shut yarrow
#

I haven't

grim violet
#

depend what kind of game really, im making a mmo with photon cloud, but its turn based

shut yarrow
#

But what new features are you talking about because I fail to see why a networking library should be so entangled with the latest unity versions

steady quail
#

Tilemaps, 2D ShaderGraph, 2D Lights, Visual Effects Graph, and some other that AFAIK , are not available in the LTS version.

#

(Tilemaps upgrades*)

grim violet
#

what do you mean 2d shadergraph

steady quail
#

Thats why I want to use Unity 2020/1.
Mirror , since is built on top of the old Unet, is locked in on 2019.

shut yarrow
#

Fair enough, but that's kind of what I meant with lack of flexibility. You're going to get stuck on things and not being able to work around them easily

grim violet
#

2019 got all this but i thought visual effects graph was only for hdrp?

steady quail
grim violet
#

maybe urp

steady quail
#

URP

grim violet
#

i use shadergraph in 2019 with 2d and lwrp

shut yarrow
#

In my opinion a networking library shouldn't deal with any game structures itself, but rather only with connection handling and data transfering

grim violet
#

and got new 2d lights

#

all this is there since 2018

#

i didnt know vfx graph work with lwrp... maybe something im missing, tryed to use it myself and it didnt work

#

ah i remember its cause my game is webghell, doesnt support it

#

;p

steady quail
#

:P, Web is always the special case

rich narwhal
#

does anyone know why on one machine a particle collides but not the other?(PUN)

dim merlin
#

So I'd like some opinions on this!
I looked at Mirror today to hopefully be my network layer for a multiplayer turn-based card game. But I learned today (according to the official discord at least) that in order to make that work, it would essentially have to be P2P rather than server authoritative as Mirror would have to run through Unity on both ends.
This is obviously not desirable as that would cause some legal issues (I think? There was that server hosting site once right?) as well as massive slowdowns because Unity would have to be the middleman there for server interactions. I was told to do a custom socket setup, because otherwise there wasn't really an option like what I was looking for.

So I set out to find some sort of starting point, but obviously that's not so easy. I stumbled over these two examples for an async client and server based setup and was wondering if that would be a good place to start?
https://docs.microsoft.com/en-us/dotnet/framework/network-programming/asynchronous-client-socket-example
https://docs.microsoft.com/en-us/dotnet/framework/network-programming/asynchronous-server-socket-example

If not, is there some super amazing library/framework I just don't know of and should probably use instead? Is PUN usable for my usecase and potentially easier? It could be that it's fine for an initial setup at least, but then a custom solution later.

spring crane
#

SpatialOS was the service that got in legal trouble. Hosting Unity servers for your own game should be fine, which IIRC was specifically outlined in one of the blog posts that came out of that.

dim merlin
#

Right okay. I couldn't quite remember what the outcome was of that

grim violet
#

spatialos is used by unreal engine i think

dim merlin
#

SpatialOS is just a server hosting platform I believe

grim violet
#

but its owned by epic games or unreal or something

dim merlin
#

Didn't they just go into a partnership after the fact?

#

I don't think they sold to Epic did they?

#

If they did I missed that

grim violet
#

hmm improbable

#

not sure why i thought it was epic game or unreal

dim merlin
#

eh

#

They do some expensive shopping

#

Wouldn't be out of character for them

spring crane
#

Epic did jump in to do stuff while the thing was going down, so Epic has in the headlines at the time

dim merlin
#

Yeah I remember that

#

It was seen as a little too perfect timing

#

At the time

#

SpatialOS knew it was coming, were doing deals with Epic in the back

#

They come out antagonising unity

#

Kinda like Epic's case against Apple

grim violet
#

apple can rot

#

;p

dim merlin
#

Apple has become too powerful and rich of a company

grim violet
#

bunch of thief

#

since day 1

dim merlin
#

Most mega corps today should fragment

#

Split up

#

But anyway

#

That's off topic

grim violet
#

turn based card game could be made with about any solution really

dim merlin
#

My initial thought was REST API, but someone said I would need full duplex to make it work properly

grim violet
#

full duplex?

dim merlin
#

Full bi-communication between client and server

#

through sockets, essentially.

grim violet
#

well again it depend

#

but yeah most multiplayer stuff require bi communication

#

;p

#

unless u playing alone

dim merlin
#

No it would be a card playing game with people against people

grim violet
#

thats what i use rest api for my mmo

#

i guess a card game would work well

dim merlin
#

hm

grim violet
#

ive played huge card game like Tyrant which had tons of player it was using rest api too

dim merlin
#

I want the server to have full authority, essentially simulate the game so that when a client makes a request the server can know whether or not it's a legal request.

grim violet
#

you could play the entire game on client side then send the whole played game to server and server calculate it all

#

it depend of how much effort you gonna put in

dim merlin
#

I want the server to not trust the client with anything

#

Other than rendering

grim violet
#

thts why you use a database on server and dont trust client change but server change

dim merlin
#

The problem I guess is that without sockets, the client has to ping the api all the time for changes, but maybe that isn't an issue?

grim violet
#

if client sent "hey i did this then this" then server cehck against db if its possible or not

#

you could do it all the time for change, on every small change

#

or keep them in a pool then send the whole thing

#

its up to you really

#

rest api can be load balanced easily if you are hosted in a managed cloud

dim merlin
#

hm

#

So I need to set up something like sockets, but not really.
When a client connects it has to ping the API every X ticks for updates

#

Or I guess I could await..

grim violet
#

you want authoritative server then

#

sending tons of tick every second

#

at least thats what you seem to be talking about

#

but its not necessary for at urn based game

#

its more for real time stuff

dim merlin
#

Well yeah. I know it has to be authoritative server for this setup. It can't be any different than that for what I need. I'm just trying to think about the logistics of using REST for it

grim violet
#

rest api can be authoritative too

#

its just slower movement

#

you dont have to ping it every X second or whatever

#

you dont even have to check if its online

#

you just send your change you want to do on the client

#

server take care of the rest

#

the logic can hard to get thought

#

before making my game i thought about it for a couple weeks/months to make my head around it

#

but it work

dim merlin
#

Well look at it this way:

  1. Player 1 asks the server to make a move.
  2. Server receives the move and sends a code back whether this is legal or not. (let's assume it's okay this time)
  3. Player 1 is authorized to put down a card.

How do I notify Player 2? Player 2 must be pinging the server every few ticks to see what happened last, so it can be shown on their screen too right?

grim violet
#

just think about it, most Actions trading website use rest api, you got a client with all the data that you can buy and sell actions, can you cheat? nope

#

;p

dim merlin
#

Look at my hypothetical. Am I correct in assuming that I'd need Player 2 in this case to ping the API for updates all the time?

#

Because without sockets, there is no other way to do it right?

grim violet
#

player 1 and 2 send whatever move they do, they can cheat with each other client, but once the server will recognize whos the winner, he can obviously find out if a player cheated by comparing values with database and processing the fight between those 2

#

thats peer 2 peer

dim merlin
#

This is turn based though

grim violet
#

both client are p2p and use the rest api as server

#

yeah