#archived-networking
1 messages · Page 91 of 1
Sorry, I said the same things many times. Same for fholm:
- you need data from server stored in separate places (not directly on transform)
- data from server replaces the client data (not on transform) for the same tick (original@one was predicted data)
- then with server replaced position for tick X, you resimulate frames X + 1 and up all the all to current time in client.
THEN, just after you have all this right, you interpolate (for clock aliasing)
And physx determinism is not really relevant here
Unless you were sending server data at very long intervals
I hate to sound like an idiot, but I've already done everything you've said, including replacing the position for tick X, and then re-simulating the frames up to the current time
My resimulations are done in a different scene, and then the main scene just grabs the new current time position from that
The literal only thing I'm stuck on, is just getting from the old position, to the new re-conciliated position (after the resimulation occurs), smoothly
Just clientside. No serverside involved for this problem
As of right now, I have it setup, so I have two gameobjects. One LocalPlayer, which is the main player and LocalPlayerResim.
The second the resimulation completes, LocalPlayerResim gets snapped to the new position and moves with the controls, and LocalPlayer loses control, then lerps to it, but this causes jitter
Watching fholm's stream right now about snapshot interpolation. Hopefully that's what I need.
wait, reading
I am confused with LcoalPlayer and LocalPlayer resim
This is not the split I mentioned
the split is:
- LocalPlayerSimulation (this is both server + resim data on top)
- LocalPlayerVIEW (this is what you see)
And the operation is:
- Server data replaces/snaps over LocalPlayerSimulation
- re-simulation of buffered input modifies LocalPlayerSImulation
- new input advances prediction operating over LocalPlayerSImulation
THEN: - LocalPlayerView copies (or interpolates) data from LocalPlayerSimulation
This is what you need
That's essentially the setup I have, I just worded it weirdly
assuming you have a synchronized tick system (which I said many times - I assume you have)
Yes. I do
You may have an issue in many many places
And the suspition always starts with the tick system
Anyone have some tips on performing a file transfer through LLAPI?
considering just using TCP and sending the file to the client in a bunch of packets with a header
question is what to put in that header
ill be sending textures, a json file and some audio files. all files are up to about a mb in size
So to confirm, LocalPlayerView, does not have any movement properties at all? It just lerps to LocalPlayerSimulation?
Let me give an example:
- you have data from server for tick 42, and you predict locally up to tick 45
- when server data arrives for 43 or 44, you predict again 45 (and also nect on the new clock time)
- LOG the DIFFS of the prediction before and what was received from server
THey should be MINIMAL or nothing
(test on a STATIC scene, no moving boxes at first - to simplify - just your character moving around on input)
On the same tick, predicted data AND server confirmed data should be SAME if running both on same machine even
They'll still be the same even on physx's non deterministic system?
Before you go into VIEW interpolation, make sure your tick based sim behaves like I said above
They will if the same conditions were used at start on the SAME platform
@slow monolith prediction will be mostly similar but probably not 100%
Even if they drift, they will NOT drift by A LOT over 2 or 3 ticks
Alright
This is the role of server confirmations + reconciliations, to fix for these small discrepancies
Correct, that is exactly what im working on
And also to fix when your movement is affected by things done by others, etc
Start by making sure the tick system is sound wit these DIFFs
Tick system is fine as far as I can tell. So wait, LocalPlayer and LocalPlayerReSim both run inside the same exact scene?
I'm 99% sure of what you're talking about, just want to confirm before I go to bed
yes
And then LocalPlayerView doesn't handle ANY movements right?
It's only job is to lerp smoothly?
and this view interpolation is OPTIONAL
It's just for clock aliasing
So IF you are going for that, you need to store 2 positions from the simulated ticks:
- current last tick
- previous tick immediately before
- (and) the partial clock not complete for next fixed network update
This is NOT necessary depending on how you make your local client clock move ahead
There are a few different techniques
Say I didn't do this, would jitter be more obvious?
They depend on how you advance the local client clock
Have you logged the tick diffs?
one sec
Yeah, if I'm doing this right, the tick diff is off by like a thousandth of a decimal
so literally nothing
Its 1 AM and I'm really slow, just trying to finish this problem before I go to bed
So when the LocalPlayerReSim object gets snapped to the updated resimulated position, and then continues moving with player input, couldn't I just use unity's built-in lerp functions to lerp the LocalPlayerView to it?
Because LocalPlayerReSim is an invisible object right?
You also told me that the LocalPlayerView lerp is optional. So if I didn't do it, the player would obviously see the microteleport after the re-sim happens right? At least that's what I saw when I tested it
That's exactly what I was looking for, Thanks
Would smoothdamp work better? Or should I stick with lerp?
And lastly, this system should pair well with cars using unity's wheel colliders, right?
Heya
I am using Mirror for my networking.
I was wondering how I could Network an Animation component.
Not to be confused with the Animator component which has a pairing NetworkAnimator component when using with Mirror.
Let me know, thanks!
== == ==
I was wondering if someone could help me? I am a bit stuck with some Mirror networking stuff. I have this system where the player can click on an object (the object has the script) and then drag it around by dragging their mouse around, then when the let go of the mouse button, it stops being dragged and re-enables physics.
It worked really well for the person moving it all as long as they were the host.
But, I struggled getting it to work with clients.
I managed to get it to work for them but it wouldn't show.
I had a look at some Authority stuff but gave up because I couldn't figure it out.
So I resorted to using [Command] and [ClientRpc]
So I would trigger a [Command] when the LMB was clicked and that [Command] would trigger a [ClientRpc] which would do what the OnMouseDown() originally did.
However, I am at a dead end.
None of it is working.
It only works when the client spawns in the object using a little system I made.
But that's not how it should be.
There are multiple objects that are made before runtime that have the script on them and don't work.
I have uploaded my code: [REDACTED READ BELOW]
This is a call of help! Please somebody save me!
I sent the wrong paste link!
New paste link: https://pastebin.com/8K9uf6kd
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Any coders out there know a thing or two about netcode in Unity? Looking to make a very basic, lightweight VRChat type social game (non-VR).
We'd need to synchronize things like players existing in different scenes, avatars, inventories, text chat, and random matchmaking. Prob wayyyyy harder than it seems.
Vector2 movement;
Vector2 mousePos;
public Rigidbody2D rb;
private Camera cam;
public Animator animator;
public float moveSpeed;
#region Client
[ClientCallback]
public override void OnStartAuthority()
{
cam = Camera.main;
}
[ClientCallback]
private void FixedUpdate()
{
if(!hasAuthority) { return; }
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
Vector2 lookDir = mousePos - rb.position;
float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f;
rb.rotation = angle;
}
[ClientCallback]
private void Update()
{
if (!hasAuthority) { return; }
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
}
private IEnumerator Punches()
{
yield return new WaitForSeconds(0.27f);
animator.SetBool("Left Punch", false);
animator.SetBool("Right Punch", false);
}```
My player is not see each ***moving *** (they see when they spawn in the world) it was working before then i added the ```cs
private Camera cam;
Then it stop working
(using mirror)
@spark void I'm writing authoritative netcode from scratch
I might be able to answer a few questions, still figuring mostly everything out though
If it's not a competitive game, you probably don't need authoritative netcode, which simplifies things a lot more.
It's not competitive in any way. Simple stuff.
-Players will be able to explore all scenes seperately, but their movements and actions will be synchronized.
-Players will be able to chat with each other with text.
-Players will be able to manipulate rigidbody objects and store some items in a small inventory that can be summoned forth for interaction, e.g. they find a basketball in Scene1, they take it, then bring it out in Scene2 and throw it.
The tricky part ...
-The player will never see a server menu. All online elements will run in the background.
-The game will constantly check if another player has connected yet. If not, it will seek players currently in-game and match them silently.(ALTERNATELY: If player-to-player seems impractical, players could connect to a single dedicated server that I'd host myself.)
If you need to synchronize rigidbodies, like being able to fling them over a network
then you'll need an authoritative server model
How I do mine is, literally have a server running a unity instance
so it knows what rigidbodies and physics are, etc
The clients themselves probably don't need to be authoritative. What I mean by that is, they tell the server their position, and the server doesn't do any checking to make sure it's correct
GTA doesn't use authoritative networking for their multiplayer, hence why there's so many hackers that can fly, spawn in money, kill everyone at once, etc
So its really up to you
If you do choose to make your clients authoritative, then you'll also have to make them snap back to a correct position (If they were at a wrong position, different than the server) smoothly, without causing jitter
that is where I am with my project as of right now.
Makes sense. Movement should be simple to synch, as it'll be grid-based and not smooth. If it would simplify things greatly, I could remove rigidbodies entirely and keep things static or animated.
Only the server should really have rigidbodies
when a rigidbody moves on the server, the clients will just interpolate that gameobject
so it looks as if it has physics properties on the clientside (which it doesn't)
Vector2 movement;
Vector2 mousePos;
public Rigidbody2D rb;
private Camera cam;
public Animator animator;
public float moveSpeed;
public override void OnStartAuthority()
{
cam = Camera.main;
}
[ClientCallback]
private void FixedUpdate()
{
if(!hasAuthority) { return; }
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
Vector2 lookDir = mousePos - rb.position;
float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f;
rb.rotation = angle;
}
[ClientCallback]
private void Update()
{
if (!hasAuthority) { return; }
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
}
private IEnumerator Punches()
{
yield return new WaitForSeconds(0.27f);
animator.SetBool("Left Punch", false);
animator.SetBool("Right Punch", false);
}```
Only the player that host can be seen MOVING on other clients
Other client can see other clients vis verse but can not see them mov
move
So with an auth server, things like movement and rigidbodies could/would be managed serverside and clients would just be receiving that information from the server so it's never an issue of "client synching with client" it's "clients synching with server"?
Correct
However
When you want to move your person, obviously you don't want to wait for the server to tell you that you can move
because that's slow and ugly
You want to be able to move the character freely on the clientside, and then just have it check with the server to make sure he's in the right spot
if not, snap him back
You can do this smoothly with clientside reconciliation. Basically the server sends the latest known position, which will be in the past. The client has already moved forward a few steps from that position
so you'll have to snap him back, and then rebuild the predicted movement from that server position, to the client's present on the clientside all in one frame
anyone here use mirrror?
Not me
Gotcha. Thanks @slow monolith. I'll have to look into figuring out how to code this all out to build a game around it.
C# has built-in UDP and TCP listener's and clients
use those to build it
etc
@gleaming prawn The process we discussed yesterday with LocalPlayerRigidBody and LocalPlayerView lerping to it, should work fine with wheel collider cars right?
Also should I be lerping to Rigidbody.position or Rigidbody.transform.position
That question is about physx,
Only thing I know PhysX was not made for predict and reconciliate
It gets too slow if you reset too many rigidbodies
But should work for cars yes
Alright
@spark void I just read quickly but did you try looking existing solutions like Photon ?
I think you should stick with Mirror.
This tutorial covers automatic connection between servers and clients as well as includes a UI fallback for hosting and testing local servers.
NOTE: Websocket Transport has been replaced with Simple Web Transport in the latest version of Mirror.
Flow map: http://tiny.cc/autohostclientconnect
Repo: https://gitlab.com/4t0m1c/mirrorgl
Discord: h...
this video is for the connection to localhost(same pc)...what i am asking for help is what should we do or changes should we make anywhere in order to connect another pc from another lan to connect to former pc ?? @everyone ??
Since@you are using mirror, their own discord has a big community
Maybe you’ll get specialised help there. You need a library and a server to perform punch through
Hi, can anybody know one or multiple tutorials or something else to create :
- Users accounts (with registering and logging in)
- User's owned avatar items
- User's avatar customisation with their owned items
- Items database (logically)
And I think that's all I need.
I would like to do this in PHP using MySQL databases, so if you know any tutorial, forum or whatever it would be really nice! Please ping me to answer, thanks in advance!
Long read is not a problem, Ive already lost like 3 hours making a login and register system that don't work at the end for one of my website
That code will create your user accounts and database, once you have done this, avatar and items will be easier to figure out. One thing you might want to look at if you are not used with sql db is this link (only after creating the login really so you dont get overwhelmed with all the info): https://www.guru99.com/database-normalization.html
Okay, thanks too
Is anyone knowledgeable with websockets / game servers able to help me with a simple question?
It's better to ask the question than to ask for someone who can answer the question
^
I'm current using WebGL-websockets (https://github.com/jirihybek/unity-websocket-webgl) and am running into issues with the webgl build being able to send messages to the server but not being able to receive messages from the server. In the editor everything works fine. Has anyone run into this issue before?
There is probably a polling method you need to Invoke or something
Looking at the sample code in the repository, it doesn't seems like there is any polling method so this might be a bug.
Perhaps consider using this project instead as it's better supported at the time:
https://github.com/endel/NativeWebSocket
can anyone help me with photon pun ?
i am getting this error:
Operation SetProperties (252) not called because client is not connected or not ready yet, client state: Leaving
when i leave the lobby (scene), into the main menu scene
nvrmnd fixed it
How can I select and submit an image via UnityWebRequest.Post in Android?
Hello guys! I have a question. I am using Photon as network solution.
In my scene I has a 10 spawn points. When user receive event "ChangePos" I want to change his position to free position, and then set this position as busy. And when sameone left - set his position to free.
The hardest thing is all 10 players already instantiated in scene and when all 10 users receives event - they need to choise free spawn point, and change position to a free one at the same time.
What's you suggestions guys?
Don't spawn them immediately. Send a network message to the masterclient and wait until spawn point frees up.
RaiseEvents don't require a photonview to be present https://doc.photonengine.com/en-us/pun/current/gameplay/rpcsandraiseevent
When sending websocket messages how does one typically structure a string so the client knows what to do with a message when it receives it? And vise versa.
You append an identification token to the start of the message, for example, if I'm sending binary on the network, I'd have the first byte of my packet correspond to an enum which describes the rest of the packet
It's probably easiest to have one client assign all spawn points (e.g. randomly). You can avoid all the overlapping and get a result that's indistinguishable from a distributed assignment.
The Master Client is a good candidate to take over this duty.
You can store the list of spawn points as room property, which is synchronized and could also trigger everyone to use their newly assigned spawn point.
https://doc.photonengine.com/en-us/pun/v2/gameplay/synchronization-and-state#custom_properties
Hey, Im currently using photon for a multiplayer game, I was wondering if anyone knew a better server host as photon gets very expensive
is AWS cheaper?
You may be mixing up CCU with "users" or "downloads" or so. In general, Photon Cloud is pretty cheap...
If you run any servers on AWS you have to make sure they also shut down instances or you might find that "very expensive" is open ended in terms of costs...
Thanks tobi, I've seen you in every photon help page xD
But correct me if I'm wrong:
does this mean that if I reach a peak of 2000 players in a month It'll cost me $370? @stiff ridge
Yes, if you have a max of 2k players (at the same time), you'd pay 370€. This includes traffic, load balancing, regions to select from and 0 effort for setting up servers anywhere.
Also, 2000 CCU roughly translate to 800.000 MAU. So you need a lot of players (cause they don't all play 24/7, even if some do).
What did you expect CCU to mean?
CCU = Concurrent Users (at the same time)
MAU = Monthly Active Users (any user who played once in a given month)
We don't know how many users you got in a month. We can only properly measure how many of your players are playing at some given time. The max of that will be the CCUs we charge you (as we run the servers to handle this max players count).
ah right $370 is very fair if you have 800k users
As some players don't come back after a few sessions, keeping up 800.000 MAU is also a challenge. You need a properly successful game 🙂
I understand that
I wasn't sure if I should say anything. When you're unhappy with Photon, we don't mean to talk you into it or so. But this turned out to be a major misunderstanding.
Yes definitely
Thank you
👍
I'll stay with photon then, but now I have the pain of migrating to PUN 2
I am in classic currently
It should not be super painful, really. Get the callbacks right and the renaming of methods / fields is the biggest piece.
Custom Properties got an update in which PUN 2 will not change them locally, until the server "confirmed" the change. This can put you off. There is a setting for that, so ask if this is a problem.
Everything else should be doable.
You know the docs with the Migration Notes?
https://doc.photonengine.com/en-us/pun/v2/getting-started/migration-notes
Ah okay great
Yeah I've seen them before
I just need the motivation to gte on with it
Also, I've wondered, why dont big successful games use photon?
It seems to be more common to game developers learning to code multiplayer than big commercial games
hey guys, so, in my game each player is given a "Head" object which has a NetworkTransform
for the local player, that Head has the Main Camera as its parent so the Head rotates when the Camera rotates
the problem is that that rotation isn't synced with the players in the server
however, if I apply the rotation only in the Head object instead of on its parent, the sync happens
does NetworkTransform only sync if the transformation only happens in its local reference instead of the world reference?
We have a few bigger titles too. With PUN specifically, we went for ease-of-use primarily. This means more complex titles could feel limitations of that, while this is OK for many games.
I think so, yes. The newer PUN versions got a bool to use local or world coordinates. This should be in the TransformView (code, maybe not in the Editor).
It might be easier to send the rotation of the head along with the transform of the body, instead of sending separate messages. The body rarely moves without the head, I guess.
Multiple scripts can be observed from the parent PhotonView.
what I'm doing is having the head without a parent and assigning its position and rotation as the camera's world position and rotation during FixedUpdate
Just use Mirror networking its for free and take any server host you want without having any CCU cost.
Alternatively you can use Steam or even Epic games store matchmaking and NatPunch for free if you release on their stores.
Mirror networking works great i really recommend it over any photon products.
@alpine pivot I don’t believe I’m working at that low of a level. I’m using websocket-sharp and hybrid web socket in Unity. The connection is established and I essentially convert a string into bytes on either side then send it to the other.
Unless you mean in this case I literally just mention at the start of the string what type of message it is.
That would work, yeah
Hi, my xcode is getting null exception but unity does not nor android (about the tcp class)
{
socket.EndConnect(_result);
if (!socket.Connected)
return;
stream = socket.GetStream();
receivedData = new Packet();
stream.BeginRead(receiveBuffer, 0, dataBufferSize, ReceiveCallback, null);
}```
Here is the code (this is client side) but i don't understand why there are null exception throwing on iOS but windows and android are fine
Any ideas where do i start to fix this ?
As long as your game targets Standalone builds, this is fine. On mobile, it's a different matter.
have used pun years ago, even bought Bolt Networking before Exit games took it over, pretty much anything with exit games been a bad experience, there are many other solutions that work out better, either its for mobile or standalone, the entire CCU thing is just ridiculous, developers end up with uncertain cost and need to trust that the CCU been given is correct.
PUN is very easy to use but its far from being good. bolt was a better solution till they took it over and i think currently its already the 3rd time its been added to the asset store and twice deprecated.
Also you have no control on server hosting quality and there are also dead zones where you cant host due to having no servers like in Asia region.
Its a good solution for beginners who don't know nearly anything about networking but if you go more deep its better to avoid.
There are so many free solution that does not let you stuck on CCU and there are also free solutions to the backend for spawning servers etc.
The Luck of PUN was that they existed in the time that unity still used a slimmed down version of raknet.
But that is many years ago and lots been changed there are better choices.
What is the best solution then Dragon
when you say "the entire ccu thing is just ridiculous", what do you mean
cause every single other service ive seen have that too
For mobile is used Tnet3 that works just fine
althought that one was a one time pay $100
Forge networking worked fine too
I use mirror now mostly as my target is XR development not mobile
thats another one of those
PUN is a relay + matchmaking for the CCU cost
i think you just dont understand the idea behind lol
you can make a server locally but also in the clod
you are comparing apples to oranges here
for the cloud backend there is a framework
but ditching a well known and used company cause you had a bad experience imo sound a bit stupid
you can have your own server with photon too
No , you can host your own but it still links back to their server for the CCU it not the same as a real standalone solution.
No matter what you do you still have the CCU recurring payment all the time.
and when you host and manage your own servers, you still have monthly costs
but those are more controlable
i think you are missing the point of a managed cloud
i dont believe its a problem, unless ur game is entirely free
they handle a ton of stuf behind the hood too
No not really, my background is unix and mainframe engineering over 25 years, there is nothing fancy about setting up those server in the cloud, you just need to have the correct software and good datacentre partners.
renting a master server plus a couple game server and a login server and all that cost at least 25-30$ a month
yet you have no one monitoring whats going on
I been running a game hosting company way before unity was a thing, the time there was Clanbase and IRC ,its really not that hard as you think it is.
#Quakenet 😉
hosted also irc bouncer that time
and voip servers
Its a long time ago 😄
🤦♀️
i remember direct connection before that but internet was made public in 93
my first network was with a nullmodem cable via the com port on dos playing C&C before the internet
the first lan we made was a BNC network using copper coax cables with terminators
i downloaded windows 1.0 with a long distance call on a 9600 bauds modem, took 3 days, still wasnt internet ;p
haha yeah 12 FD for that crappy windows
and browsers with image blockers so you can see the page data faster
those good old times lol.
i played quake and unreal online with 400-600 ping hahaha
i dont remember that has good time, from 93-2000 it was a hack fest and telephone modem was easy to disconnect
+++ath0
lol
and that was a "good" connection
just the noise that came out those modems ... lol
actually my first real download was via a radio broadcast to tape and load this tape in an MSX system in the 80's
So you could say that was in a way the first wireless data transfer i did.
i think photon is still a very good solution compared to many other, i did compare alot of solution and this it probably depends of your need and all but this is clearly able to do all what i want for a lot less trouble that i could imagine
My first computer was 40 years ago, cant believe how fast time flies
Oh yeah every networking is based on your needs for sure.
with a sound blaster card my dad made for me (he made it himself) and plugued it into the huge speaker we had from the 80's
And as i said PUN is indeed easy but not what i would go for myself.
thats some powerful beep
I have enough experience to build Cloud based solutions so why i should go to a 3rd party?
but when you end up having 500 people playing at same time
how much its gonna cost you
Currently having servers running across the globe
it can start as easy as $5 per node
the rela cost is actually traffic
and this is priced different per region/country
you cant handle 500 people on one node
the mount of people depends on how ell you code the game and how much bandwith you need
as server does not really require much CPU or memory it pure routing data in most cases
Some games i just use "Player hosted" which actually is called a listen server as one player is also running the server, then use the steamcloud to do the matchmaking and natpunch, it is the same as PUN does.
And in some situation i assign dedicated servers to steam and only use the steam matchmaking in that case.
There is also the point why i cant see the more value if you would go onto steam those services are free included @grim violet .
And it comes with more extra's like steamfriends , leaderboards and stuff like that.
Mobile platforms is indeed another story, there are so many store around the world for mobile apps.
i make game that require persistance, dont think steam can do much
you mean your server is persistent?
aint gonna go throught all of it but from what i know its just basic stuff you can save over there
In general a game is all about data what you store, it could even been written to standalone database server, it really depends on how you want to design it.
There not a single network solution that does all the magic you need if things get more complicated.
but then if you build with steam, you are probably obliged to pass by steam server and share your revenu
not sure if that 30% is better than paying a subscription
id make it free too if i was steam
;p
really paying in the end
i'm trying to use mirror for the first time. And i already encountered a problem. How do i count players? Or basically get a list of all the connected players
i can't find a function for that
never used mirror but if there no function to do it you can probably save a list of user that connect/disconnect
i tend to agree with @oblique wolf esp in this day and age where there are a lot of open source game servers that are also dockerized. there are definitely some advantages to managed solutions, but they will tend to be more expensive than self hosting
@lunar plinth On the client or server?
client, have no idea how to do server side scripts
but now when i think about it counting players on server and just sending the data to the clients might be a better idea
From my limited experience Mirror operates on the assumption that everything the client needs will be sent from the server, so client doesn't necessarily have a list of connections
i think thats the way to go
How do I get information from my networking thread to unity's main thread?
conrurrentqueue and poll it in update()? Is this really the best way?
Hi everyone, let's say I have the code below:
`void Start()
{
photonViewScript = GetComponent<PhotonView>();photonViewScript.RPC("RPC_ParentThisObjectToNetInstantiatePrefabsGO", RpcTarget.AllBuffered); } [PunRPC] private void RPC_ParentThisObjectToNetInstantiatePrefabsGO() { this.gameObject.transform.SetParent(goToParent.transform); this.gameObject.transform.localPosition = new Vector3(0, 0, 0); this.gameObject.transform.localRotation = new Quaternion(0, 0, 0, 0); }`
Would it be cheaper if I did this?
`void Start()
{
photonViewScript = GetComponent<PhotonView>();photonViewScript.RPC("RPC_ParentThisObjectToNetInstantiatePrefabsGO", RpcTarget.AllBuffered); } // [PunRPC] private void RPC_ParentThisObjectToNetInstantiatePrefabsGO() { SetParent(); } private void SetParent() { this.gameObject.transform.SetParent(goToParent.transform); this.gameObject.transform.localPosition = new Vector3(0, 0, 0); this.gameObject.transform.localRotation = new Quaternion(0, 0, 0, 0); }`
I'm using Photon
But, wouldn't it be cheaper latency wise?
Because inside the RPC method, instead of processing the contents through the internet, it is instead telling both computers to run the method on their own computer, right?
thats the method you execute once the data is received
photon will get the data under the hood then tell that method (just like you doing with SetParent();) to execute
And if I do this
[PunRPC]
private void RPC_ParentThisObjectToNetInstantiatePrefabsGO()
{
this.gameObject.transform.SetParent(goToParent.transform);
this.gameObject.transform.localPosition = new Vector3(0, 0, 0);
this.gameObject.transform.localRotation = new Quaternion(0, 0, 0, 0);
}
Wouldn't it mean that this method is being processed online instead of locally?
its still local
there nothing that run online from the client
photon do that for you
But why does my game keeps disconnecting then? I don't get it
While doing anything
I could be fighting a NPC or just walking
An immersive multiplayer VR RPG filled with adventure and heart pounding action. A dynamic experience in an apocalyptic realm.
Will you enter The Maze to defend humanity?
www.initiativevr.com
For more info
Join our Discord channel!
https://discord.gg/xzBjDHR
when you get disconnected its either bad data being sent trought photon or too many or anything that will break it
I have this VR this that I'm working on that just disconnects a lot
ah not sure about that
heard alot of vr people complaint about disconnect
not sure if its a common thing or what
might be a problem with headset
or eyeset or whatever you call it ;p
i dont do vr
When you say data being sent, does it mean something like
photonViewScript.RPC("RPC_Method", RpcTarget.AllBuffered, float DATA);
Is that too heavy?
And what if I'm not sending any data
Such as photonViewScript.RPC("RPC_Method", RpcTarget.All);
rpctarget.all is not buffered i think
only thing i would use to buffer is the player custom stats or equipments
rest unbuffered
like shooting or opening a door
you dont buffer that
if door open 500 time during game play
all this will come to the new player joining
its unnecessary
Is it normal to disconnect even while playing alone?
Then I don't get it
i leave my player online for days sometime
How do I find out?
testing, profiling
The Photon part I mean
recheck all your code make sure nothing run in loop or buffer unnecessary stuff
who was the guy who pmed me about photon. cant find u anymore meh
you usually have an history of people that pmed you
It does not need to be bad code it can be just the photon servers in your region not being good enough.
if you have only a player spawned and nearly no other networks callbacks in your code and get disconnected it photon servers problem.
So to debug you only should spawn and walk around, if that is fine then go to the next step in netcode, if it disconnect you with nearly no network callbacks it is 100% photon cloud service problem as non network related code is irrelevant.
@mellow sapphire VR does not really matter, I am a XR developer myself, making AR and VR application.
The difference is the rendering part nothing else in general with exeption of the workflow on art.
Thanks Dragon!
What exactly is a Network Callback?
everytime you callback on a photonview if you using photon
an RPC call
stuff like that
I see
I use a lot of RPC, however, I'm not sending much information I believe
Only making the calling normal RPCs without sending information
you can write a lot rpc in code but its about how many times they are called
void Start()
{
photonViewScript = GetComponent<PhotonView>();
photonViewScript.RPC("RPC_ParentThisObjectToNetInstantiatePrefabsGO", RpcTarget.AllBuffered);
}
//
[PunRPC]
private void RPC_ParentThisObjectToNetInstantiatePrefabsGO()
{
SetParent();
}
private void SetParent()
{
this.gameObject.transform.SetParent(goToParent.transform);
this.gameObject.transform.localPosition = new Vector3(0, 0, 0);
this.gameObject.transform.localRotation = new Quaternion(0, 0, 0, 0);
}
So
I had this example
Would this make the network callback lighter?
like i could write an rpc to change my score but it should have something ahead in logic that it only calls it when the score changes
So instead of setting the parent through the RPC, what I could do, would make just let each computer know that they should process the SetParent method locally
Would that make a difference?
This script is only called at start of the object its attached to
True, but if it was called a bunch of times, would that make a difference doing this
[PunRPC]
private void RPC_ParentThisObjectToNetInstantiatePrefabsGO()
{
SetParent();
}
private void SetParent()
{
this.gameObject.transform.SetParent(goToParent.transform);
this.gameObject.transform.localPosition = new Vector3(0, 0, 0);
this.gameObject.transform.localRotation = new Quaternion(0, 0, 0, 0);
}
Instead of this
RPC_ParentThisObjectToNetInstantiatePrefabsGO()
{
this.gameObject.transform.SetParent(goToParent.transform);
this.gameObject.transform.localPosition = new Vector3(0, 0, 0);
this.gameObject.transform.localRotation = new Quaternion(0, 0, 0, 0);
}
The script is very short as i see you only want to sync a pos and rot over the net at start
That was an example, but let's say it was on an update method
no never run netcode in updates lol
Hmm, I am doing that...
thats your problem 😄
Should I set a bool then?
why you need to update it in every frame ?
Change a bool though RPC, so both computers know that if a bool is True, than a method should start processing
what data is so important to update every frame?
I have to re check my code
if you realy want to sync you might be better of writing a coroutine that syncs every x seconds
That's true
Ok, I think I found something that I can start to debug, which is eliting RPCs being called on Update
eliminating*
I never use netcode in update, the only thing that updates frequently is pos/rot but only when a player moves and only in x seconds as it uses smoothing between last position and new position.
That's good to know, because I was honestly getting very worried
I dont use photon myself, i used it many years ago so i dont know how well you can even tune it.
I started developing my game right after Unity was releasing their new Network system, but they kept changing things since it was new and it was hard to learn
Photon there were already a few tutorials, but if I could have swapped to Unity Networking system, I would, but too late now =/
What do you use Dragon?
Unity network is easy to use, and its is now taken over by a dev its called Mirror
I use mirror, tnet3, forgenetworking.
Ohhh, I heard about Mirror
although you need to setup your own cloud hosting servers but you can control cost as there is no CCU
That is true
Does the paid version of Photon work faster and better than the free version?
And also disconnect less?
Oh wow, population one was made with Mirror
Also fallguys
Jeeez
Now I feel that it's too late switch since I programmed a lot already
Sometimes Photon is annoying, but maybe other systems are too, I have no idea haha
But thanks for the help @oblique wolf !
I know a few things about VR if you need help
Just let me know
You can get a vps in the cloud to host as low as $5 /month already and you can scale it up on release
Cheap!
I am in VR since cardbox and a preorder vive user @mellow sapphire
Now i am working on games for https://www.tiltfive.com/
No way man, that looks amazing
I am one of their partners
Imagine playing DnD on that
Its what i stepped into as i think it might even outstand VR
Could be
The future is bright
An immersive multiplayer VR RPG filled with adventure and heart pounding action. A dynamic experience in an apocalyptic realm.
Will you enter The Maze to defend humanity?
www.initiativevr.com
For more info
Join our Discord channel!
https://discord.gg/xzBjDHR
I'm working on this
Just me...
A lot of work
Anyway, gotta go to bed
Good night bro!
I'm pretty sure Fallguys was not Mirror, but Population One for sure is.
Onward uses Pun2, Population One uses Mirror
Fall Guys was custom iirc, think they used protobufs
how about Phasmophobia ?
They use Pun2
Mainly for the integrated voice I think
Among Us started on Pun2 as far as I know, and then decided to make their own variant of what Photon Realtime is, since they had the skills to do it.
Population One is for sure Mirror
@gleaming prawn Do you use DOTS or ECS for any of your projects? And if not, do you do any regular multithreading for your server?
Both my UDP and TCP services run on a completely different thread, and they just pass data to unity's main thread, which seems like it would eat up the CPU pretty fast, especially when managing 50+ players. Am I going to run into problems in the long run if I process all of the game stuff on unity's single main thread?
Lol, that table
I won't bother about the fake parts of the video. You guys should be able to realize yourselves
Erick did you see my question? Just trying to find out how to squeeze as much performance out of unity on the multiplayer as I can
I saw, sorry
Let me answer
I do work with multithreading, but only in the context of Quantum, which has a task-graph system for handling very fast work-stealing MT.
So we do a lot of stuff using all possible CPUs during the simulation step.
But I do not use unity's MT for spliting tasks between network and simulation.
But, if you are "eating cpu really fast" means more than your way of handling MT is bad
alright
Tobias seems to be writing something...:)
He works with MT on photon realtime I think.
You know, this really gets me: Because everything is oh so easy to you, you suggest everyone follows your path and host on their own.
Yes, sure, it's possible to host your game yourself and be happy with any networking solution there is. But you seem to assume everyone can handle servers in a number of regions as easily as you. You state that CCUs are unpredictable in price, then you go on to say server cost is different everywhere and traffic will be the real driver of costs.
It is not trivial for everyone to set up a bunch of servers and maintain them. It should be a conscious decision if you want to handle this or not. Once your game is build with some networking solution, you can not easily rip it out and replace it.
Sorry for my rant. Just wanted to clarify this somewhat...
I was still off topic 🙂
So regarding multithreading for unity, I should do as much of the work as possible on other threads, and then just queue up an action for the main thread when I need to use unity's API?
That sounds like a dumb question, it's late
I just dont want diminishing returns for a whole lot of extra work
1st:
- both the message processing, and the netcode should be as efficient as possible
To take as little CPU as possible
Yopu should be able to run 50 players single thread.
the netcode processing at least
How mine works is, I just pass data between a concurrentqueue
is this fast enough?
alright
you need to go down the rabbit hole a lot more if you want to use these things
What are my options?
I don't know, because you've been working on your own code for a long time
Also, with concurrentqueue, I simulated around 100 connections all sending data at around 60hz. Unity was at around 40% utilization
Is this bad?
But you should be able to use memory buffers, and use lockless CAS operations
Is this bad?
Very bad
alright
this looks like MIrror benchemarks... 🙂
That run 500 connections but take 90% of CPU with no game logic (this becomes irrelevant, as you can't do an actual game like this)
I'll copy here a number I heard...
If you have a server with 16 cores, you MAY reserve 1 full core for network processing, for example
So your network processing CPU consumption in itself should not take more than +-5% of your tick budget or so.
You'll need a lot more CPU to process:
b) basic game logic
c) lag compensated raycasts (if necessary)
d) change-detection and packaging from objects
e) together with interest management (what to send to each client, how to split)
f) THEN packaging these in individual sends to each client
I omitted a) because it is the network IN (receiving inputs from clients)
b-e combined should be your CPU bottleneck (and you need to design-for-efficiency the prominent ones as well)
But a) and f) should be a very very tiny footprint
So the memory buffer you talked about, how complex does this get?
alright ill do some research
If you are used to only using concurrency-safe collections, maybe you should not go down this route
And it's not a magic thing as well
It's not the buffers... it's how you push/pull data
as for this, test with no game logic, and on an IL2CPP build (never on editor)
This is with no game logic
you should be able to process 100 connections very fast
I think its the dequeueing part which is slowing it down
all of my networking happens on a separate thread and it's just the standard C# networking stuff
TCP and UDP listeners
this is not designed for high frequency and efficiency
This is designed for safety and easy of use
you are probably eating a lot of CPU just with implicit sleep/wakeups and locks (I might be wrong)
wait hang on nevermind, just removed dequeing from my server
and the CPU was untouched
so yeah you're right, might be the networking itself
There are many cases that photon is not the best solution, you are clearly biased or just trying to get more sales for Exitgames, aren't you Tobias who works with exit games for some years already?
Please don't forget this channel is called networking and it is to discuss all kind of solutions, dont try to make this a photon only channel as for help on photon ppl should just go photons support channels rather than Unity's Discord server.
Oh that was the problem with photon too, lack of support.. almost forgot that 🙂
Yep my unity server is idling at 42% with and without any dequeuing with 100 clients all sending info at once
which is odd because it idles at 32% when none of that is happening
gonna see if I can find whats eating up the CPU brb
@slow monolith check if you have automatic lightbaking enabled
Where do I check that
windows>lighting
unity 2019?
Windows>windows>lighting
Gary, if it idles at 32%, and at 42% with clients, your networking footprint is at 10
not horrible, depending on what you are processing
Yep, only 10% on the networking side
And test the server with an IL2CPP release build (headless if possible), not from editor
will do
this should be much faster
@oblique wolf there are many people from Exit Games here, and we all answer general questions about networking whenever possible.
Also that 42% was also fully dequeing the info and sending it into a pretty long switch case
so definitely not bad for 10% at all
ye
I was wondering how you were doing 40% just with networking, that's a lot
But keep in mind the a-f list of things
Will do
That explains everything why exit games be so much promoted here, its a shame there is much better stuff around to do networking.
you are free to use anything.
or do your own like Gary who I'm talking to... You are free to be angry as well. 🙂
I don't know why I'm doing this
who is gary lol
you are sure learning some things
^
Okay yeah so my server is idling at 30% even after I removed all scripts and just have a plane
very weird
yes
Alright so it was idling high because I wasn't capping the framerate. Full blast UDP with 100 clients caps the server at around 23%
that's just networking. No dequeing
Adding/Removing from queue seems to add no load to the server, so it's just a matter of optimizing the networking thread now I suppose
{
new Thread(async() =>
{
while (true)
{
UdpReceiveResult StartNetworkingUDPReceive = await UdpClient.ReceiveAsync();
byte[] UdpReceiveResultBuffer = StartNetworkingUDPReceive.Buffer;
int Code = BitConverter.ToUInt16(UdpReceiveResultBuffer, 0);
UdpReceiveResultBuffer = UdpReceiveResultBuffer.Skip(2).ToArray();
HandleUDPPacket(Code, System.Text.Encoding.UTF8.GetString(UdpReceiveResultBuffer));
}
}).Start();
}```
This is the receiver code on the server for UDP, not sure what else I could modify
oh wait, removed a few debug.logs, goes up to around 14-16% total with 100 clients sending data every 0.02 milliseconds
is that acceptable?
HandleUDPPacket() goes to nothing, in-case anyone wants to optimize my code some more
0.02 ms really?
use a realistic 0.016 SECONDS between sends (60hz)
or is that what you meant? 50Hz?
make it an IL2CPP build, use a stopwatch around you networking code to see how much TIME it is actually taking
the one on Unity's main
don't use the profiler for that (profiler is good for AB or before/after tests)
its still around 15-16% utilization at 60hz
let me try a build
uhhhh @gleaming prawn In a build I'm down to 1.5% utilization
what on earth
yay
That's more like it
YOu're good to go... now have fun with b-e
that will rake your CPU for real, lol
Perfect, thanks
IL2CPP is at least 4x faster than a Mono build... If previously that was in EDITOR, 10x is expected, yes
Wait, no. My unity exe didn't have firewall access, just popped up 10 minutes later
It's still running at 15%
wtf
ohhh
ok, that looks like threading then...
Try something like 32 connections, etc
ALso, where are the clients connecting from?
I assume from a different hardware
Nope all from the same computer
100 clients was 15% utilization, 50 clients is at around 7-9%
I tried a headless build, same results
the UDP listener all runs on a single thread
that's a bad test
because the clients are interfering with your CPU
They force context switches on the hardware
you must test from a different PC
so your unity server has a CPU for itself with minimal context switches
alright
let me check
you are probably sturating CPUs already
clients are doing about 20%
ok, not that much
server is at 8%
It's not interfering with unity's main thread, so I suppose not too much of a big deal right?
It may work for your needs with that
it is
you have 50 clients running a thread + unity on each + the server connection threads (50?)
This is a LOT of threads to context switch on a CPU with what 4 or 6 cores?
4 physical, 8 threads
ye, 4
I changed ReceiveAsync to just Receive
down to 4%
gonna see if thats actually right
yeah that seemed to work?
I'm still able to receive packets extremely fast on the server, so I suppose that was the fix. Hopefully you can explain why async does that, when you're back
100 clients, sending at 60hz, no more than 5% in the editor for the server
looks ok then
Only 2-3% on headless build. Hoping this is correct this time
Yep looks fine this time around
cool
Ooof, hate when that happens, when you think you made a good optimization only to find the same figures, or worse numbers sometimes 😬
I knew C#'s async code wasn't too performant, but this seems a bit extreme
https://github.com/DennisCorvers/UnsafeCollections
Expanded a lot on this. API is made as similar to that of .Net as possible
@alpine pivot Turns out it's true. I ran debug.log (which bumbed me up to like 7% with it on) and I was getting every packet at like 3,000 packets per second
I wish someone told me earlier that networking with async shits on performance
maybe its just unity
Okay wtf TCP was the same way. 35% full blast on the server end, removed async, now down to like 3%
Am I screwing myself by not using async in any way? UDP and TCP run on their own separate thread anyways
No, you can just do it the old fashioned way and Poll the socket for readable/writable data
I fixed the problem though, by removing async
I just wanted to know if there's any downsides to not using async during networking
Not really. It has some boilerplate code for ease of use and fault tolerance etc
But also a lot of overhead
You're right on that last one 😉
Hey guys, anyone have good resources on networking in Unity or a good code base to build off of? I'm using Tom Weiland's code for now but I wanted to check if anyone knew better
I'm making a turn-based game so I don't need anything fancy. My plan is to maintain some kind of move history and play it back on other clients when the message is received
As with anything though I'm open to any advice
I'm writing authoritative netcode entirely from scratch if you need to bounce an idea off of me
It sounds like that is what I'm gonna end up doing. My focus is on getting this game to a playable state asap though so I won't be going too crazy I hope
I'll keep in touch though
You will go crazy
I've been working on this for around 2 months
Turn based sounds pretty simple though
yeah that's gonna be a no no for me haha
so maybe not as crazy
If you don't need hack prevention etc, it can get very simple
like 1 week project simple
I'm hoping it's litterally just sending a tcp packet every so often with the completed moves
yeah I could always add features as I go
I took a course on networking a year ago so I'm familiar with the basics but idek what extra features I would need for this game
since tcp has error correction and everything built in and speed isn't an issue
you plan on selling your solution?
No, planning on making a game and releasing it
that could be years though
slow and steady 😉
For sure dude, one foot at a time
im looking to make a multiplayer game and i was thinking of using ecs and unity netcode. Are there any good up to date tutorials or something out there?
i dont have any previous experience with ecs
I assume you did your homework and considered others mature solutions.
That being said, even the docs are not up-to-date, so you'll have to dig and try a lot. No prior ECS exp will make it more difficult, I would begin by making up for that first. Prior exp with any other network project should help though.
It's not ready for production. Only for educating or prototyping purposes. If you still put all your expectations in DOTS netcode and decide a commercial release in 2021, it will probs make you miss your target date, you've been warned.
i did use mirror once, a similar thing to unet
the docs are not up-to-date
Though I must admit, old code still kinda works with up-to-date packages, but many things are getting deprecated
ok
bolt use ecs right?
because if it does will that be a good learning method for ecs?
- Learn ECS first, it's awesome
- If you're not under a deadline to make money, sure go ahead and try it (it's already promising at its early stage). Although If you are, forget 1. and 2. and bet on mirror or alternatives (depends a lot also on the type of game you want)
Not that I am aware of ?
Unity bought Bolt but they'll need some time to migrate it to ECS.
ok thanks
Also they began implementing their own DOTS Visual Scripting tool prior to the Bolt acquisition, now the project is kinda hanged up
They also plan to refactor most of their visual graphs and things so they all look kinda the same, so I wouldnt expect DOTS Bolt very soon 🙂
for clarification, there is Bolt Visual Scripting, that Unity bought, and Bolt Networking, an Exit Games product
ahh okay 👍, just wanted to make sure since it's the networking channel!
ok thanks
Thanks, I wasnt aware of Bolt Network
so if i want to learn unity netcode the best option is to follow the docs?
Oh yeah you mean Photon Bolt right ? I thought like Bolt VS for netcode xD
You'll definitely get to the point where it showcases you some network sync. Then the adventure begins... Maybe some blog posts are more up-to-date out there, I can't tell
ok, ill try and follow the docs then and see how it goes
One additional note before I go to bed, please keep in mind that DOTS miss a lot of traditional Unity API, you might have to implement your own solutions for things you expect to be basic nowadays in the engine. But the ECS part is already awesome 👍
ok, thanks alot for helping me
You're welcome, happy coding
Hey everyone, I'm currently looking into adding some networked multiplayer to my game, which can also be played single player. I'm currently having some issues trying to find a framework that keeps the same code path between SP, Local MP and network MP for my game logic. Does anyone have any resources (or perhaps any experience) on strategies for how to handle this sort of thing without creating effectively 3 code paths for game logic?
I was thinking it might be best to always have the player be hosting their own networked game under the hood, but I've heard this can lead to some issues with certain platforms.
I need help with turning my game multiplayer. So far i am using Photon PUN and i have watched tons of tutorials but i haven't been able to implement it into my project. I have created a match making and a waiting lobby system where different clients can join and wait for each other.
Once the game loads, everything f. up.
This is the script that i am trying to run for each player that has joined the game.
https://hatebin.com/hwsqbwkmhm
and This one is the script that instantiates everything that a player should have ( imo )
https://hatebin.com/wlygaeqaqk
And in the picture is my PlayerAvatar Object.
What i am trying here, which i am not sure if it's correct, is that PlayerAvatar object includes canvas for the player and the scripts(managers) that each player needs to have at least one.
And the Player scripts then Instantiates the ScriptableObject of the unit, then the instantiates the unit, And later instantiates the camera for the player.
Which when the game actually start, everything is either mixed or not working at all.
I need help to understand what is going on and how to fix this.
(i am trying to make a moba like game, but everyone has the same unit.
shop , player stats, skillbar bla bla are the same for everyone)
when you instantiate a prefab for each player they all gonna have the same, if you change stats on it after instantiating those data need to be shared with other too so they do the same
each thing you instantiate must hold a photon view too, so might not be a good idea to instiate 3-4 thing for just 1 player, should be one
ok i see you got 1 photon view and then instantiating stuff without any it seem, almost there, you must use that photonview from the character to send something like either a rpc or raiseevent to other people so they know what to spawn too for that character, just like that player.Color at the end, no player will know that if they dont receive some data saying hey the color is now this for this player
PlayerAvatar ( the one in the screenshot ) has photonview
but i am not sure what to do with it. I got confused
photonview is your link from this game object to other player gameobject with that same id, you can then either observe thing using OnPhotonSerializeView (which is a kind of streaming process between your values and those in the other player gameobject) or use code like RPC or RaiseEvent to send data, this three method do basically the same thing, just share data between people
now when you instantiate a prefab with photon, it will instantiate that prefab only, for all character
i watched 5-6m dfiferent videos where people jst type cs if(photonView.isMine) { //do things } so i tried to instantiate canvas, camera and managers, in that if but didn't work
if you start adding more stuff like canvas and all, you need to tell other people too
yeah
but that is once you receive data
when you send data from a gameobject to other client gameobject (the same one)
they need to check if the view isMine
cause only the controller player holding that gameobject can change it
PV is commented
yeah i knoww, i wrote the red one in paint too
kk
i mean, i have tried this
but why would that work
i thought it guesed it would instantiate
this Start() is just to instantiate the player's unit and camera
you dont know if the PV is your or not since the item isnt instantiated yet
i mean if you instantiate it
for sure its your
;p
here i kinda did the same thing
this one runs as soon as the game start
and the other one runs after this instantiates
did you follow the tutorial
i did,
that is why i am having problems implementing
you are missing alot of principle
they all use new projects
i did it in a new project but couldn't implement into mine
but i can understand because you are trying to add multiplayer to an existing/completing project
its hard to do multiplayer, id start an empty project
and do my test there
could take months before you catch everything for real
if you can have an empty project with 2 player spawning, and changing their color so other can see it
you will understand everything
yeah i think i need more practice over this. i am confused.
@slow monolith I'll send you the link tomorrow. Was too busy to finish it all today.
can you at least tell me, if my approach to have everything for a player in one object is a good idea
or should i split them
they will use the exact same ui and everything
not sure ui should be a player thing
also controller should already be attached to the prefab of the player
so when you spawn the player, its there
unles you spanw player without controller
not sure what is your game exactly so cant tell
those "managers" holds various scripts, i wanted to categorize them so i made it like that
would be easier to have all setup in a single prefab that you instantiate on the network
they are in the same prefab ?
canvas i dont think other player will need to know what sgoing on there
since its the personnal player stuff so it can be in the game itself without networking
well they dont seem to be in the same prefab since you instantiate them
but then if i change canvas wouldn't it change for everyone ?
yeah, only your client shouuld see it? unless it has interaction from other player too
those Instantiates are like this to avoid conflict
actually i don't need this anymore
client A - have a canvas and shop, then photonnetwork instantiate player which has controller and all already for that player only
client B - have a canvas and shop, and the same instantiate for his player
each player buy item and equip it
what they need to share for network is what they just bought and if its equipped or not
so that could be a small as 2 int sent over the network to other player
saying hey i just bought this from the shop and equipped it
oh no
so other player will say ok, that player have this and t his, lets spawn it for him locally
my shop is kinda different
thats how it shuold be
oh
well yeah like i said
i have no idea how you setup your game lol
could be totally unusual
i have a few abilities in a line
when i buy one
it shows like this
so it's not a shop it's an upgrade panel
still the same
if all player have the same canvas spawned and instantiate on network, and one player decide to buy a skill
all player will have it?
it should be local only
other dont have to know what skill you got
they need to know when its being in action thought
to spawn the VFX and damage or whatever
thats why canvas should be local, its just about ui, ui shouludnt be networked unless your game specifically use that in the network
but clicking a skill, you dont network the skill being clicked, you network the VFX being played from X player, and who hes targeting
i think you are missing some of the logic of networking, thats why you should start slowly
with a basic thing
like pong game
or something lol
i know it suck but, gotta start at bottom
i guess so, i can feel that i am missing way to much to implement a correctly functioning system into this project right now
yeah you probbaly achieve it but gonna take alot of time and spaghetti code
the headhach coulud be less starting from A
people at photon highly recommend following the tutorials closely until they are completed
they must have alot of succesful client that did it hence why they recommend it
id start with all those
its always faster when learning properly anyway
might take just a week or two and you will catch it
yeah, i been following the tutorials in a new project and this one at the same time. the new ones worked but this didn't :P guess i will practice till i say '' ooooh''
hehe
i rushed in without looking at too
took a while until i decide to understand every single word i was reading
thats alot at same time
since i know c# already
did you use other engine?
nop
that help
well warcraft3. world editor :P
i had only experience with ogre3d that i used 20 year ago
and gamed past 20 year so
rusty
lol
i think your doing good thought for a beginner
its really just the logic behind the networking and P2P
that you seem to be mising
i am good at this. once i understand what i am doing :P which i hace not idea what i am doing about this networking stuff atm :D
thank you for the advices
np
So say a UDP snapshot packet comes in on the server out of order, do I just ignore it?
I'm not sure if this is regarded as #497872469911404564 but it feels more networking related so I'll just ask here: What would you say the bare minimum/essentials are for a server online a month on higher capacity (100 players max) in a fast paced setting? I'm currently just using steam's connectivity for testing but obviously in a live environment I would want actual dedicated servers, to which I have no idea what's necessary
Nobody can answer that. Every game server is different.
Right so if you were to guess a game like Rust?
what does pretty demanding ring in your mind? (if you care to answer if not thanks all the same)
So I guess this is the bare minimum that I would scale off
RAM: Minimum RAM requirements is 4GB of RAM, but 8GB+ is recommended for optimal performance.
Operating System: Windows 7, 8.1, or 10 or Linux: Ubuntu, Debian, Fedora, or CentOS
Processor: Dual-core 3.4GHz or greater
Disk Space: 32GB+
not a xeon noted 🙂
most multiplayer servers are single threaded anyways
besides maybe another thread to handle networking
so clock speed is very important
Would anyone recommend Multiplay over more traditional options?
my understanding is they are managing the cloud where I could in theory do that myself if we're both utilizing aws services?
what traditional options
like p2p?
@gleaming prawn How would I deal with out of order UDP packets when creating an online game
like say I'm expecting packet 8, and packet 9 comes in, and then packet 8
just skip packet 8 entirely?
I think that's what unity said they did for their multiplayer demo, just confirming though
Depends on if your code has any need for packet 8
In my system I kept it in the ring buffer, since it was useful for extrapolation.
Or if it hadn't finished consuming that frame
How do you do your extrapolation anyways? Since that's on my to-do list
You don't consume frames the moment they arrive typically. They go into a buffer.
If a frame doesn't arrive in time, you make a guess at it.
No idea how to answer that
Depends on the person's connection. But you have to plan for the worst.
yep
Howdy. I am working on a 1v1 platform fighter. I am aware of my options ( Mirror, Forge, etc. ).
Which network engine would you recommend for really precise netcode requirements?
@loud geyser try colyseus
@loud geyser I love mirror, and the syncs are really precise
for a fighting/brawler none of these work (like these genre players expect)
They all expect you to have rollback netcode
You have 3 or 4 options:
- write your own rollback netcode (over any relay or other type of transport layer)
- adapt GGPO (over a relay or another transport layer)
- Photon Quantum
- There's another company that offers a predict/rollback netcode engine, but I'm not sure it is compatible with unity (and forgot the name - but a google search could find)
is anyone familiar with Photon networking? i have this issue where i control my friends game, and he controls mine. And thats not every optimal when trying to make a multiplayer fps 🙂, idk if its a problem with the code, or the photon. (i follow dapper dino's tutorial)
this doesnt work as intended, IsMine is more like IsOtherPc
which isnt a thing
do you have camera under player?
Make sure the camera is activating to the same object that IsMine is giving true
Ye, my suspicion is a camera confusion
its under the player yes
the thing is, it controls the whole player, not jsut the camera
You should only have ONE active camera
The one from the player you control, that's it
but if 2 player spawn, you will see second camera
so yeah, 1 camera
should be outside of player, following player with a script
mhmm
or disable the one from the object where IsMine is false
kk lemme try
how do i do this?
its a first person shooter game
you remove the camera from the player and place one in the root of the scene, then add a script to the camera with something that follow the player in update or something, you will also check if the player is your
but the method erick said is quicker and easier
just disabling the camera of the player if the player isnt you
i was doing this
You can make it "follow" in FPS mode making it snap to the head position
o_O
this looks ok
camera or cinemachine camera? i heard alot of good stuff about cinemachine but never used it
are you setting active false to the ELSE case?
Or maybe starting both as innactive
You probably have a camera active on the second player (most likely case)
i have 1 player, insancing it twice when starting the game
isnt that how u do it?
Check in the hierarchy that one of the cameras is off
ohhhh
Depends if the camera starts as active or not
Your code is not wrong, if both cameras are created as OFF/Innactive
But if they are created active, you need an ELSE in your code
or invert the code:
- SetActive to false where IsMine == false
still nothing?
ok
ayyy it works
thnx brother
really appreciate it
both of you
btw why shouldnt we synchronize the scale?
you can if you want to scale your character
There's a discord for photon as well
I can't post a link here, but send me a PM if you want
yes please
sent via PM
Im Using Nakama And I trying For Received Message in Match, But Received Message Doesnt Work. Why?????
I'm trying to solve quite a simple problem but i can't think of a solution. At the start of every round i try to spawn players using an rpc. But how can i get a players team its in his object im using photon pun.
Like basically how can i get a specific object using players id
solved it
Hey guys, trying to make my network client run on a seperate thread (I assume that this is better than running the client logic in an update function or smt). Is this the ideal way to do it?
listen_thread = new Thread(new ThreadStart(ListenForClients));
listen_thread.Start();
People are saying not to use abort to kill threads and to leverage processes instead but I'm not sure what that means
Nm I think I have found a better approach using asynchronous programming
It means to not call abort on the thread
But rather to make a while true > false
So that it ends itself
And async has a tremendous overhead
I have a question about Photon, or any alternatives. So i have been using Photon PUN 2, and trying to learn how it works and as far as i understand, the multiplayer uses a "Master Client" which i guess is where a player in the room, acts as a dedicated server. Which i kinda find it useful but not the method i wish to practice on.
So can anyone recommend me a framework that i would help me use a server ( like Amazon's free 10gb servers ) as a server, for the rooms. ?
I have found out that photon also has servers, but i cannot find any tutorials
@midnight bane The relay (hosted by Photon around the world) is the server. The master client is just a client that carries a special flag saying that it is the default controller of room objects, and can be used as the final word on states when you need that.
Typically for this reason, Pun2 games typically lean on player authority, rather than server authority.
so it actually runs on photon's servers not on the client's hardware ?
The relay knows nothing about your game (unless you make use of server plugins) - it is just there as a communication hub between clients.
The relay servers are what PhotonEngine hosts
So all players first connect to the MasterServer (matchmaking) and find a game room, or create one. Then they disconnect from the matchmaking server and join that game server and its room.
At that point, all clients can send messages to one another through that room relay.
So there is no server that you have to create or manage. That is the positive and negative of Pun2. Not having a server makes deployment very easy, but it also means that your game should not rely on the need for server authority.
so as i understand. Until a room is created, the players are not actually connected to a server.
that is fine, but i don't understand what actually a relay server is
They are connected to a different kind of server
You first connect to the MasterServer, which is the matchmaking server.
That is where you find/create rooms
The game server is the relay server
yeah i have done and understand that part, but then if relay server is different from that server, where is it actually
It is called that because it is a Server - the clients connect to it like a hub and spoke. It is called relay to make it clear that it is very specifically just there to manage connections and communications between clients.
If you use Mirror for example, your server is a Unity instance, running on a machine, and all clients connect to that.
So that is either hosted somewhere if you want a high quality server, or you let a player host, and everyone has to make use of Nat Punch or backup means like a relay server to talk to that player who is the listen server.
With Pun2 the server is always the Photon hosted server. But it knows nothing about your game.
All game logic happens on the clients. The only exception is if you use a server plugin, which is a special DLL you make for the relay that gives it some understanding of your game.
The relay is the cloud servers.
Just like any other cloud server... the only difference is it knows nothing about your game. It is just a generic communication hub.
wouldn't it create latency difference between the player that hosts the game, and the others ?
or make the room shut down if the player who is hosting leaves
If you try to make a client act like a server - which you don't want to do.