#archived-networking
1 messages ยท Page 94 of 1
yeah?
well
player 1 send data to server, receive if it pass or not, then send to client 2 the change
its done in a fraction of second
And seeing as a REST API cannot contact a client but a client can contact a server, it would seem that there is no other way for the waiting player to get updates, other than constantly pinging the API until it's told that the turn has ended
then player 2 play his turn, send data to server, server say yes or no
then send to client 1
you do it by turn like that or go hyper complex and wait the end of battle, both player send result to server, compare if data is equal, and guess who the winner
I think we are talking past each other atm
im not suer what is with the PING
you dont have to use ping anywhere
;p
get that ping off your head lol
when you send data to rest api, you can get data back
no the rest api cannot contact player 2
but the client that send data to server, can
thats why the game is p2p, with rest api as server
alot of turn based game are made like this
In reality you want to send what player 1 and 2 did only at the end of the game. You can start battle, both player send a message to rest api saying they are in fight, rest api put them both into a container meaning they are fighting, no data, just the name and timestamp
Then both player play the game and send data to each other only. At the end of the game, both player send their combat logs to the rest api, rest api check if both data match the combat, if yes, you know no one cheated, and if one did, the other did too, which mean he clearly let the other win so it doesnt matter, he could have not played during the game and still lose.
Now if you compare both data and one of the player is wrong, you gotta check against the db which one did an illegal move, and make that player lose.
There you got full authority over your game with only a few send to the rest api. All this with p2p
@rare grove , sorry there is alot of info in the thread, so I may be repeating others. In general, computer networking works by taking data, serializing it on one computer, transmitting it via protocol and deserializinf on other side. So, how multiplayer works entirely depends on the use case. Because of this, the philosophies and approach come down to authors philosophy and needs and can't be summarized down to "this is the one way". The needs of a TCG game vary from that of a moba, from that of a time trial racing, from that of a battle royal. The library you choose or write will decide architecture and approach. Mirrors philosophy to generic networking is, from what I can tell with my blighted exposure, transport decoupled client server architecture, where client is also server and control is dictated by authority. They use attributes to specify data that needs relayed or in their terms synced. If you read that book on sockets and them come back to mirror as an implementation that integrates unity concepts, I think you'll be well prepared to understand and use mirror and or another library, or write your own. Feel free tonmessage me so we don't annoybthe thread. Cheers.
@grim violet So here is my understanding of the two approaches.
Greetings, i hope that i am not disrupting the conversation. I am currently having some trouble setting up a relay server for my mirror multiplayer game.
Context: I am trying to make a 2 player co-op game for a game jam project. I have the local network set up for mirror so my current step is to make it work over the internet.
I have joined the mirror server and they pointed me towards this transposer for mirror: https://github.com/Derek-R-S/Light-Reflective-Mirror.
I have created a Google Cloud project with a VM running. I managed to push the server file that existed inside the repository i linked above.
I managed to add all the nessesary files and API's (.Net 3.1 & the server files) and the server seems to be running per accordance to the command console seen here:
However, Unity prints out that it cant connect to the relay
Mirror has an official discord server
You could try there if you want ๐
You could go that way using rest api, but thats alot of in and out for not much since its a turn based game
and if you do that
i dunnoh
its weird
It gives full authority to the server immediately, rather than having to trust that nothing fishy happens between the two players in their P2P session
yeah but thats alot of in and out, you want to try to keep that to the floor to have many players
instead of sending every move, you can send all the move in the end and check it all at once
thats what im trying to explain
I understand that it's a lot of requests but as far as I know REST was also designed with this in mind.
with that way, player 1 send data to server, server accept, player 1 tell player 2 data has been sent, player 2 sent data to server, receive update, then tell client 1 game can continue
and that every turn
with my way, its twice, at beginning and end
๐
It also requires that the two players know about each other programmatically which seems unnecessary.
?
I'll think about it at least.
game is played just like in your way
your way work too i mean
but if it get high amount of player
you gonna regret
Sorry to interrupt gents, im trying to catch up, I think a custom socket solution would be best @dim merlin, I know it's a lot of work. But games are stateful apps usually and forcing that to adhere to stateless request response would be more headache then it's worth. Not to mention the overhead for wrapping game state in http for no real value. This is just my opinion. Rest is great for transactional relationships, but not for relationships that "know about" eachother which is why web sockets are used in conjuction for more state full functionality alot.
im talking about hundred or thousands
If I get a high amount of players, I'd likely have to shift to better server infrastructure and sockets.
have to get there first
Yeah I had a feeling
The question just is what kind of frameworks could I use to help this?
Would I really have to code it from scratch?
I bet monogame has some stuff
It's an xna clone but I bet it was some useful abstractions for game state transfer
hm
I wish there was some sort of starting point I could refer to because jumping into a codebase like that does seem rather daunting >.<
Looks like they use Lindgren.
Never heard of it
Yeah I understand, but, networked games are daunting by default! :b
Socket programming really isn't that bad in c#
I do it in c++ at my day job...
i did it in perl
Ooph
I don't doubt that networked games are harder to do, just that I'm not the first to get into this so there must be stuff out there for people like me who is getting into it but aren't seasoned networking veterans yet
There are abstractions. Like the one above. But usually network tries to strike a balance of performance a d high level, so it tends to be an expert domain
Unfortunately
Same
god that was crap
I used to be an ethical hacker
Haha nice to meet you!
When internet was fun
I don't know if it was fun back in the 90's...seems like a bit of romanticising ๐
Haha, I'm the next generation, I barely remember slow days haha
Yeah haha
Omni
Read this sockets book.
I grew up during that time and I had internet in my parents house. It was not great tech at the time.
you could tell people to fuck off with your ip shown and no pursuit
;p
getting hacked left and right
it was free for all
Anarchy like that sounds great on the surface, when you get to be in power of some bubble. But if you don't, you just get to be a victim instead.
oh i was victim for a while
Not a great deal but for the few
thats how i learned
Thanks, I'll try and look it up
first time i installed linux i didnt know about setting passwrod to root, get formated 1 day later
great time
This isn't some "Back in .net -2.4 days..." book right?
And I know it's painful, but, be grateful it's not the 90s and your reading a rfc or Berkley sockets api reference in c....
Haba
It is, but sockets are timeless
So ignore that
ho boy..
Well I say that because often when it comes to doing things like this, you learn by doing. And if a lot of the practices in this book are ancient because we found better alternatives, it might just make my life that much harder.
There aren't a ton of books on the subject in c# sadly
Trust me, sockets programming hasn't changed at all.
Because it relies on the same osi model that cannot change
The world runs on it
App protocols are added, thats the innovation
making from scratch is hard thought
lot of things you gotta think of
and if you never made that before, you wont think about that
It's true.
you gonna face ton of problem
better use an already made solution or copy from someone who already made something that is recognized
at least for starter
I'm not suggesting writing your own. But this knowledge will carry you tonunderstanding Lindgren or mirror or insert game object state transfer lib here.
and it wont be everything, just the data transmission protocol, you still have to think all the logic to make the game over that
You have to do that anyway, let's not lie :b
I mean, I hope you are right.
Well, no matter what you'll be better having learned. But if you insist, just try to read the docs of Lindgren
In this introduction to Lidgren.Network, we will look at how to easily establish connections and send simple messages between servers and clients.
I'll check out both
What about your plans for server infrastructure rules out mirror?
Can't be tied to unity for some reason.
From what I understood, Unity would be needed for both client and server to use Mirror
That doesn't seem like a good idea
Help me understand why. The licensing?
I mean why that's not a good idea btw, not why it's tied.
From what I gather, Unity has a thread count limit of 1200 threads or so. It would also be a lot to run a server through the unity client when you need none of the rendering no?
from what i know of mirror, you can have it headless i think
Depends on the game if that matters. I would think headless would be an option
doesnt really matter if unity is needed, you gotta make your server with something anyway
Since their goal is persistent mmmo
Yeah, I was thinking that.
I try to avoid running persistent server because I'm cheap
And a bit old school, I like running ny own game server
Here is the exact conversation I had on the mirror discord
It's turn based card game?
Yes
That's actually way simpler to do sockets for that
But
If its 2 ppl
Let them host it
What's your target platfoem
The idea will be a card game that could expand to include thousands.
Ohhhh
I need to make sure what I go for can scale :/
thousands 1v1?
I mean 1000's of concurrent matches for example
I just wanna hear multiple opinions
you gonan end up doing it that way, watch ๐
I will be needing that eventually, yes @weak plinth
Then just do THAT on server. 1000s is nothing when it's just connecting ppl. Then let them be their connection with unity/mirror
For now I need to make an internal version that can be played among the people making the game. Seeing as they are not located in the same place, it should at least have some online capabilities. Thing is, I have read stories of how hard it is to put MP in after the fact, compared to building something in as you go
That's true. I still think mirror works here. Let me explain.
Real quick, whats your target platform
A droid?
For now PC
I'm not designing that part ๐
Haha
ok ok ๐
So
You can indeed use rest if you want for this
Because
Your server simple keeps lists of online ppl
It doesn't manage game state
But wouldn't the server still need to be the judge on legal moves?
it is
Yes, it's just calculated on the client pc
It just sounds a lot like "trust the client" .-.
you dont trust client for anything in a turn based game
I know...that's what I just pointed out..
the client do the calcul, ask server if calcul is right
You're running same logic that you would have written
It's just on their oc
Pc
Bow
Now,
If I am misunderstanding, correct me. You are worried they'll disassemble and change the IL/c# and cheat?
If they themselves are the server?
I mean, that is one of the basic concerns right?
But could also be some attempted injection or whatever before a request is sent off.
it doesnt matter
if client change data and server check against db and its not right
you just dont accept it
you have to make an account with the rest api, get a database, put all the card player own in that, if you loot, server decide of the loot and update db, then send info to client
just is just holding informations of what he got
but dont really decide anything
he do calcul
but server will do everything
if client decide to cheat, you can know from the server and decide what to do, not update db and make him lose
I think there are several strategies for this. If it's card ownership, yeah, keep a dB of account info on the "user and matchmaking server"
doenst matter if the clients play the match together without asking a single thing from the server, in the end, they send the combats logs to the server, server do a scan of that and check if all the move was possible against the db and tell which client won the game
yes the player can cheat during the match, but still aint gonna win
now if you really dont want player to be able to cheat during the match no matter what will be the result, you need mirror or something real time like that and not use rest api
Yes
but is that necessary
I really don't like the idea of having a match just going on even though one party clearly cheated before they send off that to a server for verification.
Seems very risky
and also just very time consuming for players
I understand
having full authority with real time data = big server that cost money
Yes
Assume that server infrastructure will be taken care of
Okay
This isn't just some solo indie game
Hello im new
so headless mirror server
p2p mirror clients
?
Is that what I'm getting?
Or should it be sockets?
I said hello
Mirro = easier.
Sockets = challenging but more control
Good for you, wasn't addressing you with my question.
Hey demonic, sorry
Guess I should have elaborated; Mirror has sockets
We're all debating haha
No need to be rude
I wasn't being rude.
Yes, all network solutions eventually are sockets
You cant even welcome new people
Yes you are stop lying
We were in the middle of something here, stop causing a fuzz dude.
Screw this im leaving so annoying go on continue on your stupid convo
I didn't mean to be rude it was just stating a matter of fact. Not some personal attack.
lmao
I mean okay, suit yourself.
Whoa, guys guys guys.
Your attacking me for no reason
that what happen when big brains talks
I feel like this guy is trolling us gotta be honest :/
Im not a troll
No, I think he's just upset. It's all good
You think I waste my time for trolling
All are welcome
thats stupid
I mean look at his tags. He took like all of them.
I hate trolls
Oh, I didn't notice
I just wanted the roles
Ok
so what
Student and Producer, okay.
Anyway, @weak plinth & @grim violet
Thanks so far at least. Was helpful.
And thanks for being toxic and rude towards me
๐
If that was toxic towards you, I don't think you've experienced toxic man :/
So you'll have xomplete control if you roll your own with bare sockets and no concerns regarding needing unity. But, at the cost of engineering time and money
Well you couldnt be bothered to even say hi not like you will die from losing your convo
Yeah that's true. If I can use mirror for this it would save time and effort I might not have to spend.
Okay, consider this:
You came into a new room, people were discussing, and then you just walk up to strangers and demand they acknowledge your existence. Does that seem reasonable to you?
Or another abstraction. There might be some out there. Check out the one I mentioned and I'll keep an eye out
Yeah I'm definitely checking that one too
No then how will I talk
I cant interrupt people
Well I dont even know the channels
Not like I was here for ten years
So logistics wise it would be something like:
Mirror client 2 mirror client
Mirror headless server
Mirror has sockets already so that should be okay I think.
Might make things easier.
I guess I should make separate setups for querying the database
REST could probably be useful for that
So internally a piece of software uses REST as the db interface
well a socket is just a name meaning a connection to an ip and port, any library will do it
can your library talk to a rest api?
thats a different thing
i dont know if mirror do, i know photon do with webrpc
Look, it's a semantic argument at this point. Let's just say that; If I can use Mirror it would cut down on a lot of time I don't have to spend reinventing the wheel.
=_=
the functionality behind is really what you looking for
and you wont know before testing it
I get the point. I think the summation is:
Network lib not attached to unitu = higher engineering cost, learning cost, engineer hiring cost, more control.
Role your own = most control, most expensive all categories.
Unity integrated = cheapest, least control
just thinking mirror is realtime api with authoritative server, there no use for rest api, i dont believe they have that
you could always use unitywebrequest to talk to your data server rest api but that kinda break the point of using mirror
should just take both and take the time to test them
I'd just use an internal REST API as the database interface for things like my server
The abstraction layer between my database and my game server
Can anyone help me with a game?
I want to implement peer to peer networking for a fighting game, but with faked latency, I have read that unet is being deprecated and I am worried that it wont be able to support the features I need (lockstep, rollback) during the time of the project. Is there an alternative which is reliable or is unet still considered reliable?
Unet didn't have any of those features to start with, so no harm using another library. @drifting turtle
Unet is deprecated so I'd not recommend using it. Right now we don't have a networking solution which supports deterministic lockstep/rollback so you might want to look for a third party solution instead. We are working on a new networking library to replace Unet called the MLAPI but we are still in early development and haven't released a package yet.
And it (MLAPI) will also NOT support deterministic predict/rollback AFAIK, which is what fighting games use (and you mentioned specifically).
Only read like 25% of the convo
But for a card game, just use plain sockets
There's hardly anything to sync, there's hardly anything real-time
It'll actually be scalable, and you have 100% free choice over what server architecture you use.
Hi guys, i want to create a Card game, i search for a relay server for the online 1vs1 and save the user data in online database, any idea?
Make that relay server not just relay, but authoritative
Have that server communicate the results of the 1v1 games with a database
You have pretty much free choice in database and server architecture, since it doesn't need to be, and imo shouldn't be a Unity server
i mean, any project or app that allow that? i mean... for example Photon is a relay server
Make it yourself, websockets or tcp sockets
It's easy enough with something like a card-game
Not that I know of. But there should be plenty of resources available on something so basic
I suggest to look for 100% self made games
i don't know for sync the game state haha
There's not much to sync in a card game, assuming you don't have a simulation
yeah, that's true
Much like a chess game, nothing happens to the game state
Only when someone makes an input, and then nothing happens again
For a chess game I made, I only send the input to the server
Validate the input, and forward it to the client if it's correct
Otherwise, I rollback the client that sent a faulty input
@versed rock
void SGameHost::onRemoteInput(sf::Packet& packet)
{
ChessMove newMove;
newMove.netSerialize(packet, false);
if (packet && inputMove(newMove, true, true)) {
m_server->sendToClients(packet, m_observers);
}
else
{
sf::Packet snapshot;
snapshot << PacketType::Snapshot;
m_boardManager->serializeBoard(snapshot, true);
m_server->sendToClient(snapshot, m_playerID);
}
}
That's pretty much the entire authoritative part I have, and I suspect it's not going to differ much from what you are planning to make
Anyone here good with php that can help me?
Right now i have a ton of scripts that are super disorginised and i want some advice making a orginization scheme
[GetDate] A testing script that returns the current data
[getOnlineUsers] The server client calls this script with the server key and it returns a list of all the user-ID's in the online database
[getStats] Used by the discord bot to generate the statistics
[getUser] Used by the bot to get the username of someone given their discord uuid
[getUsers] Old script
[linkUser] Used by the bot to link a user-ID to a Discord uuid. given a username and password and a discord-ID
[login] Used by any client. given a username and password it returns the user-ID associated with that account and adds that user to the online list. it also generates a unique APIToken that is valid while the user is online. the user uses that APIToken to validate themselves in the future.
[logout] given an APIToken it logouts a user voiding the token and removing a user from the online database
[registerUser] given a username and password it registers a user into the database and returns the userID
[sql] given a SQL query it runs the query and returns the result (Disabled lmao)
[getUserInfo] given a userID it returns all public info about that user. currently just the username and the users color
And i want to try to make it so i dont have to move anything around in the future cause every time i restructure i have to change all refrences in the code
you should include one reference PHP file on the top of your child files to get all the values/references they need @safe lynx
could you elaborate a little more i dont fully understand
lol i saw
hmm i dont see how that could help
I mean, you have a lot of small files, whats your issue with them. Do you want one big chunk of file instead?
well each small file is a unique function that gets called for diffrent reasons for diffrent users
some functions requires APITokens
some functions are server/localhost access only
basic explination
each client in unity accesses them via a URL
so for a client to login they do a POST request to serverurl/app/login.php with paramerters username,password and it returns the userID and a unique APIToken used for further accesses
i just dont know how i should go about making it a little more consise for myself to handle
like structuring them in folders or concatinating scripts
Oh, well, I guess there is no like best thing to do. You could of course just order them with get / post or functions and data storing. more like personal preference than the way to go.
i suppose but it feels kinda like something thats been standerdizes in the past
I would maybe try to group them for data, user, and server stuff. Just my 2 cents here on first thought
like coding conventions
Lets take my headless CMS for example. I am just using API endpoints structured to their functions. One is for sending email with specific content asked by the user, another one gets me my data out of the CMS to json. So I have one function in those endpoints and they are ordered in their folder. But as your functions are not really doing some close to same thing, it would be just weird extra level to have one folder for one script.
interesting...
I would just keep the fileNaming the same, so GetDate should be getDate, but thats what I see now
i suppose. im also planning on making this a website aswell
having a front end cause the structure is there
currently any error or denied access request just redirects to an index.html page
Is this some hobby thing or client work?
Oh alrighty, yeah, it sounds like your files grow with your development, right ๐
So maybe just get pen and paper, write down what you need, you'll find your strcuture best suited for you there. ๐
Like, what endpoints do you have, what data will be transported to where, and so on
Maybe you do not need to write your on php sign and register and what not if you are using a CMS already. Headless CMS is a great way to just work with data
probably
(Server) for serverside only functions
(Authencation) what you use to login
(UserOnly) what you use to make general communication it also requires an api token
whats that?
im using a MYSQL database for the backend storage
and the php scripts to interface with them
So you actually build your own little headless cms there, without backend interface obviously. And yeah, I like your structure there, makes sense to me. ๐
well theres kinda backend interface i think. im also creating a custom unity instance called CeaseServer that will do the bulk of serverSide code
it has a compleatly private APIKey that it used to access the server only scripts
Nice, I like your setup there ๐
You wanna tell what your games about or is it secret right now ? ๐
nah its compleatly open
its gonna be a VR multiplayer dungeon crawler
ive been working on a desktop mode for it aswell
ive been working on the backend for a while now. i got an account login system with username storage personalized names
been working with photon realtime and photon chat for the P2P stuff
Sounds like fun
ye its been intresting learning how to code for VR from scratch
and learn how to code networking from scratch
i'm trying to make a game using photon pun 2 and i have this script that doesn't work ``` public override void OnPlayerEnteredRoom(Player newPlayer)
{
Debug.Log(newPlayer.NickName);
if (PhotonNetwork.IsMasterClient)
{
GameObject playerReadyObjectInst;
playerReadyObjectInst = PhotonNetwork.Instantiate("playerReadyObject", Vector3.zero, Quaternion.identity);
playerReadyObjectInst.GetComponent<PhotonView>().TransferOwnership(newPlayer);
photonView.RPC("parentObject", RpcTarget.All, playerReadyObjectInst.GetComponent<PhotonView>().ViewID);
}
}``` it feels like the problem is that it doesn't get called because i don't even get a log in the console.
does anyone know why on one machine the collider works but the other a shot goes right through it, i know its not going through the network i just dont know how to fix it PUN
When can we test it! ๐
Its open beta/alpha playtest
I can invite you to the server
I'll take a look
anyone have idea how to use protobuf in unity?
or maybe can anyone help me with this error?
I have a thread that calls socket.receive in an infinite loop.
When i set its exit flag to true from another thread not only the thread doesn't quit (obv its stuck awaiting the receive), but it causes a crash.
is there any way to gracefully close this thread, besides adding a timeout for the receive?
You should have a timeout for the receive
Unless you have some kind of handle that stops receiving
And why would it cause a crash?
thats some unrelated, i guess unity can't abort a thread when its stuck
ill add a canceltoken see if it fixes it
nope, apparently that's not the only thing that causes the thread to hang
i think i found it but....
an await will not yield if the called method returns null?????
is this true or am i tripping
I haven't done that much async stuff but it's easy to get lost.
Are you doing any error handling on a return of null? Is it timing out and returning null or is it returning null and an error code?
Don't use the async functions.
Just call receive and/or poll, it's much cheaper
Just receive for 100-1000ms at a time in a while(isrunning)
Async is 100% useless for game networking
Not looking at the network stack, what would be the best way to send updates from client to server then server to other clients?
I'm thinking of a VTT.
Token A moves from x1, y1 to x2, y2. That gets pushed from client to server then pulled to each client.
My thought was to push a serialized object to the server then have the other clients check for updates which would include character movements and other data.
Like, you last connected 2 minutes ago, here are all the token updates since then.
@elfin pecan is this for real time? If you don't need real time responsiveness, you could look into something like Firebase
it's fairly easy to get started, essentially a JSON database where you can subscribe to changed events etc
Timing isn't strict. I'm thinking of a 3d version of Roll20 or Foundry VTT.
dont let clients push anything but normalized input
So for my game, the client's car's wheel rotation should match the server car's wheel rotation right?
and just have it do a rotation lerp?
^ For viewing other players, not when the player is predicting the car movement
i wouldnt sync wheel rotation, that should happen auto when car move
yeah but the wheels only rotate when force is properly applied to the rigidbody. That won't happen when the updates come in from the server
it's just going to lerp the car to the correct position
you are using physic on a client to move rigidbody and wheel turn by itself then other client you use lerp on position?
that sound wrong
correct
It does use physics, when the player is piloting it
but when the player is out of it, and someone else is controlling it
then player 1 only makes it lerp
yeah thats not how its supose to be i think
hmm
you gotta move it with physic too
i might be wrong but it sound more logical
than trying to sync all part of the vehicle
it could be a way too i mean if you are in the air and want to turn your backwheel while pressing pedal and want other to see that specific effect yeah
you gotta do it that way i guess
just physic should work too actually
I think you might be misunderstanding what I'm saying. So player 1 is piloting the car, and player 2 is standing beside the car, not inside of it. Player 1 predicts the car movement on his end with physics and does reconciliation checks and all that stuff. Player 2 only receives information about the car's position every 20ms
So if player 2 tried to move the car with physics, I don't know if that would work
why not?
you just push velocity and apply it i guess, there probably some math i never did it myself
im using photon and it calculate it under the hood but im not award of the math they use
well the car moves with physics entirely on the server's end
It's just getting the client to replicate it properly
but your wheel and all that work with physic doesnt work properly
just sending velocity wouuld make all that work
how wouldn't it work?
on the client's end yes
arent those wheel turning when you apply velocity to the rigidbody of the car?
yes, but when I send the car's position, the client makes the car lerp to that position
- lerp the wheel rotation
so it looks like its moving while the car is moving right?
trying to wrap my head around this
https://gafferongames.com/post/deterministic_lockstep/ there some good read on that
yeah I just don't know if moving cars with physics is the right thing to do, because my players also move with physics and I just lerp the positions
if a car hit another car and there an impact, how would you know how much velocity to apply to the impact
well the server handles that right?
kk ur server doing all the work for the calculations
yeah
then yeah i guess you gotta lerp everything like you doing
I see what you're saying witht the collisions though, car crashes probably wont be smooth on the clientside
since it has to wait for the server to recalculate and give the right positions after the collisions
Hello everyone, I'm watching this playlist to learn someone Unity Networking but the videos are using the Multiplayer HLAPI and I saw that Unity will remove it so I don't really want to learn it. Does anyone have any other videos I can watch to learn Unity Networking
here is the playlist
https://www.youtube.com/watch?v=UK57qdq_lak&list=PLPV2KyIb3jR5PhGqsO7G4PsbEC_Al-kPZ&index=1&ab_channel=Brackeys
In this video we set up our Player and begin moving him around.
โ Download cool Weapons: http://devassets.com/assets/modern-weapons/
โ Developer Forum: http://forum.brackeys.com/
โ Download project (GitHub): http://bit.ly/1JOvQ61
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
Learn how to make a multipla...
its also alot of calcul for server
imt not sure how many people you want to handle
but it wont be that much
well it has to be done on the server regardless, since it's authoritative
yeah but id imagine if your server give a start point and just take input from that, you can still have authority on stuff
with physic calculated on each client instead
i guess it depend of physic engine like the article i shown saying at begining of the read
i dont know about physx
how it work or anything
Isn't step 1 of networking to never trust the client?
you dont
but you dont have to control everything on his screen too, server hold info of wher ethings are at and push that to everyone, if one client decide to cheat something for a sec, next update will fix it
alright
@jade glacier I'd like your opinion too whenever you get on, before I start this complicated module for my game
Way too much for me to read back through
@jade glacier So essentially every 20ms, server sends a list of all entities and their positions/rotations including the cars
when the client receives this, he just lerps the position/rotation of the cars driven by other players right?
Clients driving cars are predicted. so I don't know if that would make car crashes look weird or not
I could be wrong, but in Rust, whenever you crash into another car on the clientside, the collision happens, and then a quarter of a second later, the car you just collided with, will actually move. So I don't think they do crash predictions. Could just be a figment of my imagination though
The predicted cars will exist in the future, so there is always some weirdness there you have to account for.
alright
Would it help to put rigidbodies on ALL cars, even ones not currently being predicted?
So the player has SOME feedback of real-time crashes?
And lastly, the non-predicted cars get the wheel rotation from the server right? Since they're just being lerped and don't move with physics on the client?
but then I run into the problem where if a car hits a car that a user is currently predicting, it's going to be weird since the non predicted client cars don't move with physics.
@gleaming prawn Any thoughts?
The part that I'm stuck on is just determining if other player's (non predicted) cars should be moving with lerp transforms or through physics. Now that I really think about it, the cars all SHOULD be updated through physics right?
Hello would anyone be kind to assist me with echoing mysqli results back to unity with json objects?
- I'm not sure how I can echo multiple responses from a POST request with PHP
- Should I echo multiple json objects > work on them or make a single json objects with all query results?
Not sure what your backend is, i am using a headless cms, but kind of the same, I am adding up queries and combine them into one single json file getting back to Unity
You don't
You are designing something poorly if you have to send out multiple separate JSONs
Use a DTO for something like this
It'll be easier to send and also easier to process on the receiving end
Agreed, just get an endpoint that fetches your stuff and output what you need
Hello all, I'm a little confused by concept of Relay Server and Dedicated Server (Authoritative). Is the difference between them is based on their set of functionalities?
As far as I understood:
Dedicated Server - used to process incoming packets from clients directly or using Relay server which is a proxy between Client and Dedicated Server. It also handle additional server-side logic like specific systems defined by user.
Relay Server - used to send packets back and forth between two destinations, can be used for a pseudo-P2P solution. Its Sending packets and can use packets optimization techniques.
Would be glad if someone would be so kind to let me know if I have the right idea. Thanks!
A relay is nothing more than a post office-like server
It's usually used for two clients to communicate with each other, where one client acts as the server(host)
Host Client -> Relay Server <- Client
A dedicated server can be as simple as a client host running headless, which in some games is exactly what it is
"dedicated" means it's only purpose is to run a server, not act as a client where a player can play through
Authoritative means that the server (or whatever is authoritative in this case) decides the final outcome of the game.
Yeah, I was only confused with Relay meaning since i've not remember using it
Alright, @weak plinth thank you!
If you just wanna play around with networked games, Photon PUN is a pretty fun way to get into it.
They provide you a relay for upto 20 players for free, allowing play without portforwarding.
What are the best ways to store the client data in multiplayer?
I thought about creating a class specifically for this purpose, but that feels stupid
I don't think that's terribly uncommon even for singleplayer ๐
Oh you mean all the data for the client? For some reason thought it to be some sort of player data.
What is the client data tho?
@weak plinth Regardless of playing with people in your own country or not, you probably need to do port forwarding for any other computer outside of your house to connect to you (unless you use something like PUN)
by client data I mean ID and whatever stuff that cannot be handled effectively via server, such as ammo counting
with limits
Relay servers are a thing (PUN is one, yes)
NAT Punchthrough
UpNp
STUN
I mean CCU
@weak plinth isn't that what I said why you mention me ๐
That's not what you said
Number of clients that can connect at the same time to the server
Concurrent users
NAT punchthrough and stun are not port forwarding
And UpNp is implicit, temporary port forwarding that the user doesn't have to do
that means 20 users can join at the same moment
and yes, it is the limit for free PUN
you don't
photon does this for ya
Why overcomplicate things, nobody is going to use NAT punchthrough probably (it'll still require a server)
That's why I said PUN
@weak plinth you operate on your application remotely
no bandwidth goes through your network
No, you said "you probably need to do port forwarding for any other computer outside of your house to connect to you"
Which just isn't true
Did you miss the part where I said (unless you use something like PUN)
You argue for the sake of arguing
Pun is a relay, that has nothing to do with nat punchthrough or stun
There's not port forwarding or pun either/or
There's other options...
I mean you CAN host the Photon server by yourself
but in most cases people choose the photon cloud to do all the job
@weak plinth Unity themselves recommend (and it's used in practice as well), is to first attempt UpNp for the host
If that doesn't work, STUN is the second best option
If you want more flexibility then consider renting a VPS for a couple bucks per month, then you can run any server you like without port forwarding (your clients just connect to this machine somewhere in a datacenter)
For Photon it is only worth if the server requires full authority
Photon costs ridiculous amounts of money
For photon yes
Thread is about the PUN, so I didn't mention alternatives
Well he asked about options to not port forward, so PUN might be the best option especially for beginner
I agree
And he can try out for free
Yea it's worth considering the context
Still remains the same
2000 is nothing really for a serious multiplayer game
^
under 2k is not serious?
But here is the joke of it. You could have those 2k users on a machine that costs you 20 bucks a month maybe, with photon you pay way more than that
per app
2k user on a machine?
20 CCU is for one application on your photon account
what kinda machine is that
No, 20 total players online at the same time
@grim violet I wasn't implying under 2k isn't serious, just saying 2k isn't something strange if you have popular game
It's not per app?
No
in total
WoT has usually 20k people on EU1 all the time for example
Technically with PUN there's no concept of 'servers', instead you can have multiple rooms with max 20 players across all of them
@weak plinth Not per server
It is, but consider when you go over that you start paying considerable amounts of money that you might not necessarily earn already with your game
to which sentence is that a reference to?
considerable amounts of money
This is relative
Maybe so but in absolute terms you pay a lot more than other solutions with your own hosting
Photon has it's other limits as well, so it's worth adding those to the total cost
CCU means simultaneous. To get something like 100 CCU (which is offered as a one-time payment for a year) you need around 40000 players in total in the game
the msg limits are more suggestions due to the client performance
not a hard-cap
I mean the nature of the Photon itself
Quantum is ignorable due to it's availability
I always wondered which Photon product can spawn NPC via server side
to not trust clients
Bolt by default.
I'm not up to date with current photon products but in the past I think it was Photon Server
or custom server logic (server plugins) with photon realtime
or quantum which is deterministic (so not possible to do usual cheating)
i do spawn on server with pun
or the new photon fusion
All the options are confusing to me tbh
Multiplayer is not a one-solution-fits-all
That's true
We're streamlining a few things
Photon Fusion will eventually replace both PUN and Bolt
When can Fusion no longer be ignored due to availability? ๐ค
(although we'll still support both for existing customers, of course)
Ah now it makes sense you preach for your own choir ๐ ๐
Fusion is expected to go on public beta before summer AFAIK
Everybody with more than 2 days here knows I work for Exit Games
no
port forward is only necessary for mlapi, mirror, etc
It's fine I get it, I visit here every now and then
But notice PUN2 is a totally different thing than doing client-server multiplayer
Nice. Looking to remake some older PUN projects
port forward is a bit old and unsafe TBH
Inb4 UpNp works just fine on your router, because he didn't turn it off
it's more common to use STUN punch nowadays
Itรs what steam networking does, for example
same for upnp
it's something you can not rely on...
Sure, if it works from your machine and that is ALL you need, fine
Wouldn't you still need a server to establish an initial connection?
That's how I understood NAT punchthrough to work for example
A STUN server, yes
But most people develop games to be available for players, in that case neither port-forward nor upnp are really a good solution (punch is + relay is more consistent)
not only the STUN server
the STUN server gives you reflexive addresses only... YOu need a reliable way to exchange these addresses between the machines, so they can attempt the punch, eztc
@weak plinth register for a PUN account you can start in minutes
@weak plinth just use pun or bolt then... or use mirror and mlapi on LAN only (no internet) or host a dedicated server with them
@weak plinth you need to do this signaling (exchange the reflexive addresses and coordinate the punch process)
it's not only a STUN server, that's just 1/3 of what you need
Somehow I still fail to see the big benefit of still needing a server and then exposing clients to eachother, like how can that be considered safe. The only real benefit I can think of is very low bandwidth consumption for the server that does the interconnecting
A complete solution that uses punch (like steam, or bolt, or nintendo PIA, or PSN, etc) have 3 pieces:
A) a reliable server to coordinate the process
B) STUN server for reflexive addresses (could even use public ones from google)
C) a Relay as fallback (punch only works 85-90% of the time)
You can sure combine A and C in the same server
there are 2 benefits:
- it's faster connection for the players, there's a big chance their are closer to each other than going through a 3rd hop (server)
- if it's you hosting these servers, you save resources in them
Option C bumps up the server requirements by a lot
C is mandatory if you are serious about your game
Of course
Maybe you guys are all young, but let me tell you a story about Unity and multiplayer
Alright understood although just the security aspect still weighs heavy on me
Back in the days, when Unity first launched UN (old API they built on top of raknet), they offered a master server thing for doign matchmaking, and it included all of the above except C (no relay fallback)
I remember UN but back then no idea how any of networking works
It was a big failure, people tried to launch games with it, and caused rages on players because connections would not be established in 15-20% of the cases (I have a friend who released one of these games with Paradox)
PUN (the most popular photon product) was developed as an answer to that... Very similar API and concepts, but worked every single time (because of the reliable relay servers)
Not arguing PUN is the best way to do multiplayer
First time I started with Unity, PUN was already a thing
Which was like 6 years ago somewhere
Just saying a lot of its success was because it worked reliably and it was super easy to use
Well it definitely covered a big hole Unity left open
It still does
My point is this:
Yeah I'm not waiting for Unity to do it better
- talking about punch/upnp/port-forward in 2021 WITHOUT a relay fallback is like repeating the same primary mistake unity did
If you are thinking about RELEASING a game for others to play... THis is not an option..
I understand and I agree
Now the question is, does Stream do these things for you through their API?
Steam does only the basic transport (so it's not really a netcode API)
But it does ABC, yes
point is, it's only for games on Steam, so not for consoles, not for mobile, etc
I mean, is there an option to roll your own netcode and use steam for ABC
I think Epic is offereing something similar
Playfab has their own relay
YOu have Normcore... there are many many offerings in the basic-transport-layer tier...
Many can be integrated into Mirror or MLAPI (if they are not yet)
tryed to email them normcore never got an anwser
Ours are just some of the offerings
To get info about the server hour thing or whatever it was? ๐
yeah
room thingy
1000+ hour a room i think
or some weird stuff
i even remailed after a week
Room hours, yea
AFAIK they are offering legit services... But I can't answer for them of course
I think the 3TB needs attention (this is similar to ours)
bandwidth is expensive
Here's my free interpretation of the 1K ours
yeah but you have limited ccu and they dont, for 49$ a month, there has to be something
Knowing how people "word" these, my assumption is:
- total SUM of hours for open rooms
What is a "room hour" ?
What is a "room" in this context?
example:
- one room at a time, needs to complete 1000 hours to reach that
- if 2 at the same time, 500 hours
- say you have 10 concurrent rooms, your limit is 100 hours, spread that over 30 days...
3 hours of gameplay per day
That's your limit
"room" is one session?
but thats freaking shady
Remember, that is my "safe" interpretation
why would you limit your game like this
thats what i thought too
i looked throught all doc
not a single comment on it
and no mail anwser so yeah
because there's no free lunch?
this is not how to deal with a (prospect) customer, agree...:)
see, server costs and bandwidth are commodities, these are not different for them as they are for us
So a plan for 50 bucks a month is probably good for half of what a plan for 100 bucks a month on photon does...
Normcore is a relay as well, it's always using the servers bandwidth, etc
thats why i stick with photon, good anwser at any time of the day or night, and ccu limit but no room hours shit ;p
by the time i get to that ccu limit, ill probably be rich
id prefer have unlimited room hours
and ccu
lol
people play and bam server cut
no more time left
Honestly, using CCU as the metric is what our management says face to face to any customer: it's the most fair metric
yeah it sound very low when you have no idea
You can disagree on pricing, sure
i seen a game that has 600 people max ccu
they made 12 million
so yeah
ill be able to afford that 3k ccu once there
lol
yeah
If you have a paid game on steam that reaches 1k ccu, you are probably rich
And not worrie about paying 95 bucks per month
clearly
on mobile it's different
even hosting myself i tryed to calculate and it would cost me more than just using pun and a vm somewhere as backend server
because of F2P, you get a lot more players
yes, but it IS possible to get cheaper than what we offer. We're not doing this on a loss, of course
BUT
You can host a VPS for 10 bucks a month with 20 TB traffic what do you mean electricity...
It takes a LOT of work, of effort and you need to find very good deals
its like having the industrial company selling at 1$ but if you do it on your own, good luck
its normal
;p
how many CCU can you hook on that baby?
Aren't these numbers https://steamcharts.com/ representative of CCU? At least, assuming the clients are not connecting to privately owned servers
As much till you max out on RAM and CPU, so depends
Yes
If a player play "offline" is that a ccu too
these are live CCUs:
then you can see how absurdly huge the big-shots are
The AAA stuff
yeah
The CCU of games like Destiny and Warframe though ๐
Or the new indie-frenzy Valheim
on steam, depends
It counts also players playing single player games
so it add up in that
So I'd say if you have the game open in the menu, not searching for a match, it already counts
yeh
For the StreamCharts, or what you'd count as CCU? @gleaming prawn
steam charts
Ah ok, yes
for photon it counts only when you are connected to photon, of course
what about offline mode in photon
SteamCharts is steam metrics from the steam client, etc
does that count
Yeah, it is. As soon as you boot up the game, even if you remain in the splash-screen, it counts as an active player
of course not
that data can actually be a burden
i played some game where community was freaking toxic
and used taht steam chart to attack on every side
lol, ye
each time a lost of player was made
"the game is falling apart!" then they do bad reviews
so yeah
lol
I can deal with toxic players, but cheaters -_-
cheating is overrated...:)
Depend what game you play
yeah cheating is a feature
I mean as a game maker
I can ignore toxic players, but cheaters come specifically for me
remember nintendo game genie
;p
a cassette to place other casette over to cheat
made by nintendo itself
they understood some player had fun with this
Thing is I care about it a lot, more than I should... And then you have these games where the dev did not give a shit about it (Fallguys, for example)
why not
And sell tons
I'm flying around in an airplane trying to catch bankrobbers, then whoops I get ejected from my airplane because a cheater pressed a button and now I'm falling to certain death
webgl is easy too i think
Rinse and repeat... At that point I quit the game
So from a game development perspective, it's at least relative
i never tryed myself but i remember having ton of developper stuff for web and easy changing variables
webgl is totally open
I do not deal with it most of the time because neither quantum nor fusion work on webgl at all
pun solution with fake authority from my server on webgl
you can do with realtime
People need an incentive to cheat in the first place, remember that
So you are running photon server with plugins?
And the bigger the incentive is, the likelier it is that people will cheat
nope
yes
just webrpc
php server
you mean webhooks plugin on photon?
That's why you very rarely see player cheat in co-op games or modes
no webrpc
i dont use the webhook
its part of it thought to give the address
but i dont use the webhook stuff
I did not get what you are doing then... you have the clients connect both to PUN and to your backend?
"there" you mean the clients?
from pun
it's a bit of a weird setup tbh, but if it works for you...:)
I know what webrpc is, of course
ye
about my spawns and all, all is calculated there
ye ye
i can have loadbalancing if there many people
that's what I though, you use the backend as a sort of spawn and movement limits validation etc
yeah
not movement thought
its turn based battle
i dont care if player cheat his movement in the map
Makes sense then
wont get him anywhere
so you use Pun just for the visual sync
but use your own backend for the gamelogic...
exact
making a whole mmorpg with this
turn based battle but real time map with people walking around
i lock em at 50
Although you can go clever with interest groups and the update freqnecy
could probably optimize for more but i dont want to
and push that a lot higher
ye
but you can go higher due to your setup not needing to run the actual game logic over pun
yeah i dont have much going on except player movmeent
its just that actually
and ressource spawn when player get resource
i use custom room properties to hold info on who get it first
but still server that check it if its okay at the end
so far its working fine, tryed with 5-6 people
I failed to find here (google) the blog post (from a customer) explaining a way to do interest management with pun
Would work well for your setup
i probably saw it when i started this project hehe
did alot of research how to make a server with pun
to find out about php
interest management you mean by player around?
like ring streaming players
just to make people far from you be updated seldom
So you improve bandwidth and can go higher on player count
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
this
i make room right now with maps, its big map but still limited
ill check it out
i wasnt even award you could do that with pun
that open doors
๐
can you believe im using pun since about 2 year and never seen this script, someone spoke about rigidbody view other day and i was using the transform view instead ignoring the other one was there lol
there so much stuff
bruh what is even going on with the new multiplayer api
Which one?
idk i have no idea whats available to use right now all i know is that unet is being depreciated
but i want to start a multiplayer project
Just use thirdparty solutions like people pretty much always have.
alright
i tried photon and i really didnt like it so ill try mirror i suppose
or maybe, what would you guys recommend for turn based multiplayer? nothing real time
You can use anything for turn-based...even a web service. It will be down to ease of use at that point and your own skill set
Plain TCP Sockets will in my opinion be one of the easier options
No extra fluff to work with, and because it's TCP, you don't have issues with out-of-order, duplicate or missing data
could u recommend some resources for working with a tcp socket in unity?
Don't know any on the top of my head, sorry
all good
Most I can offer you is a Chess game in C++ that also uses TCP
lol that actually might be pretty useful
thanks a dozen ๐
Yeah, no problem. Hopefully it's useful for you.
Does anyone know why in unity PUN photon i have a photon view on a object yet it wont show up in game for the otherplayer
@rich narwhal Are you using PhotonNetwork.Instantiate?
well the thing is should i instantiate? i have it rn to where you just enable it and then at start it disables it and you can renenable it in game
but it doesnt show up
if i have some "working" code (it's a little janky, but it basically does what i want it to) using mirror... how hard is it going to be to convert the player movement to server-authoritive from the current client authority version i'm using? relatively easy or... basically start over from scratch?
Am having trouble understanding "CONCURRENT USERS" if i buy the photon 2 Plus does that mean only 100 players can play the game at a time OR i can have 100 players in one match / room
concurrent is the total sum across all active rooms
Does not matter if two of 50, 5 of 20, etc
But remember that to get to 100 players in avg you need to have something like 2000 daily active players (DAU), which requires around 40000 downloads of your game, etc
@jade glacier looking for job opportunity xD
Yo, anyone here has experience with playfab? I'm trying to figure out the session lengths of my users, upon logging in session_started gets raised, but session_ended never seems to get raised
hello guys im new here, and im also new to unity networking. Im currently stuck with UnityWebRequest.Put method. I've looked at the unity manual, it shows how to pass a string, but I want to pass a key,value style pair. How to do that? Thanks
Thanks for clearing that
@weak birch You are looking?
Yes remote front end . Do u know any? @jade glacier
I don't, I live in a pretty small bubble and I don't really know many employers sorry ๐
Company fell apart?
No im just trying to improve life by earning in dollar currency
Wages aren't satisfying
Ahh. yeah sorry - I am the wrong person to help there.
There's nothing special about a "Unity Server" assuming you mean a headless build
yeah
My question is can I make a command line engine to control the server by accepting input
like minecraft
Sure
How can I make it accept input
in a c# console app I can do Console.ReadLine();
but in unity I'm not sure
The same, it's just C#
but it isn't a c# console app is it?