#archived-networking
1 messages ยท Page 69 of 1
alright thanks !
unless you actually print the value you are assuming what it is :D
murdering assumptions is an important programming skill
I did, thats how i found out it sends the "ID" of the local Player, because i "printed" the actually ID on the UI to test it
Especially in networking, where debugging is 10x harder
debugging is the same. just come here and someone 10,000,000x smarter will fix it for you
While loops with network time related conditions are giving me debug nightmares mostly
(Stuff that i did to have my own controlled FixedUpdate-like update)
@empty yew sorry that i ask questions
Ah sorry, i thought you are reffering to me
@slim ridge Doing Unity physics stuff or PhysX stuff?
unity. the way fixedupdate works makes timing a nightmare
Yea I've seen mentions about that. Seems like a lot of people are jumping on to take advantage of the more predictable physics for networking stuff
For all of my networking I had to create my own singleton that runs at the earliest exec timing and another that runs at latest, and I use that to reconstruct a "PrePhysX" and "PostPhsyX" master callback.
not having an actual PostSimulate in monobs is a real problem for good tick based networking.
Hey I was wondering if anyone who knows there way around Photon Networking could dm me or something BC im having some problems
You can ask your question in here
I assume you mean PUN, and I assume you are using an RPC?
I am using PUN and I have tried using an RPC and OnPhotonSerialzedView but I'm new to this and nothing has worked so I'm assuming I implemented them wrong
Probably yeah
If I were to show you the scripts do u think you could help?
Dunno, can't hurt to try and form a question or isolate some code to show.
You haven't actually asked a question, you just kind of stated that you are lost.
Yup
So, give it your best shot.
I'm uploading pictures
have you done the tutorials on the Exit site?
typically you want to use like hatebin.com or if its short code like that use the ```cs yourcode ``` format in here.
U lost me there
yeah, you are miles away
do the tutorials first
you will never guess how to code for networking
I've done a few but none on the hashbin thing
I read about it in some documentation
hastebin is for posting code, not for the networking dev part
Sorry hash something
But you aren't even calling any of the PUN callbacks for networking there, so unless its somewhere else - you are entirely missing all of the connecting and responding to connection callbacks.
Yes I deleted that so you could see the code but I'll try and recreate it
Have you gotten the tutorial working?
If you start with that you can then start adding your own things to learn how to do it.
Sorry here's what I had b4
And if you have any recommendations I've tried quite a few tutorials and they haven't been working for me
I would start with the tutorials that come with it
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!
Have you made a Unity game before? Or at least mostly completed one?
Yes but networking is always something I've hated
Anyway the code up above in my 3rd picture seemed similar to the code in the GameLogic section
Still not a question really, sorry.
Why isn't it working
You are missing a lot of things, I haven't seen any code yet that you have where OnJoinedRoom and such are being used so I really can't say anything.
Its not working because you have bugs in your code.... that is all I can say.
You are connecting and seeing the other player objects?
and you have wired your component up to the PhotonView IObservables?
And debug.log calls inside of your serialization methods are firing indicating that they are being called to write and read?
I didn't debug it
why does the pasted code have two identical IOnSerialize methods?
Dang
Why not?
Idk
And I can't freakin test it right now
My computer isn't accessing the internet
And the Photon can't work without connection
I got nothing for you sorry. You need to do all of the basic debugging stuff first and narrow it down to an actual question before I can assist. ๐
I'll assume it's not being called anyway or else the variable would have been synced
Never assume
Yah
Debug.Log.... everywhere
You have a wrong assumption, that is what you are trying to find.
I'll have it being able to test tomorrow
Wait...
I think I have another theory too
@jade glacier is it normal that I need to get the PhotonView of the GameObject I'm trying to call the RPC method on?
So if I'm trying to call an RPC method on a player from a game manager, I need to get the player's PhotonView?
I don't use rpcs, but seems reasonable to want to do that.
Yeah, you need to get that exact PhotonView.
I personally used events only when I was still using PUN.
PUN doesn't have the concept of LocalPlayer like Unet though. A player can own any number of objects and send rpcs from them.
Hello my names billy a game developer/ concept artist, I need help on my project texturing a few 3d realistic mutant creatures for unity anyone here have experience on that field?
This is the multi player networking channel, probably meant that for a different channel @uncut marsh
Hey guys,
Is there anything like connection tokens or something to pass data during connection in Unity.Networking.Transport?
hey everyone .. I've been searching for a while on how to implement the networks of an MMORPG and the only results I've reached
so far was using SpatialOS so I'd like to ask for your opinions on this matter and what the best approach would be.
Have you made any kind of finished or somewhat finished basic MP game?
Starting in with an MMO = kiss 2 years of your life goodbye with a high likelihood of abandoning your project half finished. I strongly recommend AGAINST beginning your networking journey there. @clever quartz
Lol I figured as much
I'm literally trying to make a monopoly-type game to play with friends because the monopoly on steam is the laggiest game I've ever played
hello I join this discord to know how I can get the link api
like this https://discordapp.com/api/invites/discord-api
I haven't .. I'm a junior computer science student with little background in networks so I'm hoping this gives me even the slightest advantage and
even if I gave up half way it would still count as experience so I wouldn't really consider the process as useless @jade glacier
what I would really like to know though is how to start with network layer and what tools to use
I would still first run tutorials for some of the more popular libraries, like PUN2, Mirror, Bolt - to get your head around the basic networking for games concepts and problems.
I always recommend to try and make a version of 2 player Pong that plays reasonably well over the Internet first. It will teach you the paradoxes involved in networking that you will be up against - before piling too many challenges on top of that right out of the gate.
an MMO is the deep end, and you will have so many broken parts at once you won't even know where to start.
Break it down into learning the small bits of what goes into game networking separately - and then once you feel you get it you can try to pull those all into an MMO.
I agree completely. And it sounds like you want to do it for learning and employment purposes. In both cases, finished products are much more valuable.
And you're not going to finish an MMO alone while still studying
You can break it down into smaller bits that later can find their way into an MMO. But seriously. Try to make 2 player networked Pong that survives 150ms pings and 10% packetloss. You will learn volumes from trying to do that.
All of this also isn't even touching the marketing side of MMOs. They require lots of users to even function as planned, and lots of users require lots of marketing and budget.
okey great I will do my best to get more familiar with the basics and the fundamentals so that I'd have some base knowledge when starting with the mmo
And to the point of a portfolio, you would get FAR more mileage out of a very small and tight study of some mechanic applied to a networked game, executed with genius.
Shitting out a sloppy barely functional MMO is not going to impress any networking people who are hiring.
The best portfolios I have ever seen are a lot of small, very intelligent studies of networking problems, and experiments produced that solve them in interesting ways.
So step one, make Pong and start to experience the problems we mean.
Step two... start coming up with genius ways to solve them.
@night plover yeah I'm doing it for the fun and the experience and I'm not really alone there are many people I know who are willing to help so implementing the base game is kind of my goal now
We can only tell you from experience and what we see here. The highway of this channel is littered with people showing up day one with "I want to make an MMO...."
And they all vanish
@jade glacier yeah I understand you clearly .. a half working mmo won't be impressive in my resume at all
And will just not be fun... at all
I know how difficult it is to pull it off and I know that it's extremely hard and complicated and that I most probably going to give up half way through, I know of the amount of people who wanted to do something similar and failed .. I don't mind failure because I really don't think that those people who vanished have failed .. they have gained some knowledge even if it's something insignificant as completing 1% of the game
You do you of course. We are just telling you what we know and see as networking devs ourselves.
so far it has been extremely fun for me and my other friend .. facing new problems and even struggling with the code :D
We have this exact conversation in here like 5 times a week. You might be the exception... who knows.
Networking is a lot of fun, for sure.
i'm not lol
MMOs can be fun as a graduation project after getting a handle on all of the smaller components first. But starting right into one to begin with. Strongly discouraged.
I really hoped being a c.s student gave me advantage .. looks like it didn't
not really, that will help you on the transport layer, but you don't do much work on that layer anyway.
Those libs are all made.
Game networking is largely a gaming problem, not a CS problem.
The core of it being how to reduce a game to States and Inputs, how to serialize and share those over the network, and the hardest part, how to hide the latencies involved and deal with lag/loss.
that's new to me
Making a system that is efficient and resilient has a lot of layers of complexity, and lots of paths you can go to solve those paradoxes and such.
gafferongames.com is a good starting point
okay, how would i get two game instances, both connected to the same network, to sync scenes? something like the unity matchmaking or photon, but LAN only?
well I'll go for your advise so I guess my job right now is to fully grasp the fundamentals and start on small projects first
I do have a question though .. is there any reason to why I shouldn't use SpatialOS .. it looks fairly easy and I don't have to do any coding related to networking
at least not complex code as far as I understand
Isn't SpatialOS mostly backend stuff?
I'm not sure I'm still trying to understand how it exactly works
At this point I would try lots of things. Do all the tutorials you can... That will really get you down a good path.
okey great .. checking the popular libraries you mentioned earlier and making a 2 player pong sounds like a good idea to understand the basics
really appreciate it .. thanks ^^
Could anyone link me, some docs regarding async sockets for client side in c#?
hmm, i've just been googling about SpatialOS and came across their dispute with unity. I'm still uncertain. Can anyone clarify if we're allowed to run our server in the cloud without a separate unity license?
@slim ridge I followed that example like in many ways, from the strict one, to the creative one lol. I mean, i encountered lots of problems with my game using that example, WaitOne() makes the Unity Thread wait forever. Right now i'm using this class https://hatebin.com/ujwazvntnt for the Client.
I really don't know how should i implement those methods, in order to recieve all data without blocking.
Btw my class is ugly, i should take my time to adjust it
where's it blocking now?
it's not blocking atm
but sometimes it doesn't recieve data if i call RecvData in a while loop for example
The server is a python asyncio server
i havent used async sockets yet, but don't you need to EndReceive at some point?
oh, i see it there ๐
that bool that i set to false, is just to avoid multiple recv on to another
that erase the response
but since it's async it could be happening at the wrong time
what would be the best approach for LAN multiplayer between PC and ios/android?
but since it's async it could be happening at the wrong time
@slim ridge what do you mean?
there could be two RecvCallback going at once
That is the class that calls recv and handle all the events
@gray ether do you need a server or is one of the clients acting as the server?
one of the clients would be hosting
pc is in vr, i only need to send a render texture, probs dont need multiplayer but want to add more features on mobile than in vr
you'd have to build a server/client for each OS
use a python server ; ) hosted on a Linux machine
no, i dont want servers
this is only for two players on the same network, but if i had to, i would be using python ๐
thanks @slim ridge
I'd recommend picking one then writing a server/client for it that encodes your RenderTexture and streams it
since it's LAN, you shouldnt need to worry about compression ๐
id probs just use something that supports udp
How I can do it, that if the PhotonView is mine, that other Entities spawns as if the View is not mine.
any recommendations for something that works on both?
public class WarriorSpawn : MonoBehaviour
{
[SerializeField] private Warrior Prefab;
[SerializeField] private List<Enemies> enemies = new List<Enemies>();
public void Summon()
{
Warrior warrior = Instantiate(Prefab, new Vector3(-100, 190, 0), Quaternion.identity);
// miner.AddComponent<Miner>;
// Miner m = gameObject.AddComponent(typeof(Miner)) as Miner;
warrior.MoveTo(enemies[0].transform.position);
}
}```
@clever quartz If you are on the PC be sure to test your gameplay using clumsy.exe - you really want to see what latency and loss do to your system.
i dont know any, awesomepants, but something you might be interested in is multicast networking it seems appropriate for your situation
@tropic adder store it as a prefab?
Yes
thanks! i'll look into that!
ok, no, i only need communication between two devices, a pc and either an android or ios device
unicast is enough
@jade glacier i will do that .. it's just that I want to set up the multiplayer for now and improve the connection later
Hello?
I haveno idea GoldGuy it's hard to understand your question ๐ฆ
I want that:
If Player1 spawn a Warrior, the Warrior1 have to Spawn on -100, 190, 0. And if Player2 spawn a Warrior, the Warrior2 have to Spawn on 800, 190, 0.
What are you using for a networking library? @tropic adder
Photon
PUN2?
You should be using the instantiate built into that for spawning if so.
What you pasted above has no networking code, so not sure what you are trying to do.
https://doc.photonengine.com/en-us/pun/current/getting-started/pun-intro Have you done the somewhat mandatory first reading?
Hi, so im working on a server-client prototype where the client is always an android smartphone. Handling messages and stuff works kinda good. But im facing one problem. The client randomly disconnects, but only when i test it with a android build using Console everything works perfect. Actually i have no idea why this happens. Im using sockets and tcp protocol. Thats my client net code https://github.com/SradnickDev/Sockets/blob/master/TCPServerClient/Client/ClientPeer.cs. Or is there anything i have to take care when dealing with android and local wifi?
@weak lava you might get more mileage using a websockets-based solution that already includes connectivity lifecycle, like SocketIO
if this is more for educational purposes, you should start with an environment where you can see what different connection states mean
like start with two computers on wifi. try moving one away from wifi. try sleeping it. try turning off the wifi adapter. etc. you'll be frustrated to discover that for these very real, concrete things, you will not at all get predictable connection states, exceptions, events, etc.
exactly zero people in this chat room, except maybe the PUN author, will know what would happen ๐
i don't even know
ya the android smartphone can change networks any time it pleases
@amber trench alright, i'll not change to any third party lib, its more for educational purposes for my next project. That means i'll just keep tryin and testing stuff.
you might want to see how socket IO works then
the answer will be "heartbeat"
basically every networking solution that has to work in a general way, especially for mobile devices, sends a heartbeat every X seconds
to determine whether or not there's a connection
"but TCP" doesn't matter
every rolled-your-own solution eventually uses UDP, because it's connectionless, and the heartbeat is a superior way to determine whether or not a mobile device is connected to a server
Clash Royale for examples uses UDP as its underlying transport
mobile devices have very good support for UDP, especially as their internet interfaces may change
or their sleep states may change
so i'll be honest, a stateful TCP connection is a dead end for you, unless you do a Socket-IO's level of work to manage the lifecycle of the connection
Well i switched from udp to tcp because of the reliability, actually without packetloss where a problem. But im gonna check UDP next after studying Socket IO. I also had a heartbeat implemented but since im sending continuously packets due to testing, i deleted it, will remember to reimplement in when changing to udp.
You're gonna have to share your code so that someone can help you.
you have set your NetworkIdentity on your player prefab to be localPlayer?
The client can't move meaning your controllers aren't working locally on the client?
Sounds like your hasAuthority check on your controller might be wrong.
How are the players being spawned
Hello, im looking for someone good with Photon Bult integrations, paying good to make a photon bolt integration and adaptation in my game.
Dm if interested, cant find someone outa there
does anyone know why a UnityWebRequest GET call would perform syncronously (aka, blocking/freezing the app) in a WebGL build?
@frozen canopy You have been told multiple times that we don't do job advertising here
@worldly cedar How are you doing the request?
Some info about UnityWebRequest on here https://docs.unity3d.com/Manual/webgl-networking.html if you haven't seen already.
ah, ive posted the wrong one, 2 secs
network problems in 2 different projects haha
this is the main part of the code @spring crane
//Add auth header
using (UnityWebRequest www = UnityWebRequest.Get(url))
{
www.SetRequestHeader("Authorization", "Bearer " + accessToken);
yield return www.SendWebRequest();
resultText = "{ \"Items\": " + www.downloadHandler.text + "}";
}
it works, it just freezes the app
Few alternatives here https://stackoverflow.com/questions/52514829/unity-webgl-unitywebrequest-data-handling
Not really sure if something is up with yielding www.SendWebRequest()
right? Ive got a few other calls implemented exactly the same way and they arent blocking at all
but thanks for the links, helpful!
is anyone familar with the socket.io asset for unity? I'm having some problems sending json server with a seemingly simple emit command. everything is working on the node.js as I can send messages between two browser windows. i can also see that unity is making a socket connection and the beep() method that is provided (does not send data, ie socket.on('beep', function() as opposed to socket.on('chat', function(data){) which works correctly
I want, that if the PhotonView is mine, my Prefab Miner spawns as a Child of the empty GameObject: Player1
And also with Player2
Here is the Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class MinerSpawn : MonoBehaviour
{
[SerializeField] private Miner Prefab;
private PhotonView photonView;
public void Summon()
{
GameObject ParentGameObject = GameObject.Find("Player1");
GameObject ParentGameObject1 = GameObject.Find("Player2");
Miner miner = Instantiate(Prefab, new Vector3(-100, 190, 0), Quaternion.identity);
photonView = GetComponent<PhotonView>(); //Line 21
if (photonView.IsMine)
{
miner.transform.parent = ParentGameObject.transform;
}
else if (!photonView.IsMine)
{
miner.transform.parent = ParentGameObject1.transform;
}
}
}```
Please nick me, if anyone have a solved Version of this Problem:
NullReferenceException: Object reference not set to an instance of an object MinerSpawn.Summon () (at Assets/Scripts/MinerSpawn.cs:21)
which one is line 21?
ah yeah
well that's weird. I'd understand if the error was on the following line, since IsMine can't be accessed if the object if null... But on that line, the only possibility is that this would be null, which would be even weirder
are you sure the object hasn't been destroyed once the function is called?
Yes
because that would cause this to be null (from Unity's point of view)
then it's hard to tell..
I did it before
private PhotonView photonView;
// Start is called before the first frame update
void Start()
{
photonView = GetComponent<PhotonView>();
if (!photonView.IsMine)
{
foreach (var script in scriptsToIgnore)
{
script.enabled = false;
}
}
}```
And there it worked
doing that in start is only going to work if you spawn that object after connecting
that will not work for scene objects
I mean the PlayerView.
If its being spawned after connect, that will work yeah
You can make that work for scene objects as well just by changing from Start to OnJoinedRoom and OwnerChanged
Ah. Ok
anybody able to answer a playfab question? (i asked in #๐ปโcode-beginner already and dont wana double post it)
should i use Unet or build my own server api for my fps
or is there another api option better then unet
There are a lot of options better than UNET. I would say all are better than Unet at this point, since its obsoleted.
I am sure you are about to ask "Which is best"
@toxic lintel any protocol you write is going to be easier to debug and modify than a plugin like unet, but perhaps what you're looking for is photon
Photon is several products. The only one really suited for FPS is Bolt. It's designed to make AAA fps games, but it does have a learning curve and it does tie you to Photon.
Honestly though, what you are asking gets asked about 10x a day here.
the correct answer is none of that.
If you have to ask, it means you haven't done tutorials and build any networking experiments - so you should not even be trying to think about making an actual game yet.
ye
The question itself indicates you aren't ready to ask that question
Networking has a half dozen layers
the transport being the lowest, which is just connections and sending byte[] arrays around.
tcp chat is a good entry to socket layer programming ๐
Game networking is about dealing with the paradoxes of latency and loss - and how you architecture to make that manageable.
chat is a good intro into the transport
alright
but don't blur that with actual simulation and state transfer - those are a completely different set of challenges.
ok i dont even know what these are yet
yeah, which is why it is WAY too early to be asking about the best way to do an FPS really.
Do tutorials for some of the major libraries
i will
PUN, Mirror, Bolt for the middle layers
networking seems like a good way to go once you have a good grasp on datastructures anyways
Bolt is the only full stack available to you, and is likely the actual best answer for making a real FPS... but you won't learn much from it alone.
and how basic OOP works
yeah, none of that is really going to help you down this path.
Networking at the game level is a lot weirder
You need to know those, so you are ready to get into networking
But you really have to take some time to read up on the paradoxes you will be trying to solve
PUN, Mirror, Bolt these three right
they are the more popular libraries yeah
Bolt is the only "correct" one
Pun/Mirror and such are a couple layers on top of the transport
PUN is relay based, Mirror is basically UNet in architecture.
so that would be similar to things like ftp?
Totally going down a wrong line of thinking there
The transports typicaly work using either TCP or UDP
but what they are doing is always the same... they establish the connections, and they send byte[] arrays as messages
With optional reliability settings if its UDP
but that is about all that is going on down at the bottom of real consequence.
its really helpfu;
then we can help way more
helpful
gl
If you try mirror, they have their own discord channel
just be aware that that library will encourage some VERY bad networking practices
So take advice given there as debatable. But still very useful.
ok so im trying to understand how to RequestLeaderboard from the playfab api I thought maybe I was supposed to write my own function for it like this
C# Code blocks:
//Get the players with the top 10 high scores in the game
public void RequestLeaderboard()
{
PlayFabClientAPI.GetLeaderboard(new GetLeaderboardRequest
{
StatisticName = "HighScore",
StartPosition = 0,
MaxResultsCount = 10
}, result => DisplayLeaderboard(result), FailureCallback);
}
public void Displayleaderboard(GetLeaderboardResult result)
{
//show results in ui
}
``` here are the docs, Im looking at the code under RequestLeaderboard https://docs.microsoft.com/en-us/gaming/playfab/features/social/tournaments-leaderboards/quickstart
basically im not sure how this "DisplayLeaderboard(result)" is intended to work since it doesnt exist. im assuming I need to write that "DisplayLeaderboard()" function myself. but GetLeaderboardResulsts is under PlayFab.ClientModels wich i am using. and obviously the code i pasted doesn't work
i still dont get it. You don't find what you need in result or the function isnt even called ?
https://docs.microsoft.com/en-us/rest/api/playfab/client/player-data-management/getleaderboard?view=playfab-rest#getleaderboardresult
looks like it's made of an array of PlayerLeaderboardEntry
DisplayLeaderboard in the line under max results "doesnt exist" even if I make that function myself
what is pun good for, @jade glacier
emptying your wallet
?
looks to me like PUN distributes your networking on their cloud
something you'd buy if you can't afford a cloud computing engineer
i know bolt is good for fps, but why is it better for that
probably because of the mecanim replication, state replication
you dont necessarily need bolt if you have a slower type of real-time fighting then, right?
not slow slow, but not fps headshot dead fast
Pun is relay based, so it basically removes the server from the equation - for better and worse. @empty yew
So it is not good for competitive authoritative game types, unless you start writing server plugins.
so each client are just connecting to eachother
I was using PUN for a magic based fighting game solely for friends at school. Should I cut my very short losses and swap to bolt?
I missed the start of the convo... what game type?
And is the goal to learn, or to get to market?
PUN for most fighting games in its vanilla form isn't going to be ideal.
Fighting games if you mean like Tekken really want to be extrapolative and deterministic
This is basically the start of it lol
FPS style gameplay but with magic
Not for market, just for the experience and to hopefully have a finished product i can play with my friends
I don't need it to be perfect, just working lol
Just be aware of the architectures and how those will play out
in the case of fighting games, state transfer with client prediction and extrapolation are going to make for some "interesting" timings
are you still on tekken type games
in that case i'd say go for it with PUN or whatever you want until you encounter these problems, but a professional project will require much more forethought
But worth trying, just to see.
Most of getting good at game networking is learning how to hide the timing paradoxes
or just have the game be hilariously bad
and embrace the shittiness
PUN should work then?
or should i swap to bolt for the better chance of dealing with less lag
i literally have only connected to master and shared variables. I'm not that far in
try both
I guess I'll stick to PUN until I discover what issues I can't get over
Thank you to both of you
np
If you are making a game that is typical FPS (missed that it is NOT a fighting game), you will mostly have to deal with not having an option for server authority. That means you really are going to be leaning on client authority.
@empty yew
For that type of game Bolt is the only full stack option. Alternative is to create your own client prediction system on top of a server based lib like Mirror/MLAPI
Then I'll swap to bolt, considering that the second sentence there sounds awful
if your friends cheat you can reach over and smack 'em
I'll probably just referee so I can keep an eye out for bugs and what not
It's meant to be a MOBA mixed with RPG elements, be it killing monsters for loot/spells and farming herbs for potions that can be stolen
I would switch to Bolt sooner than later if that is the plan at all
Since it has its own physics/controllers that make all of this possible.
The reason server auth is so hard is it requires the ability to rewind and resimulate properly, and to do that the system needs to manhandle inputs and states in a replicatable way.
Yeah, I think that would be for the best. I stopped working on the networking mostly because of school, but also I want to create everything in single player simply to have that out of the way.
So by the time I finish that, I'll have forgotten PUN anyways
PUN of all of your options for an FPS is probably the WORST one - so I wouldn't get too deep yeah.
Hey, I had a question about UNET right now will it still be working later on if they removed it and if they make a new API with better Features and functionalities will my project be upgraded some how and can i use these Features? I heard it might be removed should i start with something else?
The new one is not even remotely related, there will be no upgrade path.
You would be better off moving to Mirror now, its going to be the upgrade path for Unet for the foreseeable future.
@echo flax
Okay but if am in a middle of a project with UNET or finished one do i need to remake it with Mirror or is it a small difference in like the plugins and the extra features ?
What do u mean with git am sorry?
@worldly cedar unitywebrequest will use the content-type header to determine the encoding of text. for example, content-type: text/plain; charset=utf-8
I have tried both text plain with charset utf-8 and application/octet-stream, no luck. Someone on stack overflow has commented saying that it may be sending it in a url form format, and suggests using UploadHandlerRaw, so im gonna give that a go
And that seems to have fixed it!
great ๐
What's the best option for a mobile multiplayer game?
And by that I mean what route should I take for the multiplayer aspect and how would I go about doing this? For learning sakes.
What kind of game is it?
What platforms as well
Do you want to learn to create multiplayer games, or how to write a multiplayer framework?
Honest questions... Without more details about your goals you'll receive totally random answers
Drive-by
So i have 1 one body on the bottom there is a walking animation etc, but on the top i have script that makes the upper body to look where the camera is pointing, i tried adding photon view (transform viewer) and at the ended looking terrible how do i achieve that
@me if you know the answer
The vanilla animator sync in PUN is a bit limited, but what you are describing indicates some kind of an ik-like thing you may be doing you need to serialize and sync whatever that script is doing to the upper body if it isn't manipulating the player through the animator. @delicate kindle
You also need to use the animator view if you are using an animator.
there is a empty transform that is parent to the upper body
if i sync that transform it will glitch and it will look strange
it will have delay
etc
You have multiple issues it sounds like
And syncing requires buffers which create some last as well
No idea what I am looking at sorry
Delay in what?
it stretches' the point
compare the first video with the second one
for example because i am syncing 2 transforms, when i move, the 2nd transform has small delay
Yeah, you have something of a mess going. I would start over and get just the basic animator and transform syncs working before trying whatever you are doing to the upper body.
Yeah, you have bugs. Looks bad.
Yup, you've got issues for sure
so if i move transform 01 forward after 1 sec or something the 2nd one will move after 1 sec or something, but only when i am syncing with photon
so my question is how do i sync 2 transform points, but to be synced and don't go all over the place
You are mixing timeframes somehow. You definitely are doing one or more things wrong there.
Too big an open ended a question sorry. Without having your code in front of me to see how you Tangled things up like that, I can't even guess how to fix it.
Well it has nothing to do with the code, maybe i should contact Photon, or syncing it every frame without waiting to change position and then sync it
Typically you do all local animation and transform handling, and the syncs replicate that. You are doing something that is fighting with them most likely.
I am photon PUN.
What are you using for a character controller?
Wdy?
?
I would during dev have it update continuously yes, to be sure its not a weird timing issue
you can also try the SNS stuff, which has much better syncs
I'll try to update it continuously
i am 78% that is going to work
so yea
thank you btw for the help
The SNS syncs are tick based, so they ensure that transform/animator syncs happen on the same ticks exactly as they were on the owner. If that is the problem they will help. If the problem is your controller is doing some weird stuff on clients, then you have to track that down.
https://docs.google.com/document/d/1ySmkOBsL0qJnIk7iN9lbXPlfmYTGkN7JFgKDBdqj9e8/edit SNS I am referring to, which is an extension library for PUN2 that is in beta. @delicate kindle
How do you get Unity UI to update based on what a player on the other screen is doing with said UI (Im using Photon PUN)
Same as locally. You have fields that represent the state, and UI gets callbacks when things change.
You just have to sync the backing fields with rpcs or such.
ok
I wana set up a leaderboard / log in system and I dont think I have the time / skill level to learn it from scratch. I'm setting up playfab currently but it doesnt have a clear pricing structure that I can see. Does anyone have any recommendations?
ur right. "other limits apply" how ambiguous
but looks like you can get by for a small project without paying
@mint acorn I've seen that said before (which is why I'm worried) but I cant find any limits that immediately seem too small (at least under my 10k registered user limit)
any idea what usually runs out first?
storage i'd guess
and probably these "capped at number of development mode users per title" thing
ATM I think im gona risk setting up with playfab and hope for the best TY @slim ridge
@dry wave what were you going to write your server in?
Probably Java for now, and then check if something like NodeJS could be a better option
Of course if there is a framework to use I can just use that, just trying to avoid some weird in-between solution
it's a hard problem to tackle. in regards to networking and unity, it seems photon suite of products is the only player. (maybe spatialOS?)
or you could take the same route as me and write your server in an environment that makes sense to you and bend unity to your will to achieve determinism
What I want for now is just so that my sync is actually there. So let's say I interact with a character, that I can check if the player is actually next to that character and not somewhere completely different
And then I don't have to delve into half a year old code later to put the sync in
Photon does peer to peer no?
& yes that's what I want to do, just have Unity as a front and send the data to the server, have the server handle the rest
The issue is that I have no clue how to for example, make other players appear in someone's Unity front
I can send data, I can do stuff with it, I can do security (basics not advanced), but I don't know how to do the sync back to the clients
ah ok, i got a good video for that somewhere...
Also I don't know if APIs or Websockets (or something like that) are a better option
your solution will use TCP or UDP sockets
Is that a question or a statement?
ok i lost the video ๐ฆ but the basic concept is:
clients send their input to the server
server propagates this to other clients
Yes but how do you send back position information around a certain player from the server
Like do clients just have info on ALL players in the game?
I'd assume only the ones that are nearby
If all it's quite easy though ๐
no, server should have authority over everything
it's pretty easy to intercept and modify packets coming from your computer
No I mean does the server send ALL player info all the time to clients, or only the player info of players nearby
I didn't mean that one client sends its info to the others
the server is telling clients what's what. you could do both ways you just said
For example, I have an Interact() method now, the player uses this to interact with any interactable in the game. There I'd send data that the player is attempting an interaction, and have the server check if that's possible, and what the outcome is.
That I know, but not what to do with moving parts not decided by the player's interactions
Yes, but how do you know if you should send certain info to a client
Like, when does the server send info about player A to player B
i think what you're talking about is determinism
which means, given the same input all clients will result in the same output
Also, should I use UDP to update other player's information and interactions in general in the world (e.g. moving NPC) or and TCP for what my player does, or both TCP?
which means, given the same input all clients will result in the same output
@slim ridge Yes
then all your server has to say "this thing is happening here" and all clients will know how to handle that
Yes, but that part I know
But when to send the info I don't
If player A click on a furnace I know he wants to use the furnace
If player B moves closer to player A, how do I know player A should see him?
Also, isn't it insane to send player B's transform every x ms?
An NPC can move in the game world and then be corrected by the server, but a player can't
the simulation has to run on the server too
Yes, it will
and you'd write the logic of checking proximity into your server
So it's like player B is 100 distance from player A you send the info in every call?
no, just the input since both clients will determine the same result
So all players have info on all players?
instead of sending the transform each frame you'd send one message that says "move from here to here"
But that's the transform no?
How else do you know?
Thanks for helping me understand this better btw
Unless you are deterministic, there needs to be a state authority and that needs to replicate to all clients.
Couldnt tell by browsing the above what the question was.
Introduction Hi, Iโm Glenn Fiedler and welcome to Networked Physics.
In the previous article we discussed techniques for compressing snapshots.
In this article we round out our discussion of networked physics strategies with state synchronization, the third and final strategy ...
it's a complicated article but probably explains better than me
listen to emotitron he knows this stuff better than me
It's all pretty boilderplate advice, same as others will give on the topic
@slim ridge I didn't fully read it yet, but yes this is what I wanted to do. And this works perfect with my game since its click to move, meaning that I can send the destination. My question is more, when to send things. I don't think I should send all player info each time, only the nearby ones. But what is nearby? And what is the most optimized way of sending data, e.g. Tcp websockets (how does that work in unity+self made server)? @jade glacier
Sending a destination can be tricky, since that is relying on determinsm to play out the same on all clients
Boilerplate is fine I just want a system early on and then optimize it later, just to already send the correct info and not having to redesign my code in half a year
@jade glacier how would it not play out the same?
You need to read up on what determinism means for that answer
That question would literally take me a day of typing to explain in generic terms
If you can remove all non-deterministic factors, you can do what you are saying. But that is not easy.
I understand determinism, or at least I think I do. But I don't understand how if all elements are the same in 2 client that the character would not move the same
If you have good sources, even a book, please tell me. I'm really okay with spending time on this
read all of gaffer on games articles xD
All elements are 100% certain to be deterministically the same?
Then sure, will work great.
But, I seriously doubt they will be if you haven't gone to great lengths to ensure determinism.
Don't understand why not, or at least close to
Yeah, thus why the research time is needed
determinism is a huge topic
Or, just try it
and see how it works out
Alright I will look into it more
Is there a video/benchmark result of PUN? I see Photon has some videos on youtube where they show quantum framework in action by displaying 2-3 clients at same time and this looks really good - no noticably lagg, very smooth and fluent.
Maybe it's something misconfigured on my end but i wasnt to impressed with the multiplayer experience using PUN, it was noticably laggy. Quantum is probably really smooth because it uses the deterministic technique (and probably other stuff too).
So i just want to see if someone have taken the effort to put up a benchmark result/video of how good PUN can be using simple games.
Determinism doesn't have anything to do whether there's lag or not
For information, i tried the PUN on a simple game where very little is synchronized. Only a cube's transform component per player is synced.
Really? Isnt it supposed to do the next synced move locally first, then correct/verify it by the actual network later on, and this is what creates the smooth movement?
I forgot a little about what deterministic simulation is again, i somehow thought it predicted the state for remote players which is impossible, when it actually predicts the state of the local player in a server authoritive model. The local movement is fine, its the remote movement which is laggy.
Nevermind my request about PUN in action, i tried out some games using it and its pretty good so the laggy state is on my end ๐
determinism vastly reduces the amount of data you need to transfer
it allows clients to predict state because determinism means the same result is achieved by the same input. (you only need to transfer input data)
So instead of sending the transform component, you just send the input so recieving clients use the input to move the player "locally"?
yeah, you send the initial state once when it's relevant to the client and they can control it using input data after that
I can definitely see how that is reducing the bandwidth on larger games that synces alot of data. I was wondering about this the other day when thinking about how larger and complex games that synces alot of data deals with the bandwidth limits.
i'd recommend examining the bandwidth usage of several games. You'd be surprised how bad some of them are
Yeah im actually trying to get info on it now. Pun for example has 60GB bandwith limit in total for 20CCU. Is that accountant for outgoing and ingoing bandwidth? And what is the rate limit of the bandwidth?
@burnt axle
The local movement is fine, its the remote movement which is laggy.
Not really, both are predicted, so neither is laggy
predict/rollback determinism (whose simplest possible implementation, GGPO, is popular with fighting games communities - aka rollback netcode) uses input extrapolation to predict the whole simulation (not only the local player)
This is what quantum uses (I#m one of the engine developers)
@slim ridge prediction can be done WITHOUT determinism... just transfer input and do local extrapolation
What you gain with determinism is the ability to transfer ONLY input and get both Prediction (via predict/rollback) and synced results (via determinism over verified frames)
I assume Rocket League isn't fully deterministic, but it does extrapolate for sure.
I believe it does state transfers
I would say the "smoothness" of Quantum is actually counter to what it is really doing. The constant resims if shown to you in their raw form would be jittery as F
@gleaming prawn Thanks for answer.
State Transfer with interpolation is inherently "smooth" but that is because it is working with known historical states rather than extrapolated guesses
@jade glacier physics objects are inherently Smooth, because simulation of loose objects is always driven by physics, not network.
What could be jittery are remote player movement in those moments they change direction
I assume though until a missed input prediction, if that was shown immediately as the new sim result it would lurch
yeah, was referring to that
THat we smooth out using an error-based interpolation mechanism
I think we are on the same page
Just clarifying that determinism wasn't making smoothness, that is still the lerping operations
But we're talking about 2-5 ticks of rollbacks... SO it's tiny smoothed fixes
yep
I just observed the bandwidth usage of active gameplay in CSGO with 10 players, it only used 50kb at average. My ISP provides 50MB up and down so it only uses 0.10% of available bandwidth.
CSGO AFAIK sends full state snapshots, with delta compression... But their game states are also tiny
In comparison, a 4K video on youtube recieves 3000kb/s ๐
imagine a game with states as big as 4k video frame LOL
Lol. And netflix used the same amount as youtube 4k video despite being 720p (maybe 1080p, didnt look that good).
video streams buffer WAY ahead though and don't skate the razors edge of trying to get and consume packets with as little buffer time as possible.
Hey guys, does anyone have any experience with PUN's Photon Animator View? I cannot get it to work for the life of me ๐ฆ
I have a GameObject prefab which has an animation for rendering a 2d sprite walking. The Photon Transform View is working fine, however no matter what settings I utilise for the PAV none seem to work. This is what it looks like - I'm not sure if using 2020.1 is causing the problems
can't speak to 2020... haven't even touched that. 2019.3 is buggy enough for me already. ๐ Is the animator just not replicating ANYTHING at all?
The animation works locally, just not on other clients
The vanilla pun animator isn't the most comprehensive but it usually gets some kind of working result.
You can try the beta SyncAnimator which is quite a bit more intensive, but you do have to add the whole beta to your project to try that, so I would save your git first.
Before trying that - do you have all of your controller code disabling when not IsMine ?
ie- you are sure your controllers aren't stomping on any syncing remotely
Thanks! I do have the controller code doing so. I may also try the legacy one
I did last test that an hour or so ago though so I shall double-check beforehand
Converting stuff not built specifically for networking to do networking is usually a game of hide and seek like that.
Yeah, I only have basics so I hooked it all up today and this is the smallest thing not working but it's enough to drive me insane ๐
Some controller code uses triggers, which might not serialize right, since they happen to fast.
SNS has passthrough methods you use to catch those. I don't recall if the vanilla PUN animator view has them or not.
Yeah I've avoided triggers
So in my "Update" function for the controller attached to each prefab, it hits IsMine as often as !IsMine as expected
Ok - so I done some detection of if not IsMine and looked at whether the animator.GetBool that starts the movement animation was true...it was recieved false on the client, so there seems to be some kind of issue in that property being transferred
...so it randomly started working...thanks guys!
Wacky
@jade glacier @slim ridge So as requested I looked into determinism, and read a lot of other articles too. I understand better how everything should work, but I can't find any articles on what data best to send. I know what to send TO the server, but not what to send back from it. What is too much? What is required? I can't those answers. Do you have any sources I could read?
You ideally are just syncing player inputs, that is one of the main advantages of a full deterministic system
Yes, that I understood indeed
But what if a player interacts with an NPC for example. How much of that NPC data do I send
That's what I don't know yet
Or if another player uses an animation. Do I just send the start of it, or do I send it frame by frame
The server is just the final word on what each player inputs were each tick
To ensure every client has the exact same input history
But I understand the input, but not the output
There is no output, that is the point
Then how would stuff be displayed?
Locally simulations produce new states
By simulating each tick
And that produces the state results
But if Player A moves, on Player B's screen. A local simulation is not doing anything if Player B doesn't know how Player A moved?
So there is always some kind of output
But I don't know what exactly that would be
It knows what player A's inputs were
server would tell player B when player A is close enough along with player A's state (as it relates to player b)
@jade glacier The server knows yes, so what do you send to the other players
The inputs
initial state and whatever input comes after that
@slim ridge What does state entail, what data is in that state
Every player gets every other players inputs
everything the client can't figure outon it's own
@jade glacier You just said there is no output?
That is output from the server to players
I'm out of ways to reiterate the concept, sorry
for example: for simple objects that change position the initial state would just be a position
So what exactly would be in that output, position data or input? Because if it's only input how would a player know if an NPC moved
The same way it knows anywhere
a more complex state might include animation state, identifiers for different assets that need to be rendered or associated with it, etc..
So you would send, for example this (let me write something):
Npcs are deterministic, and their actions are produced by the simulation..
The same on all clients
another way to describe it is like designing a conversation between your server and clients
{
playerA:
position:x,y,z
animation:0,
rotation:x,y,z
...
npc1:
position:x,y,z
animation:0,
rotation:x,y,z
...
}
Or not?
yeah
And you do that for any NPC / object / player in the vicinity of the player yes?
On every frame
When applicable ofc
yeah you'd have some loop on the server that decides all this
Only the changed ones
Maybe I didn't explain my point of view correctly yesterday then
I'll look into that Azure link you sent me, see if that helps me set something up, otherwise I'll write it myself.
Thanks for the help
Btw this is a really good article: http://ithare.com/chapter-vib-server-side-architecture-front-end-servers-and-client-side-random-load-balancing/
For anyone that could use it
That's page 3 though you have to go to page 1 first
If it's full determinism, the server doesn't need to run the sim.
@jade glacier in practice wouldn't you usually want server to run sim tho?
- if you want people to join mid-game server should be able to send current game state
- if you want to record game results at end of a match e.g. xp earned or who won/lost
just wondering if there's something i don't see
If you need to account for late joins or disconnects it's useful yeah
So back with another question. Been looking even more into all of this, and found one decent tutorial which I've been skimming through to get a better view on the full setup. One thing I don't get yet though is collisions. Assuming you don't want to run a simulation of your game on the server, would you define every object in your game on the server via code? Or how would this work?
in full determinism you'd define every object in your state
But your state is just object and their transform no?
the state of one object
My question was more about how it would work
your whole simulation has a state too
Which is what exactly?
everything's transform
Yes. So my question still stands, how would that work?
Do I define all objects in code, or how would that work?
i dunno, what tools are you using?
What tools do you suggest? ๐
i can't help you with photon
Not photon that's peer to peer
Has anyone here had major issues with webRTC crashing mac builds?
photon = mommy of bolt, pun, quantum
Okay. To answer your tool question, none I assume
Pun more specifically is relay. There is a server, but it's very generic and doesn't run any simulation. It handles connections and relaying messages.
As such, it is a client authority system in most cases, unless you write server plugins to give the server more logic.
Okay. But does anyone know the answer to my question? Or do you need more specific information?
Or just a direction you could send me in to find the answer would be really appreciated too
I'm reading on a phone here, so not sure what question you are looking to have answered.
How to handle collision detection, or at least validation of a player's location, on the server side. Theoretically I understand how to do it, but how would I go about having all my objects (transforms) to check?
Would I need to define all of them in code? Do I have my game world running on my server? How would this work?
Basically if possible how do I get the world defined in Unity, but without rendering it, so I can just check transforms
For what kind of architecture? I don't know what you are making or what lib sorry.
I don't know why that exactly matters, but I'm just trying to make a simple server for my game
Most people just use the built in physics
Yes, but how would I do that without rendering anything? + Then I have to use a Unity build as a server no?
So by server you mean you are doing server authority started transfer?
Like with mirror?
What I mean is, the player clicks, the servers moves the player. The player clicked into a wall, the server should know there is a wall. How does it know there is a wall
That is full server authority then. There server has to run physics.
Yes I know, but how would I do that without rendering? ๐
- then my server would be a Unity build, or not?
By building it out as headless
Aha, I did not know that was an actual option. That already helps a lot
Has to be Unity, unless you plug in your own physics engine or simulation
Yes I expected that, but if I can do a headless build I guess that should be fine
Thanks a lot for that
Np
Oh hey there emotitron. Glad to see fellow competitors active in this chat.
Getting hammered with support requests yet ? It's been crazy month due to things happening atm.
Heya. On which front do we compete? Are you an asset maker?
Simple Network Sync and AnySync
assuming yes by the color
ah, right on
Just the usual sorts of questions, usually how to make server authority work and such.
Mainly working on expanding it to become part of core PUN2 stuff for Exit.
Oh ye, everyone wants fully authoritative movement for some reason.
The asset itself is pretty drag and drop (until Mirror pushes breaking changes on me)
So I don't hear too much thankfully on the support front
Which they did right when I came down with my fever with Covid... literally the next morning I had two emails waiting for me saying it was throwing errors in Mirror... so that was fun.
Mainly working on expanding it to become part of core PUN2 stuff for Exit.
This is great. The lack of proper sync tool for PUN2 and UNet was the main reason why I decided to roll my own.
Yeah, its a pretty common problem for the mid level apis
Damn dude, get well. I don't want your customers because my stuff is designed strictly for network programmers.
Mostly over, just lingering cough stuff. We got off pretty easy if it was it.
I only was really full on trainwreck for about 2-3 days
So no complaints
I don't get the impression we overlap much in our asset usage. I don't really make much from it anyway, it more just has a price tag to keep it from being free. Free assets = cesspool of reviews
Oh yea. I learned not to make free stuff a while ago.
Free assets = users dumping 20 free assets into a project = them then giving all of those assets 1 star for "not working"
Free stuff = free review bombing.
free stuff is great, i want a better rating system
I would have kept it free, but Unity admins make NO effort to curate.
I barely make anything these days either. It's very rare to spike over $100 a month.
If it was easy to purge that dumb negative reviews that had no business being there... I would still have my old libraries up on there for free.
About the same, I suspect the people who buy one of ours buy both.
and SS as well
Usually my help requests consists of "Tried the built in one, SS and Anysync... does your do XXX?"
Wow lol. Thanks for letting me know that.
SS gets most of the sales I think. First to market and all.
And they also really try to sell it as a business.
I literally try to convince people to not buy my stuff.
Same. I'm better off working on contracts instead of spending precious time on support. I'm basically telling them "go away, buy SmoothSync instead".
They aren't worth the $8 for me to be obligated to maybe support them later.
I'll send them your way instead now c:
I don't agree with SS's architecture choices, but it works for what most people are looking to do. So good enough.
I removed official Mirror and MLAPI support, and PUN2 they can get it basically free with the beta I have for that.
So I am TRYING to discourage people from buying it
SS is basically just lerping the position, right ? It doesn't actually keep position keyframes but just lerp them as they arrive ?
I'm not sure because I've never tried syncing assets.
Its time based and doesn't do any kind of fixed buffer from what I have seen of it.
so it is prone to rubberbandyness and non-deterministic recreation in relation to other components.
basically the same issue I have with the vanilla stuff in unet/mirror/mlapi/pun
They just execute the smoothing and lerping much better
so it does what it says... it makes things smooth.
I see. Well, honestly this was the exact thing I was trying to avoid.
But its still "bad" networking
But uh, whatever works for customers is good.
yeah, if the rest of their game isn't tied to a fixed tick and a simulation, its not going to matter much anyway
its all just squishy timey whimey anyhow... not my place to try to fix that for them.
But this approach swallows netcode quality issues. When it comes to my solution - one wrong variable or one wrong setting and you're pretty much screwed.
Jittering all over the place, sliding way off screen, sliding while idling
Sounds like a recipe for a support nightmare yeah
You name it - I've dealt with it on a support ticket.
I didn't even incorporate handling for anything time based
Its all strictly on its own fixed update based tick singleton... so all the users can play with is SendEveryX physics tick
Makes for a lot less support issues, since it basically acts like they are on a simulation.
If they arent... it still works, just less than ideal.
I see. Well mine is kinda similar, but I still detect time drift (in case of lost packets that lose time delta, temporary app freezes, etc.) and slightly nudge it into a correct timeframe
yeah, my original asset was like that
NetworkSyncTransform
but when I started to adapt that code base to do deterministic server auth stuff I changed it up to be a fixed tick without any squishiness, other than an Overwatch style handling for buffer reduction where clients would actually change their simulation rate to make the server happy.
But that going backward to SNS translated into a hard fixed tick, and the only adjustment occurs if the buffers decide they are too large or small, but those hard adjust are rare.
Going for deterministic is pricey, but always desired.
The benefit there is it is conducive to an entire system of components and such
Its not actually determinstic, I just wanted my core buffer and timing systems to play nice with deterministic when i was doing work on that.
I see. Mine's other way around. Mostly designed for trusting the client, but still work for authoritative servers.
Yeah, I think yours is in the vein of NST and SS
I made SNS really as just a gateway to simulation based ring buffers for people interested in getting away from adhoc timings
And made it possible for me to build a whole component set on top of it
Noice. At least now I know where to send people asking about authoritative setup.
It doesn't solve that problem though, its just the tick/frame buffer engine from it.
Bolt is the only working answer to server authority atm
You can't do it without manhandling the controller code and the simulation code in the networking library
and Bolt is the only one that has a layer that codegens for those
I built it trying to make a server auth engine, but I ended up having to write so much I said F it.
Getting a working client-side prediction and time rewinds is pretty much a suicide when it comes to unity, so props to fholm for getting that done.
I had to write the controller generation, the input capture, and the controller physics in order to make rewind possible. It is too much to make "just work"
He made his own colliders and such in Unity 4 to make it happen. And it was a support nightmare as a result.
So yeah, I don't touch that.
If people want real server auth, they need to learn to code ๐
I had to write the controller generation, the input capture, and the controller physics in order to make rewind possible. It is too much to make "just work"
Omfg.
I literally was recreating Bolt... so I ejected on that idea.
If people want real server auth, they need to learn to code ๐
That's what I've been telling my customers the whole time. Even I myself try to avoid server auth whenever I can afford to do that.
At least with prediction
if they want server auth without prediction, that is easy as can be. Send inputs to server... server sends states to all including the player. But that input lag is going to be objectionable.
Yeah, player experience should never be sacrificed for anything. Input lag in most games is simply not an option.
Stadia... cough
I'm not sure why it exists.
But we're talking about realtime games. There are games that aren't realtime, right ?
They have some pretty first persony games on that platform that I can't see feeling good
So uh, what are you working on besides the asset ?
Just general work on PUN2 at Exit
Noice.
Its kind of the older neglected asset since Bolt and then Quantum came along
so its been needing some love
Quantum is nothing short of amazing, looking forward to working with that.
Yeah, I can imagine that it's amazing. I've almost got my hands on it with one of the companies, but things weren't meant to be.
I was very sad about it.
But then I remembered the added difficulty that deterministic simulations imply and moved on.
Finally I've got some time working on my own project, since the world economy is pretty much paused at this point and nobody has spare money to pay for my services, since I'm just a contractor.
Game networking isn't going anywhere at least.
can I get some help on MagicOnion
@amber trench I'm trying to figure out a way to have shared data in a hub in MagicOnion
as far as I'm aware, each connection gets a separate instance of the streaminghub, even if they're in the same room
also where are a good place I can get documentation for MagicOnion?
I'm going off on their readme.md for now
the question is, how do I communicate data between the streaminghubs
In my experience you can use something as simple as a reactive collection to achieve most of what you need
@vivid owl but yeah somewhere you will simply use a field on the room? I think that will be fine
I've looked into that
but do I have a separate room manager?
like this
MagicOnion doesn't define the concept of room in itself
so I would need to write my own
which would mean that I need to handle room load balancing myself
one question
how would I make sure the two Unity clients are connected to the same pod, in a kubernetes cluster setup
Alright back on it again. Found a decent tutorial series, and also bought a C# networking book. I have a big question left though. Would TCP or UDP be the preferred choice? Most interactions are quite slow paced (think RuneScape, World of Warcraft, ...) but other interactions are slightly faster-paced, yet not as fast as an FPS (think League of Legends, ...).
I know World of Warcraft uses TCP and it's still covering 1v1 PvP in the open world, League of Legends uses UDP (I think) with a tick rate of 30. Runescape has a tick rate of only 10.
But when using UDP I'd have to make sure that things like item buys, player interactions, etc are for sure coming through right? And I could use TCP disabling Nagle to have no delay but then would I still have too much overhead or would that be fine?
@dry wave The thing that will slow you down your game is not TCP vs UDP debate but the implementation of memory management and packet handling.
@winged sun Yes I know, but I'm speaking only of TCP vs UDP right now. It makes sense that if you implement either badly that it'll slow down your speed significantally, but imagine both are implemented correctly.
@dry wave If you use UDP, how do you know if the client recieved the information?
@tribal vessel By sending ACK packets.
@tribal vessel You write the thing that TCP does by yourself.
Part of it, not all
so.. ah
TCP does more than just sending ACK, + you'd not re-send insignificant data.
also TCP auto resends data that was recived with an error in the bits. right?
dont we have to ASSUME there will be tramsisison errors?
@dry wave I use UDP because SteamNetworkingSockets use UDP. Thats actually the only reason. I can also recommend ENET C# by nxrightthere. These are both UDP and work pretty well. And the only reason I recommend these is because they are well made not because they are UDP.
@tribal vessel All that is covered in my question, errors in positioning is fine if you have a tick rate of 30 for example
@winged sun I'm building it myself.
I don't understand.. couldn't the error be the most signifcanrt bit of a coordinate?
I dont recommend doing that. but you can ofc do whatever you like.
No, a few milliseconds after you have a new position. That small amount of time isn't visible
(thanks for the explanation by the way.. sorry to jump in on your Q)
@winged sun I just need to simply send and receive data to sync clients right now. Everything on top of that is for later.
I can always replace stuff once I have an interface with a working prototype
@dry wave ENET is exactly that. The only thing it does it sends packets.
Yes but by using a library I don't know exactly how it works
Thanks for the tip though I'll for sure look into it, for now just wondering about my question above
wow is 10 years old and the networking sucks. and runescape is webbrowser game so they do things that you would usually not do.
@winged sun Abut WoW: yes exactly, networking has improved a lot of the last 10 years, so makes TCP more viable. Runescape is not a web browser game.
what runescape do you mean
?
oldschool or runescape?
Either
they are both browser games. idk what to tell you.
@winged sun Yes, sure, you win the argument. Can you now please reserve this channel for networking questions?
Alright back on it again. Found a decent tutorial series, and also bought a C# networking book. I have a big question left though. Would TCP or UDP be the preferred choice? Most interactions are quite slow paced (think RuneScape, World of Warcraft, ...) but other interactions are slightly faster-paced, yet not as fast as an FPS (think League of Legends, ...).
I know World of Warcraft uses TCP and it's still covering 1v1 PvP in the open world, League of Legends uses UDP (I think) with a tick rate of 30. Runescape has a tick rate of only 10.
But when using UDP I'd have to make sure that things like item buys, player interactions, etc are for sure coming through right? And I could use TCP disabling Nagle to have no delay but then would I still have too much overhead or would that be fine?
Have you completed a small multiplayer game of any kind yet? Or is this going to be your first?
@jade glacier No I have. But not with Unity, nor C#
And it didn't matter much back then how fast it ran or anything, it was just a small project. So I understand how everything works, but not fully what the best options are.
@tribal vessel Since you were asking about this earlier. My book says the following: "UDP has no handshaking or acknowledgment signals to indicate whether a packet was properly transmitted from host to host" The handshaking part is quite important too, not just the ACK
Ineed, and I don't see how you COULD do handshaking with broadcast packets. Or, CAN UDP be used for peer 2 peer?
You could code the handshake yourself but then you really can just use TCP
That's why my question above was purely about latency
I get the TCP part... not seeing how it would work with broadcast packets tho.. wouldn't EVERYONE see you handshake acknoledgements?
I have no idea
Maybe I could tell you after finishing the book, no clue how in-depth it goes
ok. suspect I'm just off base on what "broadcast" means with UDP
@dry wave maybe this article can shed some light, specifically the "can we do better than TCP" section
https://www.gafferongames.com/post/deterministic_lockstep/
Already read that
also dont forget you can use both
Yes, but when I looked into that a lot of articles said that's a bad idea.
You could if the functionalities are separate, for example your chat and your game systems, but having both UDP and TCP for the game system would be a bad idea.
Although I have been wondering why not use TCP to send information, and UDP to receive it?
it's fine as long as you maintain control over their concerns
TCP and UDP doing the same protocol is a bad idea
is what they probably meant
Although I have been wondering why not use TCP to send information, and UDP to receive it?
What about this?
it doesnt work that way
Why not?
you cant send a tcp request and get a udp response
Yes, but why not?
because they both must bind to a port
Also known as stateful vs stateless.
Use two ports?
UDP doesn't actually have to bind to a port per-se.
But that's unrelated to why TCP can't get UDP responses.
TCP works by acknowledging packet send and receipt on both sides, for every packet (almost).
If you send a TCP packet, you must receive a TCP ack at some point.
Otherwise the TCP sending stack will resend it, assuming it was lost
UDP has no such insurance
use TCP for things where the response is required for whatever system to move forward, use UDP for things where response is not required or can be dealt with after the system moves forward
I didn't say you can't send the ACK
They're not the same protocol. You can't respond with UDP
If you want to use two streams, that's fine, but they will remain unrelated as far as the networking stack is concerned.
So going back to my original comment
You can just have UDP incoming, for transform updates. And TCP outgoing, for player input
But would that in any way be beneficial?
you're overthinking it drissy
Depends. Many netcodes differentiate between reliable vs unreliable delivery. Some of them try to reimplement TCP on UDP to make it reliable, but that's really unnecessary imo. TCP provides the options to make it a fine choice
@slim ridge How is that?
Primarily by disabling the Nagle algorithm and using selective ACKs
you're thinking so far ahead without trying anything
@prisma girder So you'd go towards TCP without Nagle? (https://discordapp.com/channels/489222168727519232/497874116246896640/698216317211115521)
Link is to my original question (or a copy of it)
For reliable delivery I'd pick TCP over reimplementing reliability on UDP, yes. Bare minimum, the internet routing infrastructure is heavily tilted towards favoring actual TCP.
@slim ridge I'm just trying to understand everything that's all, to see why certain things would work better / worse
seeing for yourself is better than trusting ppl on the internet
If it's tuned poorly, you can get inconsistent performance, but it's not 1998 anymore
@slim ridge I bought a book though ๐ (book incudes code)
you're going from hypothesis -> hypothesis without any experiment
and trying to solve problems you haven't even encountered yet
FYI, I do this for a living. Just changed jobs but I was a cloud network architect for 10 years at a hosting provider. I can probably answer any questions you have about network protocols
@prisma girder What I'm struggling with the most is understanding when you would be okay with losing data and when not
In a videogame context
i'd do the whole thing in TCP until i can actually test lag situations and make informed decisions about what to do next
I understand it outside of that
Well that depends. If you're writing a replication system yourself, and wanting server authoritative, then you care that the server gets accurate client input.
You don't care as much about accurate position/velocity transfer from server to client, since deltas are usually small and missing packets will get corrected
Largely going to come down to your state replication model as well
^
The next big question is how many replicating objects you have, and how many clients, and then how do you plan to multiplex the streams.
If you are going for fast and unreliable, you need a mechanism for eventually getting things into agreement if something gets lost
"The next big question is how many replicating objects you have" What do you mean with replicating objects?
You can send a separate reliable channel, but you will the have to account for the asynchronous nature of the two channels.
Anything that has state in your scene
race conditions are networking hell
It's also worth mentioning, UDP really isn't that unreliable. Again, it's not 1998. Yes you need to architect around dropped packets, but you should realize that these are "My wifi is disconnecting" and not so much "Oh yeah you just lose 20% of those all the time"
Ah. I don't know if this answers it, but what I thought of doing was have all physics logic on the client as well as on the server. Then based on the client input the server would know if there is a collision or not, and then send the position of the players back. (or npcs etc)
you just have to account for lost packets, and make sure they aren't going to break anything
like a lost transform state is easy to deal with... a lost "pickup item" can be a bit more pesky
Yes, I understand it's not unreliable as in: if you lose 20% it doesn't matter because you send x packets per second anyway, no one notices it. But if the player consumes food for example, I want that food to be consumed and that interaction not lost.
So that's what I'm struggling with to understand.
For updates server -> client UDP seems fine for sure, the other way around I don't get, as in it seems that TCP is (almost) mandatory.
Typically then you let the server be the authortity to avoid that headache
the player sends inputs, or "I try to eat this food" to the server....
And the server then simulates what happens to the food and the state results... and replicates those to clients
So worst case without any replication of lost packets... the food goes uneaten
That I understand, it makes complete sense. But the "I try to eat this food" input can get lost with UDP no?
and the player has to try clicking again
So you implement your own ACK for input or?
Yes, it can, in theory, in which case your replication model becomes "try to do this"
Player having to click it again is unacceptable.
There's several ways to deal with this.
TCP is one.
ACKs is another (reimplementing TCP in UDP)
OR you employ RUDP and force that packet to be reliable, but that can create the logjams you are avoiding. Which leaves you with the player needing an ack from the server for that tick... and if it doesn't get it sends another request.
But a more sophisticated approach is to merge state deltas
There is no one answer to this problem, the problem itself is the nature of high level game networking.
Client gets click, knows state should change, sends delta to server, server is always sending deltas about state changes to client
You employ the right answer for the game type and requirements of your game.
If client doesn't receive updated state from server, it's able to keep sending its desired state
Until the server state matches.
You will have to resolve disagreements if say your packet gets lost... some other player says they ate it next... and that gets to the server first.
But then what if the client is modified, the state would never match right?
Welcome to decades of "how do I deal with merging multiple states over asynchronous channels"
Trading is another example, imagine you trade an item to another player and only one of them receive the traded item.
Which is why doing this by hand is just best avoided, and its better to just come up with a server authority model that just doesn't break when these things happen, and the players have to live with some weird behavior when packetloss is present
Step 1 is a single point of truth. That means clients may try to do something and fail.
Which must include inputs and clicks
If the player tries to eat the food and its in the middle of their connection losing packets... some weirdness isn't going to end the world.
Or make it all reliable, and deal with the logjams.
do the transaction somewhere reliable like a database
You still have to unwind race conditions that played out wrong.
But, how much slower is TCP really?
If you assume that the client is always right, and can never fail at an input or activity that involves a shared resource, then you have invented an unsolvable problem
If you just disable Nagle
Would it be that much slower really?
- you could have a 100ms cache like in the article micken linked
TCP without congestion prevention algorithms and with selective ACKs and some other tweaks is perfectly performant
Like if the player says "I ate this on tick 9"... that gets lost... other player says "I ate this on tick 10"... if the first player finally gets its message that it ate it on tick 9... you have a choice.
Hey guys - apologies for breaking up the conversation into my own query here, but I've been trying for...a fair amount of time ๐. I have a local PlayerPref that is stored that sets up an animator - setting the animation condition to play (it's a different sprite), however, I can't mentally piece together the correct way to do this, as what I think should work, only does so for the 2nd client to join etc, despite me using an RpcTarget.AllBuffered. Using Photon, small grab of the area of code mentioned provided.
Even with congestion algorithms, it's mostly fine
and that previous now wrong state has already been sent out.
I'm copying that phrase @prisma girder
I'll look up what that congestion stuff is and see how to implement it later
Most resources online about TCP behavior are old. Decades old. Most don't even cover window scaling or how slow start mostly doesn't exist
So I wouldn't worry too much about TCP until or unless it becomes a problem
The thing is I don't want to cover everything right now, I'm completely fine with having a mediocre solution. But I don't want to completely rebuild it later. So if TCP connection would be completely fine, I can do the basics of that and look into it more in-depth later.
@sinful niche not sure where all the usage of buffered RPCs is coming from, but generally that should not be the answer to anything. Relay and PUN doesn't work like that.
So from all this I take it that TCP would be fine (with adaptations), and implementing UDP would make it way more complex.
Typically if you have a bunch of stuff you need to get from a client to inform late joiners, you will want to just send that when clients detect a new player joining the room.
@sinful niche
UDP isn't more complex really. Here's the thing
If you use TCP for reliability, yes, it will retransmit on packet loss or corruption
But if you wait for that, always, it may take a while with a lossy connection.
20% loss on UDP doesn't slow you down.
20% loss on TCP means you're stuck
Are you trying to go for razors edge low latency?
If you set very low timeouts, that's fine, but now TCP = UDP
So... you need to plan for desync no matter what
@jade glacier League of Legends latency
What does LoL use?
its not the latency though, its more the tolerance for logjams
^
Like a quake type game, the buffers are very thin.. so if a packet doesn't arrive in time, its discarded anyway.
Let's take Quake as an example, imagine the player shoots, you don't want that comment to disappear right? How is that handled
If you have a giant deterministic system in play, you might want TCP or RUDP all the way, to avoid desync hell