#archived-networking
1 messages · Page 11 of 1
Hello, I am completely new to networking and followed a short little tutorial on fishnet. I am having an issue though. I am using Character Controller Pro for my player physics. I'm not sure if that could be contributing to the issue. But anyway, I'm not seeing the other play object moving around on each client. I do have the NetworkTransform component on the objects.
Hey! You can try asking on the Fish-Net Discord. I haven’t used Character Controller Pro, so I don’t know if it causes any issues (it shouldn’t).
You might also try a character controller that has already been adapted to Fish-Net, such as Easy Character Movement 2: https://assetstore.unity.com/packages/tools/physics/easy-character-movement-2-193614
I see also that you’re trying to make a multiplayer FPS, there’s an official multiplayer FPS demo project: https://youtu.be/UtQFkJnxDMM
Asset Store: https://assetstore.unity.com/packages/tools/network/fish-net-networking-evolved-207815
Github: https://github.com/FirstGearGames/FishNet
Discord/Support: https://discord.gg/Ta9HgDh4Hj
Documentation: https://fish-networking.gitbook.io/docs/
Tutorials and Examples: https://github.com/FirstGearGames/FishNet-Examples
Do you know any good resources on data serialization? Binary protocol formats, floating decimal numbers, fixed, fixed point arithmetic? By the way, is it possible to use winsockets in unity?
@graceful zephyr Hey man, can photon fusion do a souls like combat with stagger and local prediction? Is it viable?
Even at like 200ms ping
Fusion allows you to do game wide predictions yes
But if it works out at high ping or not depends on you and your code, not fusion
You can predict as many ms into the future as you want, but if that works performance wise and gameplay wise is on your end not fusions
But things like a stun where you are locally predicting you moved to the right but you were stunned 200ms earlier. Is it viable on photon fusion? assuming i`m doing the code the right way
" If your character moves client-side thinking everything is okay and an enemy has stuns it in the meantime, that enemy will have stunned your character earlier on a different version of the world from the one you're seeing"
this is from unity page about networking
You would just see the character snap back to where it was stunned
If this is the case then a souls like networked combat is not viable. It will look too bad to even be playable
A stagger (mini stun) happens on nearly every tick, every 2s a snap back ...
Of course it's viable. But very few games will survive 200ms ping for very long
@woven kiln yes fusion can do this type of prediction
And it will correct itself automatically on mispredixiciton
stunning is tricky to look good with client prediction.
if you pair stun with knockback you can sort of fudge it and smooth it out.
Say you are stunned and knockedback by the server for 2s.
0.5s later the client recieves this message. The client has 1.5s to do the knockback from where you incorrectly are to the stun spot, rather than doing the usual reconciliation which would've snapped you.
Of course if you recieved the message after the entire stun duratioin has ended you'll jsut get the usual.
On a souls like you probably tried to dodge the attack (almost always) so locally you are too far away from the stagger position
Yeah, the faster your gameplay/worse your ping the more off it'll look for sure. Definitely a can of worms!
Is there any game that is doing it at 200ms+?
with success
New world is the closest but not at 200ms
Sorry for the crosspost; not sure if the question fits here better:
I'm building an app on iOS that needs to communicate with the Unity Editor (a custom editorwindow). I need to be able to send files from the editor to the app and vice versa. I also want to do some RPCs from the editor to the app.
What's the best way to go here? I came across the Telepathy library which makes it easy to set up a connection and send arbitrary byte arrays over tcp, but I'm not quite sure how I would figure out what file I'm sending/receiving (a header, probably?).
Or is it a good idea to run a small http server on the app and use UnityWebRequest for sending files?
Hey, so I got this working and the server changes the color for the player however, whenever a new player connects the old states that are present on the already connected players aren't applied to the new player's unity instance. Do I need another RPC onconnect to sync the data?
Either another RPC or you can make it a Network Variable
I have already made the Color a NetworkVariable still it doesn't sync back when the player connects (I haven't defined what will happen OnConnect, I don't have that method at all)
Network Variables are automatically synced to late joining clients
(FirstPIcture) I have this state in my multiplayer game where I have set the colour of objects to two distinct colors.
(SecondPicture) I connect a new client to the server and it won't sync back the colors.
you need to store the state you want to sync automatically to new clients in a network variable, or yes, if you do it manually, you have to send that state to the new clients
You still have to read the network variable and set the cube's color. It's not automatic
Is there any tutorial to do this ? The Unity networking API is a bit confusing when it comes to syncing and creating RPCs.
- Where do I begin to code this (I am new to Unity networking and I feel lost).
- Will this code be called when you connect? Will this be a Server RPC ? Will the server maintain a list of all the connected clients and the states ?
I am assuming that the host/server internally maintains a list of its connected clients, do I need to trigger a Server RPC which will inturn fire a Client RPC only for the new connected client?
Okay I got it to work by setting the color of the material on OnNetworkSpawn (Got a tip from this thread: https://forum.unity.com/threads/netcode-for-gameobjects-code-for-assigning-colors-to-players.1370025/). But still, would like to know any resources for simpler explanation of NetCode for GameObjects..
i am trying to pass the Player class instance who sent the RPC along side with it, why is it returning an error?
The LocalPlayer and Networked player both inherit a Player class, wich is where the rotation is happening, plus i'm testing this in a room with only myself inside... it should work tho!
playerSync is a class dedicated for rpc calls etc
that's whats inside there!
It also gives this error if i make Player a Player class instead of LocalPlayer and attach the LocalPlayer class!
Hi everyone. I am developing a multiplayer game and I need to store the player's name upon connection to the game. Should I be creating a custom NetworkManager class that inherits NetworkManager and override things or is there an easier way to do this?
Depends on what framework you are using
I'm not sure what you mean by framework. I'm using Unity's Netcode
Then you need to use a network Variable
I want to implement a "last man standing" multiplayer game (similar to Crab Game), and I was looking at Unity Relay. However I'm having a bit of trouble understanding the costs associated with it.
I want a game with about 20 people in the lobby etc, and wanted it to be p2p so I don't have to pay for any servers (i.e. the game is run on the player hosting the game's PC). I moved from Photon to Netcode thinking it could be done for free but from what I see, I would need Unity Relay to achieve this. And for Unity Relay, I see that it's 50 Concurrent Users with $0.16 per additional user.
Based off my understanding, in an unrealistic scenario, I have 20k people playing this at once, that's $3,200 a month which is $38,400 a year. And I have no intentions of commercialising this game.
Am I correct in this understanding? And/Or is there a free alternative where I don't have to pay anything to achieve this? I hope I'm making sense
Thanks
NAT Punchthrough is an option
But 50 CCU is more than you think
Having 20k CCU puts you in the top 40 steam games for some perspective
I would say it's a definite possibility given the intentions of it, I don't anticipate it being any more than 200 people at the most, but I'm not really sure tbh. If 50 CCU is 50 players, and a 20 player maximum lobby, there's 2.5 games that can be run at full capacity
500 CCU for free would be great but I have a sneaky suspicion Unity wouldn't have that as an option lmao
i want to send an information to the server from my client and server should send that value to other clients. i use network variables for that value but i don't know how can i make this transfer process. do i need serverpc or clientrpc or both?
I can't site my sources but I heard somewhere that 50 CCU is about equal to 10k copies sales. If you're selling 10k, those costs probably don't matter compared to marketing and production costs. Otherwise NAT Punchthrough is free if you're willing to implement it. Also P2P sounds like a bad option for you. What if the host gets elmininated? IIRC netcode doesn't support host transferring yet.
@signal crown
NetworkVariable should be fine here, just make sure you add a writePerm argument to it's constructor so that the client can write to it (default is only server)
I did thank you, now i can send value across the clients
[Netcode] NetworkPrefab "Player" has child NetworkObject(s) but they will not be spawned across the network (unsupported NetworkPrefab setup)
does anyone know how can i get rid of this thing?
Hey, I am trying to modify a NetworkVariable however I was encountering the following error: Client is not allowed to write to this NetworkVariable so I switched to Server RPCs and then tried calling the ServerRPC to modify this network variable but now I am getting this error: Only the owner can invoke a ServerRpc that requires ownership!
So I have been learning about the basics of networking and just saw the new Counterstrike "getting rid of tick rate" announcement and it threw me for a loop on what i thought I was understanding. Do people know what's going on under the hood to "eliminate tick rate"? Is the idea is clients are sending packets with timestamps and then the server is prioritizing them within physics ticks (i.e. the source2 equivalent of fixedupdate)? How does that not end up giving exploitable trust to the client?
I realize I'm essentially asking about Source2 in a Unity forum, but I assume the concepts of networking are fairly universal, and I'd love to implement something like that if it's doable. Do they just have after the fact packet analysis to figure out if someone is spoofing timestamps (e.g. x percentage of packets being towards the the front of an expected normal distribution of packet times within a tick)? Some other form of anticheat? Is there just something I fundamentally don't understand about what this means? Thanks for any help!
Actually I guess it'd be a uniform distribution, but I digress
You can't have child networkobjects of a network prefab
What could be the solution for me?
Put the networkobject in the root object of the prefab (the top parent)
For the RPC, either give ownership to the client or add (RequireOwnership = false) after "ServerRpc". For NetworkVariable you can add a writePerm argument in it's constructor to allow clients to modify it.
It's actually an average of 50 ccu per month. So it's actually closer to 36k player hours
It's marketing BS. Like Google Stadia's "negative latency". I'm assuming it's basically some form of rollback Netcode that Overwatch also uses
Okay, thanks. Also, a question: Is Unity Transport not supported for WebGL?
It's not
I believe newer versions are?
I remember seeing it on their roadmap a couple of days ago
Unity Transport is not currently supported in WebGL. NetworkDriver will likely not work as intended I recall someone telling me it was.
Sorry, that was for Relay
Unity Transport seamlessly supports all platforms the Unity Engine supports thanks to a connection-based abstraction layer (built-in network driver) provided over UDP and WebSockets.
https://docs-multiplayer.unity3d.com/transport/2.0.0/about
Are we supposed to do an Pre-Initialization for WebGL?
Wait, is 2.0.0 older than 1.0.0?
This is documentation for Unity Multiplayer Networking 2.0.0, which may be a previous or preview version.
For up-to-date documentation, see the latest version (1.0.0).
Or is that coming up just because it's in preview
https://docs.unity3d.com/Packages/com.unity.transport@2.0/manual/index.html also mentions WebSocket support.
It seems it's supported, but the server/host cannot be on WebGL
I tried connecting to hosts which are not on WebGL but it gives this error on connection
Make sure you have the correct versions
Correct versions of what? Unity Transport?
I would start there
I have used the same version for both host and webgl instance
I literally exported the game after implementing a basic project.
I meant versions that are new enough to have WebGL support
Oh what, if that's the case how will i revert to older versions?!
WebGL (requires NGO 1.2.0+ and UTP 2.0.0+). Note: Although NGO 1.2.0 introduces WebGL support, there's a bug in NGO 1.2.0 that impacts WebGL compatibility, so it's recommended to use NGO 1.3.0+.
I am using 1.3.0. Okay here is what I am doing:
- I am hosting a server using my Unity Editor (which is also a client) the target ip is 127.0.0.1 and port is 7777.
- I am trying to connect to the host setup in point 1 using WebGL client.
No you aren't. NGO 1.3 is not out yet
Oh my god, the versions are just confusing 🤦♂️
You might mean Transport? You would need 2.0 version of that
You have to add it by name and specify the version number
You need to be using 2022.2 or later
https://docs-multiplayer.unity3d.com/transport/2.0.0/getting-started
See the Installation guide if you’re new to Unity Transport. If you’re upgrading from a earlier version of Unity Transport, see Migrating from 1.X.
Do you want me to specify 2.0 or 2.0.0 because i tried 2.0.0 in 2022.2.X and it says the latest is 1.3.3 (Unity transport)
Yea 2.0 of com.unity.transport should work
Does 2.0.0 give you the same error?
Yes.
What do you mean by that?
What version of unity are you on?
It's averaged out. You can have 100 players one hour and 0 the next hour and it will average out to 50 CCU for that 2 hour period
But it's averaged out over the full month
2022.2.X as i mentioned above
2022.2.12 to be specific
So if for example I load up the "server" for 1 week of the month, then 500 people play it, then the rest of the month I have the "server" down/off, I wouldn't reach the 50 CCU average?
Right. It's still in preview. Use version 2.0.0-pre.6
Check the pinned message here. There is a dedicated discord for NGO and Transport. Using webgl is a bit tricky
Exactly
Ohh ok, thanks 🙂 Do you happen to know anything about the Steam framework? Dunno what it's called but apparently it's free (minus the upfront cost to publish the game etc)
Wow that was super hidden, I was trying with 2.0.0 didn't know about the suffix
It did add the library for me however my WebGL build takes years, is there a way to fix that as well (Although this is not related to this channel)?
hey, noobish question, would it be possible to control my vr multiplayer gameplay via something like a webapp that is connected to photon pun? is this possible? Like I want a vr game lobby where one player is on the pc and can control certain aspects of the game...
Anyone know what could cause my spawn point in my Server build to be different from where it spawns in the Editor? its not setting it to a random value, its a fixed value that works in editor but its different on my server. Seems like a deep underlying issue i'm having.
In my enter server system i set the position:
commandBuffer.SetComponent(player, LocalTransform.FromPosition(new float3 (7, 2, 5)));
but in the server build its (0,0,0)
If it's the same PC then you don't need a web app at all.
Unfortunately it isn't. The VR game is for quest 2 and the PC would be separate. Possibly on another Network
Then yea either a web app or another unity client would be needed
how can i network a method like transform.RotateAround() on a player instance?
You can run it in an RPC
How do the instances know wich player is turning?
The RPC is run on one particular object
so like this?
but this sounds possible to you? I'm pretty noobie. But if I just keep running through the photon docs and mess around this should be achievable ?
it kinda works for the local player, but it looks offset for a player that joins after i have been orbitting around an object with it... should it be buffered or nah?
nvm, fixed it... partially!
hello guys,i am using photon voice2,i set up the project but when there are 2 people in a room just the master-client can speak while the other player no,is this normal or it is a bug?
This sounds like a better question for the Photon discord. You can find link to it int the pinnes message here
ok thanks
is there any way to make networkvariable<int> value null?, ikr it says non-nullable type
Yea. Ints can't be null. You can use something like int.MaxValue for an invalid value
thank you! i've learned that i can use int? in netvar for getting nullable int type and its working
Neat. I don't think that's supposed to be working, lol.
it didnt give any error, i didn't test it because i changed my mind, not gonna use it
Hey guys, I’m kind of OOTL (havent been devving in a while). What do people use nowadays to handle networking? I’m running 2021.3.4f1
Im pretty well acquainted with Mirror, but maybe theres something more “trendy” now :)
Mirror is fine. So is Photon. Fishnet is newer. And I'm a fan of Unity's Netcode for GameObjects
Gotcha, thanks!
Hey
Any devs in here who do multi-player games ? I need help with something
How do I sync an object between client and server?
That depends on what network framework you are using?
How do I find out what network framework?
It's whichever you chose to use. Mirror, Photon, Fishnet, Unity Netcode. Check the pinned message here for more info
hey, how would i be able to target an RPC to a specific client?
Lol, that depends on what framework you are using.
unity ngo lol
Servers can invoke a ClientRpc to execute on all clients.
so right now I'm trying to spawn in a network object as a player, but for some reason it only works when I pass in the host id
doesn't work for the clients
I'm doing this in a server rpc
what is better using steam for multiplayer or unity netcode
[Command]
void SpawnObject()
{
// Spawn object on the server
RpcSpawnObject();
}
[ClientRpc]
void RpcSpawnObject()
{
// Spawn object on all clients
}
why would you do something like this ?
I mean call the rpcSpawnObject in a command function ?
ping me
i understand almost every basic except from this
Are you using .SpawnAsPlayerObject(serverRpcParams.Receive.SenderClientId)?
This is how clients communicate to other clients. The client sends to the server then the server will broadcast out to the other clients.
How do I find out what network framework a game is using ?
Google it, ask the devs
yes but instead of SenderClientId I'm passing in a ulong variable of the clientId
the variable I pass in for the clientId is the ownerClientId of the player
At that point the owner is probably still the server/host
I just started using mirror and fizzy steamworks and cant find out why one client can instantiate a bullet and see it but other clients wont see it, can anyone help ```public class Shoot : NetworkBehaviour
{
public PlayerMovement pm;
bool bananaHeld;
public Rigidbody2D banana;
public GameObject player;
public float throwPower;
[HideInInspector] public Rigidbody2D thrownBanana;
// Start is called before the first frame update
void Start()
{
bananaHeld = true;
}
// Update is called once per frame
void Update()
{
if (!hasAuthority)
return;
if (Input.GetKeyDown(pm.ThrowButton) && bananaHeld == true)
Throw();
if (thrownBanana)
{ Debug.Log(""); } else {
Debug.Log("");
}
}
[Server]
[ClientRpc]
[Command]
private void Throw()
{
thrownBanana = Instantiate(banana, transform.position, transform.rotation);
if (pm.movement.x == 0 && pm.movement.y == 0)
{
thrownBanana.velocity = new Vector2(player.transform.localScale.x, 0) * throwPower;
}
else if (pm.movement.x != 0 || pm.movement.y != 0)
{
thrownBanana.velocity = pm.movement * throwPower;
}
thrownBanana.GetComponent<Bananarang>().target = player.transform;
bananaHeld = false;
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.GetComponent<Rigidbody2D>() == thrownBanana && thrownBanana.GetComponent<Bananarang>().canReturn)
{
bananaHeld = true;
Destroy(thrownBanana.gameObject);
}
}
}```
hey so im coding a grenade for my game and everything is working exept for calling damage. Im using an RPC to call damage over the network and im a bit of a beginner to rpc's so if anyone could help that would be great. heres the strand: https://hatebin.com/ifjzhbbyzm
that makes sense but I just tried to debug.log the name of the player object associated with the clientId that I pass in, right before calling the SpawnAsPlayerObject(clientId) method, and it correctly logs the name of the client
😭😭
so that means that the clientId variable is correct, its just that it's not spawning in the playerobject for the clients for some reason
(btw I named the player objects player0, player1, player2, etc, based on what client they are)
I was wondering if anyone here has used mirror and do you suggest it?
Just because it's named correctly doesn't necessarily mean the right client Id is being used. OwnerclientId defaults to the host/server
I prefer unity netcode. But mirror seems fine
I have a question, what is the main difference between using Mirror and using Steamworks Wrapper?
what would be the correct way to get the clientId of a specific player object then?
rn what I'm doing is calling a server rpc to damage a certain player when the player object is shot
Steamworks is just a suite of services and not a networking library.
Therefore, Mirror would be the way to convert does services into a usable library?
You can send serverRPCparams to get the sender client Id. But the server should be the one sending a clientRPC for damage.
Right, you can use steamworks with any other network library
I'm also using a network variable for player health right now
so should I just change the network variable on the server rpc and then on the client have the on changed callback
In that case you don't need rpcs at all.
hmmm
The health should be server authoritative. When the server registers a hit, it will adjust the relevant HP.
The clients can use the OnValueChanged callback to update any UI
ah got it
the only confusion I have left is how to change the correct clients health network variable. right now I have it so the player that shoots another client sends the rpc
not the actual client being shot
so doing senderClientId would return the shooter, not who was shot
The server should be handling the hit detection. All the clients have to send is that they fired. The server should do the raycast and determine the hit. It can then change the health value there
yes but how can I change the value of the client that was hit, how would I correctly get their health and lower it?
Just a normal physics raycast on the server/host. From the player that shot. If it hits another player, get their health component or whatever and decrease the health value.
hey so i am calling damage from a grenade and its working exept its not calling damage through the rpc can someone please help?
Same as above, health should be a netvar and the server just needs decrease it.
the thing is shooting and decreasing health works its just im having trouble calling the pun rpc when the overlap sphere touches the player
so I just need help with fixing one line of code
this one:
GetComponent<Collider>().gameObject.GetPhotonView().RPC("TakeDamage", RpcTarget.All, 25f);
There is nothing wrong with that line. Unless TakeDamage isn't an RPC. I don't use photon.
ok
i get this when the grenade expoldes on a player
Dunno. Sounds like you can't call that RPC on the host. Like I said, I wouldn't be using RPCs at all
ok
Does anyone know how to fix this error. When I tried increasing the Queue Size, the network objects don't register which gives more errors.
errors that occur once I increase the Queue Size (the prefabs are registered in network manager)
Sounds like you'll need to find the prefab with hash 256 and maybe readd it to the Network Manager
can someone tell me why other players cant see the weapons i have equipped?
if (Input.GetKeyDown(KeyCode.Alpha1))
photonView.RPC(nameof(EquipSnowball), RpcTarget.All);
[PunRPC]
void EquipSnowball()
{
snowballOverlay.SetActive(true);
katanaOverlay.SetActive(false);
mLauncherOverlay.SetActive(false);
}
the input.getkeydown is in update btw
and update checks if photonview.ismine
You could subscribe .onClientConnectedCallback event and compare if client's ID is the same as yours.
https://docs-multiplayer.unity3d.com/netcode/current/api/Unity.Netcode.NetworkManager/index.html#onclientconnectedcallback
The main component of the library
this is the quick and dirty way
https://docs.unity3d.com/ScriptReference/Application-internetReachability.html
Hello. I'm fairly new to networking and am currently using fishnet.
One problem i have is that the lag between clients are noticeable. I heard lag compensation fixes this but I don't want to upgrade to fishnet pro.
Are there other techniques i could use to reduce lag between clients?
Hello, voice chat is quieter in some places, but in the centre of the map, it is really loud? How do I fix this? I use Photon VR Voice
lets say there is a function that needs to be run by the server and we are running it without the server attribute what happens then ? How does the unity know that this function needs to run on server is it because of server attribute only that unity knows that this function is running on server or something else ?
You can write your own client prediction system
There is nothing special you need to run functions on the server
Also when we want client to give a message to all the other clients we put a clientrpc in a command function how does that work does the client tell the server to run the function on the server and then server run the function which affects all the clients ?
can you explain more
what happen without server attribute
What are you trying to do? You can just call a normal function on the server
I am trying to understand a tutorial
how do I know if a function is being run on the server or locally ?
I am talking about mirror
You'll need to read the mirror docs about how it does RPCs. But for the most part functions will run where they are called. It will run on both clients and server. Then you will need to check if its the server or not after its called
so i have a custom class that is serialized and a networkvariable
it does update on the client that its changed
but it doesnt sync on the other client
any ideas why it happens
Do you update the variable in a serverrpc?
is the networkvariable supposed to be updated on the server
or if i update it on the host
// todo: set AddNextBotToSessionList(long modId = 0)
public void AddNextBotToSessionList(long modId = 2883082)
{
// todo: check if client is master/host client!
try
{
NetworkHandler.Instance.globalData.Value = new GlobalData
{
nextBotModIds = NetworkHandler.Instance.globalData.Value.nextBotModIds.Concat(new[] { modId }).ToArray(),
};
}
catch (Exception e)
{
Logger.Error($"Error while trying to add a new nextbot to session list! More info: {e}");
return;
}
Logger.Info($"Successfully added nextbot:(Mod Id) {modId} to the list!");
}
this is the code that changes the networkvariable
?
Ok I have found something, the default creating of a network variable only allows for the server to change the value. Scroll down in the docs to permission
and how do i know which client the owner is
is that the first client that joins
From the docs
public NetworkVariable(T value = default,
NetworkVariableReadPermission readPerm = NetworkVariableReadPermission.Everyone,
NetworkVariableWritePermission writePerm = NetworkVariableWritePermission.Server);
You could change it to everyone as well
read perms is set on everyone
i think i am gonna try a rpc
send it to server
Yea but you want to change it, if I understood correctly, so write perms need to be set to everyone too
write perms has 2 options
server and owner
Oh right, I'm a bit tired, sorry
I actually don't know
I think it is the client, which initiates it, but not sure
No no, no problem man
probably
thx for the help tho
Can we use rigidbody based characters for our game that uses Netcode
It will be tricky but yes, you can use Network Rigidbody and Client network Transform
What do you think about Fishnet
Ive seen online that it offers support foor rigidbody characters out of the box
I've never used it. But unity physics is nondeterministic so it's going to be tricky no matter what you use
Is this using Unity Netcode?
Ooof
I'm completely new to networking and it seems like a physics based multiplayer game was a bad idea 😅
I've posted a yt link in #archived-works-in-progress showing a clip of the kind of game I wanted to make. Is that possible at all or just outright impossible for a newbie
Nothing's impossible. But I wouldn't recommend it for your first multiplayer game
I see
Yes
The [Command] attribute is not part of Netcode. And it looks like you are nesting the globalData network variable
It honestly depends on how good you are with docs, all the physics interaction can be handled through network transforms, the movement off the player has to be client authoritive tho
From my experience, which granted is not a lot, most of it works pretty much out of the box, with netcoee for gameobjects, once you got network objects, network transforms and most importantly player movement setup
But wouldn't recommend such a complex system as a first project, start a new one, get familiar with netcode and after that come back to the project
The important part is, that every omving object, which is nearly everything in your scene, needs to have a NetworkObject and NetworkTransform component, after that you need to register the network prefab of them in the server manager.
Then the physics should pretty much work
It will be fine as long as players don't collide with each other. That's when shit gets wonky.
Command attiribute is for the in game console
Ok. By default only the server/host can write to network variables so this is not going to work on clients. You are also going to get errors if you try to use an array in a network variable. You should probably use a networklist instead
Hey so im making a game and i try to add multiplayer but it wont show up in my assets, what does this mean? And how do i fix it?
What is not showing up in your assets? Which networking library are you trying to use?
I tried using NormCore but it said error while getting auth code then it said system.InvalidOperationExeption: Failed to call unity ID
so i tried using Pun 2 wich is also multiplayer but it said the same thing
@sharp axle What do you mean by Which networking library am i trying to use?
@green tusk Could you help me?
Are you trying to install these from the package manager? I'm just trying to figure out which one you are trying to use.
Yea im trying to install from package manager
i'll send a picture of what i see
[Package Manager Window] Cannot perform upm operation: Cannot fetch authorization code. User access token is expired or invalid. You may need to sign out and sign in again. [Unknown]. I just copy and pasted that but thats what its saying now
Sounds like you aren't logged into Unity
Nope I'm logged in
You need to be logged into the editor not the website
Sorry if this too vague or rudimentary but I've watched a lot of videos and read a lot of docs. Whats the best approach to sync clients joining a session in progress? The issue I'm currently facing is all the network objects that have been destroyed are frozen in place at the place they were destroyed at before the client joined. I'm using a ClientRpc as well as a ServerRpc to return objects back to the pool. There's also some other weirdness happening on the client but I'll tackle that next. In the screenshot you can see frozen missles left over from the host(on the left) on the client(right).
Oke lemme try that
Thx
After i am done with sleepijg
I am using Photon Fusion for my multiplayer game and I am having an issue where the second player who joins the game is unable to move. The first player is able to move without any problems. Both players are able to join the game and spawn correctly, but the second player cannot move their character. I have checked that both players have control of their respective objects and have also checked that the inputs are being sent correctly. Is there something specific that needs to be done in Photon Fusion to enable movement for the second player? Any help or suggestions would be greatly appreciated.
sending server rpc doesnt work but triggers a warning idk what that warming wants to tell me
left side is host/server right side is client
netcode for gameobjects btw
oh wait
it didnt capture right side
and yes ive maked sure both sides hvae their objects spawned
well
i found the issue
the networkhandler i wrote
it doesnt sync
[Netcode] NetworkPrefab hash was not found! In-Scene placed NetworkObject soft synchronization failure for Hash: 704349611!
i get this error
but i dont know why it happens and how to fix it
can someone please help
this stupid error is giving me headaches
i am trying to fix it for 3 hours now
is it because i use dontdestroyonload on it
oh
i found out it has to do with dontdestroyonload
why tho
hey guys, I'm using Unity.Netcode and having a bit of a struggle with syncing an object position. Here is the problem. I have a physical object (with rigidbody) and the ownership is on the host. The client takes ownership and moves the object then gives back ownership to host and the object should keep moving by the inertia. But in the moment of giving back the ownership to host the object stops and and jerks a little bit back. How do I fix it?
.
You might have better luck if you ask on the Photon discord. Check the pinned message here
Ok ty I will try.
I need help understanding something in Netcode for GameObjects. The NetworkManager has a property called Enable Scene Management, which is responsible for synchronizing scenes. Does this mean that if I have a multiplayer game where I want clients to go into scenes separately I have to turn this off?
Yes. But those scenes wouldn't be networked
Can you elaborate on this?
The example I'm thinking of is if you have a city and shops that you can enter into which would load the shop scene
You would need to setup Custom Scene Management
https://docs-multiplayer.unity3d.com/netcode/current/basics/scenemanagement/custom-management
If you haven't already read the Using NetworkSceneManager section, it's highly recommended to do so before proceeding.
Thanks!
I am talking with a few people on fiverr to hire someone to implement multiplayer in my game. I am curious what the going rate for this type of work should be? I don't want to get ripped off.
This is the game. What is a reasonable price to pay a fiverr developer to take this and make it multiplayer?
Whatever you pay them is not going to be enough
thanks im not here for opinions i just want to know what a fair price would be to implement photon multiplayer
Country of origin and experience level would dictate the going hourly rate. You would need a senior experienced developer to make a multiplayer game.
so the job itself doesnt have a price?
No of course not
Sure, you can set one, but you'd have to get estimations on how long someone would think it would take them and use an hourly rate to calculate it.
ok. give me an idea of how many hours it would take say, yourself, to do this job and what your hourly is
But the amount of work to create, especially a multiplayer game, would be a full time job. So you'd need to be paying full time hours/salary amount if you hope to get it done in any reasonable amount of time.
everyone on fiverr just wants to "know my budget" so they can fuck me over against my consent
I don't know what your game is, you've shown nothing about it other than some movement. You haven't shared any details about the overall scope and how multiplayer would work.
First of all, we don't need rape jokes here. Secondly, fiverr is for small time jobs at best.
thats how basic it is. i just want what i already have, but with 1-8 people doing it in the same space
there is no shortage of people offering large scale work
shee the only thing i came here for - a number - is the only thing i didnt get
got plenty of opinions tho
It takes work to sit down and calculate a number, nobody unless interested in having to work for you, is going to do that.
There are many questions to ask, because, again, it's not just "what's exactly in the video but multiplayer" that needs answering.
alright do me a favor and just give me an estimation of how many hours it could take a skilled unity networking person to take this game with basically one 500 line script running everything, and make it so that 1-8 people can be in the same space and do whats in the video
one month of work, $10k, quality is flexible and you got no say on how they do it, this is based on the assumption that you want a professional implementation of what you've shown and said with the usual edge cases handled
so then people saying 10 days $500 bucks on fiverr are scamming or?
no, you can technically make it multiplayer with very little effort
you could also turn it into rocket league, for an additional $10mill
im going for more of a Slapshot:Rebound quality
i can't judge the quality of that
the point is, however much money you give someone, they will use it up
duh thats why im here trying not to get ripped off
it depends on the productivity and skill of the person what you get for that money
this is not a rip off
its how software development works
so you pick a person you know who can do it, give them the time they need, define reviews every 1-2 weeks to check progress/quality and steer their efforts based on that
all projects will have to figure out whats required along the way, there is no perfect upfront plan, spec or estimate
this is commonly referred to as "agile"
yeah im kinda concerned that if i take someone up on fiverr they'll keep asking for more and i wont end up actually getting what i set out to obtain
or some variation of that
thats a reasonable concern with any contractor
you could use toptal instead (considerably more expensive though)
what is?
thats fiverr for real developers
good to know
on fiverr etc. you'd only find developers that can't get onto toptal & co.
At the end of the day i just wanna take the shitty game mechanics i made and have a few friends be able to connect to the same host or server and play around with the mechanics.
not really trying to drop 10k to putz around with some friends
understandable
i'd throw a grand at it if i knew i was gonna get what i wanted
there is a good chance someone on fiverr can do it, but the whole context of the gig-economy on fiverr and your brief makes it a quite volatile situation
you see thats the issue with low-budget jobs, there is a strong desire for guaranteed outcomes but really no way for those guarantees to be realized
guaranteed outcomes are usually created by repeating the same thing many times (not possible with a custom job like yours) or by giving the project a large enough budget that one mistake won't cripple the project and leave either you with nothing or the contractor with an unprofitable job.
technically someone could just install netcode, sync all transforms and call it a day, thats doable in a day
i'd bet most fiverr people will only do the minimum to check your boxes
thats the vibe for sure
overall fiverr is a race to the bottom, i'd not expect you to be happy with the experience unless you are very flexible with your expectations
its much better for stuff where the outcome can be clearly defined quantitatively and qualitatively
thanks for confirming my worst case scenario
i might have to tell the boys the game is off 😦
Photon and Netcode are different ways to do the same thing ya?
@leaden totem This is not related to the channel
If you want to chit chat use the channel I pointed to
Or go to DMs
Can i ask about photon and netcode
#854851968446365696 on how to properly ask a question
Where is the proper place to ask about these two #archived-networking things?
@leaden totem Do a basic research before asking. Then ask a proper informed question.
This looks fun
When in doubt, ask GPT
Whats the best approach to sync clients joining a session in progress? The issue I'm currently facing is all the network objects that have been destroyed are frozen in place at the place they were destroyed at before the client joined. I'm using a ClientRpc as well as a ServerRpc to return objects back to the pool. There's also some other weirdness happening on the client but I'll tackle that next. In the screenshot you can see frozen missles left over from the host(on the left) on the client(right).
If they have network objects on them then they should automatically sync
Thanks for the response. They do all have NetworkObjects if I understand. Network Object components in the inspector.
should i use photon fusion or netcode for game objects for a fast paced fps game
Fusion is probably better out of the box feature wise. But it will get expensive
I've decided to stick to Netcode personally. No one is going is to be more liable for they're stuff than Unity themselves. Just my take, new at this though
agreed, the future for netcode is looking bright
additionally the docs are quite good so far
Should i use photon quantum or netcode for a competitive physics based ball game
If you can afford Quantum, go for it. Might also be good to look into Netcode for Entities as well
for your game and your use case you should use netcode
I will say it seems like Netcode for GameObjects struggles with solutions to physics. I've been trying to find a solution to having the client game object have control of it's player object while retaining rigidbody physics interaction. Adding a Client Network Transform removes its physics and a Network Transform keeps the physics but loses player control. I believe the right solution to my game would be to give the client access to its Network Transform, since it's supposedly possible. Any help appreciated 🙂
physics are not a networking problem, if you mean to predict physics sim outcomes on clients as part of lag compensation, netcode (and practically all other libraries) don't do anything to help
the easiest way is to sync physics is to have clients interpolate the physics sim results they receive from the server as changes to transforms
physics in a non-authoritative netcode setup are a mess
I'm sure I'm probably overlooking a simple solution.. Probably not following but wouldnt changes to transforms negate the use of rigidbody's? I'm working on a top space shooter for context ^
your server runs the physics and updates the transforms of the relevant objects, the network transform on those object then syncs the outcomes to the clients, on the clients all rigidbodies and colliders are disabled (this is if you have no lag compensation)
if you want lag compensation it all gets very complicated
but you can do some basic prediction just based on the inferred velocity of the transforms on clients, this will be quite inaccurate depending on the actual lag you want to compensate for, usually you'll have this just to have smooth motion on your transforms
its not suitable for competitive games, but often sufficient for cooperative stuff or anything that doesn't require aiming at moving targets
That is helpful, thanks. I haven't really gotten to the point of addressing lag(it hasn't been a problem testing locally via ParrelSync but don't doubt it will need to be addressed), I just want my client to be able to push around other object floating in space like the host is. So you're saying the only solution is to add something like a ServerRpc on client collision to and do something like .AddForce? I've just been looking into a server based approach
the simplest setup is to have the client only send user inputs to the server, then have the server simulate everything, update all transforms and the clients just receive these visual updates (transforms & some RPCs) and do no logic themselves (besides connecting to the server and cosmetic stuff like playing effects, maybe show/hide UI and derive commands from UI widgets)
Current Unity Physx is non deterministic which make prediction close to impossible in some cases.
The new DOTs Unity Physics is supposed to rectify that
Right, that's the approach I've concluded on. Thanks for clarifying. Now it's a matter of implementing. Any advice on getting the movement input the server is appreciated. I have an if(!IsOwner) check on top of the script. maybe just move the movement scripts before that check.
its all quite simple once you've fully thought through and understood how the information flows from client to server and back
I watched CodeMonkey's video on that last night. It's ready to be used? Probably the perfect solution to what I'm doing. I'm working on a slither.io meets topdown shooter type game
there are very few general rules to follow
its not a solution to any of your problems if you arent already an advanced network developer
I'm a junior developer without a full time job currently though! Haha, going to look into your solution more. Very helpful
Dots Physics is still in preview in any case
if you make something based on what i described and see the limitations you will be in a much better place to dive into DOTS stuff
I'm all about that hard-learning
Keep physics interactions as simple as possible. Avoid player collisions if at all possible
Saying that only makes me want it more but I hear you
Hi, how do I free the allocation of a player in relay if they disconnect? For example, if player 2 joins it has ClientId: 1, if it closes the game and rejoins now has ClientId: 2. How do I avoid this? I'm using anonymous login btw
I don't think you can. client id will always increment
oof if that's the case I have some serious refactor to do lol
You can see a bit on how the Boss Room handles reconnection here
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/reconnecting-mid-game
In a multiplayer game, clients might get disconnected from the server for a variety of reasons (such as network issues or application/device crashes). For those reasons, you might want to allow your players to reconnect to the game.
Thanks!
I have some test code here, which is supposed to spawn a player when they connect as a client, but when a new prefab is created, the new one has 'isLocalPlayer' and 'isOwner' checked (on the host). Would anybody happen to know why this is?
I'm surprised that works at all. You can't send a GameObject as a parameter like that
Not even if it is a network object?
You can send it as a NetworkObjectReference as long as it was Spawned already.
I'm having trouble figuring out what you mean. Could you provide an example? 😭
Brief explanation on using NetworkObject & NetworkBehaviour in Network for GameObjects
thank you
With netcode for game objects, if I don't specify any guards such as isOwner, isClient, or isServer the code runs on both the client and server, correct?
and components like NetworkTransform and NetworkRigidbody are automatically server authorative? is my understanding here correct?
I was able to make it so the new player that is spawned is no longer the localplayer (thank you by the way), but the host still owns all other players. Any advice?
I believe how it is is that the code will run on the server if the player is hosting, otherwise, the code will only run on the client unless you call a ServerRPC.
I should have mentioned I'm using a dedicated server setup, where client and server are distinctly different
Right, it will run wherever it is called. If it's on the player then it will run on all the Players everywhere in the scene
does anyone know any Pun tutorials on how to add teams to my game and also how to create a death log?
You should probably be calling that serverRPC in the Onclientconnected callback
You might have better luck on the Photon discord. Check the pinned message here for the link
does anybody know the difference between SpawnAsPlayerObject and SpawnWithOwnership? When should each be used?
The only thing special about player objects are the convenience methods available to find them. Like NetworkManager.LocalClient.PlayerObject and the fact that there is only one player object per client. So checks of isLocalPlayer are super useful
So i have the basis for a physics based multiplayer game, and my current setup is server authorative (client calls a server rpc to send its inputs and server determines positions of clients and sends that back out)
I'm interested in adding latency prediction to my clients to make the inputs more responsive. Would I just use simple guards like
if (IsServer) {
//do server side calculations
}
if (IsClient) {
//do client side predictions and lerp towards server predictions
}
or is there a more pragmatic / unity way to do this?
I'd also like to maintain authority on the server
That's actually the opposite of prediction. That will always have you playing catch up to the Server.
This is a short video explaining the basics
https://www.youtube.com/watch?v=TFLD9HWOc2k
Welcome to this Unity Tutorial where we go over Determinism, Fixed Tick Rate, Client Prediction, and Server Reconciliation. Deterministic Programs and Fixed Tick Rate are more theory but really important to understand in order to implement Client Prediction & Server Reconciliation. I then go into how to code Client Prediction & Server Reconcilia...
what does this error mean RPC method 'RPC_CreateController(Boolean)' not found on object with PhotonView 1. Implement as non-static. Apply [PunRPC]. Components on children are not found. Return type must be void or IEnumerator (if you enable RunRpcCoroutines). RPCs are a one-way message.
code:
void RPC_CreateController()
{
PhotonNetwork.Destroy(controller);
controller.SetActive(false);
spectate = false;
Player player = PhotonNetwork.LocalPlayer; // or replace with the desired player object
object teamObj = player.CustomProperties[TEAM_PROPERTY_KEY];
int team = (int)teamObj;
Transform spawnpoint = SpawnManager.Instance.GetSpawnPoint(team);
if (player.CustomProperties.ContainsKey(TEAM_PROPERTY_KEY))
{
if (team == 0) {
controller = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "NeonContainer"), spawnpoint.position, spawnpoint.rotation, 0, new object[] {pv.ViewID });
} else if (team == 1) {
controller = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "JettContainer"), spawnpoint.position, spawnpoint.rotation, 0, new object[] {pv.ViewID });
} else {
Debug.LogError("Erorr: No team assigned");
}
}
SpectateCam();
}```
RPC call:
``photonView.RPC("RPC_CreateController", RpcTarget.All, false);``
what should I select when choosing rigid body target 2d in mirror when i click on the circle the are no options
its ok i figured it out
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
public class PlayerMovement : NetworkBehaviour
{
public float speed = 5.0f;
public GameObject playerPrefab;
private Rigidbody2D rb;
public override void OnStartLocalPlayer()
{
base.OnStartLocalPlayer();
// Enable the player's rigidbody when it becomes the local player
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
Debug.Log(rb);
if (!isLocalPlayer ) return;
float y = Input.GetAxis("Vertical") * speed * Time.deltaTime;
Vector3 movement = new Vector3(0, y, 0);
rb.MovePosition(rb.position + new Vector2(0, movement.y));
}
}
why isnt the player moving ?
when I debug.log(rb) it does give the value of rigid body
Photon Fusion:
Hello, how to sync NPC's movement, animation on the network? I can do one in Host's simulation but I want it to be the same everywhere and if player(client) lefts/joins, it should be synced. and when client joins late and I spawn it on my local simulation, what should I set to spawn point?
And how to spawn using Runner.Spawn?
or this should be done only host side
Cannot resolve symbol 'LobbyEventCallbacks' - this method is outdated, what can be used instead? in 1.0.3 it is not
Did you add the defines from the Sample?
UGS EVENTS BETA NOTE When using the Events code in this sample, make sure your Editor Project Settings > Player > Scripting Define Symbols include: UGS_BETA_LOBBY_EVENTS and UGS_LOBBY_EVENTS
Is there some sort of way to create client-side only variables and server-side variables without making a seperate class?
im thinking something along the lines of
public class SharedNetObject: NetworkBehaviour
{
//shared vars
private int sharedVar = 0;
//client vars
#if IsClient
private int clientVar = 0;
#endif
//server vars
#if IsServer
private int serverVar = 0;
#endif
}
I understand the above example won't work as IsClient and IsServer are runtime variables and not compile time, but I'm wondering if it would be possible to get some sort of similar functionality as the above (ideally using compiletime constants, however runtime is fine too)
I know that you could do something like
public class SharedNetObject: NetworkBehaviour
{
//shared vars
private int sharedVar = 0;
//client vars
private int? clientVar = null;
//server vars
private int? serverVar = null;
void Start() {
if (IsClient) clientVar = 0;
if (IsServer) serverVar = 0;
}
}
however this is a bit messy, and ideally I don't need to make clientVar and serverVar nullable
I'd like to mention that for my use case I don't care about IsHost as my setup will always be
client <-> dedicated server
(but the above could be easily modified to support IsHost)
Keep in mind, this is not the same thing as network variables as I don't need synchronization between these two
You can change network variable read and write permissions but that's it.
https://docs-multiplayer.unity3d.com/netcode/current/basics/networkvariable#permissions
Introduction
how to avoid a serverrpc and a clientrpc that modify a player's stats from both being executed on the host, giving them the stat modification twice? I'd like to avoid using if (isHost) return; everywhere...
You can use compiler defines separate out code if need be
yeah im thinking either compiler defines and pass them as a compilation flag or something (idk how compiler defines work yet but that sounds like something they should be able to do)
Or I'm thinking of creating some annotations to simplify the whole nullable pattern
[ServerVar] int serverInt = 0
[ClientVar] int clientInt = 0
if you try to get or set the serverInt while on the client it will do nothing
and I don't have to write annoying getters / setters for every var
Thats basically it. Though stats should either be server authoritative or client authoritative. Not both.
well i need the client to be able to read their own stats, that's why i use the serverrpc + clientrpc strategy
Thats what network variables are for
if you want to use rpc's for this (which I recommend you don't) your stats need to be server authorative and then synchronized using a ClientRpc from the server
alright. gonna have to figure out how to do that with my non serializable class
what makes your class non-serializable
BigInteger
just wondering do you actually need BigInteger
do you have numbers larger than INT_MAX64
yes, but I can convert it to / from a string
probably the move
also you can't use a double or something?
do you NEED integer level precision?
hello
i create game with mirror, but when I host my game camera works good
but when I connect client
hosted client camera change to new client camera
Any help will be appreciated.
You want the camera to be assigned when the player is created. void start{playerCam = GameObject.Find("Main Camera")}
No
when I host game
player is created camera works fine
but when i connect another client
first client camera changes to second client camera
(to new camera)
Do you have an "IsOwner" check?
You will need to make sure that only the local player has control of the camera
there should only be one camera in the scene
what do you mean?
add "if (!IsOwner) return;" before assigning the camera so the clients aren't running scripts for other clients
Unity expects there to be only one camera in the scene. the last camera added becomes the active main camera
Yes how to fix it
?
don't spawn a 2nd camera. or just disable it on remote players
that doesnt work
Has anyone used c# compiler directives with RPC's?
//client rpc for receiving state from server
[ClientRpc(Delivery = RpcDelivery.Unreliable)]
private void PlayerStateClientRpc(ulong sourceNetworkObjectId, StatePayload state)
{
#if IS_CLIENT
latestServerState = state;
#endif
}
//server rpc for sending input to server
[ServerRpc(Delivery = RpcDelivery.Unreliable)]
private void PlayerInputServerRpc(ulong sourceNetworkObjectId, InputPayload input)
{
#if IS_SERVER
inputQueue.Enqueue(input);
#endif
}
I successfully defined IS_CLIENT and IS_SERVER, thats not the problem
I'm just wondering if they can still be called from the other end, even if they are missing a body
for example, server calls PlayerStateClientRpc, the server is not aware of the implementation (body) of the function, but it knows the signature.
However on the client it is totally aware of the implementation.
Looks like it works, my bug was elsewhere

Those defines don't really do anything. ClientRPCs will only ever run on clients. Same for ServerRPCs.
Does that also mean [ServerRpc(RequireOwnership = false)] is only there to hide errors?
That is for when the client is not the owner of the network object that serverRPC is on. Usually will happen for some kind of manager script owned by the server. Like for UI buttons
I am using Unity Multiplay and just deployed my server and started a test allocation. However after ~ 3 minutes the server crashes with the following log output:
Caught fatal signal - signo:11 code:0 errno:0 addr:(nil)
Obtained 13 stack frames.
#0 0x007fbf5cf23420 in funlockfile
#1 0x007fbf5cdfa23f in clock_nanosleep
#2 0x007fbf5cdffec7 in nanosleep
#3 0x007fbf5dd1c851 in std::_Rb_tree<void const*, void const*, std::_Identity<void const*>, std::less<void const*>, std::allocator<void const*> >::_M_erase(std::_Rb_tree_node<void const*>*)
#4 0x007fbf5dbedb13 in int* std::_V2::__rotate<int*>(int*, int*, int*, std::random_access_iterator_tag)
#5 0x007fbf5dbedbda in int* std::_V2::__rotate<int*>(int*, int*, int*, std::random_access_iterator_tag)
#6 0x007fbf5dc41e17 in int* std::_V2::__rotate<int*>(int*, int*, int*, std::random_access_iterator_tag)
#7 0x007fbf5dc3b1c7 in int* std::_V2::__rotate<int*>(int*, int*, int*, std::random_access_iterator_tag)
#8 0x007fbf5dc3b182 in int* std::_V2::__rotate<int*>(int*, int*, int*, std::random_access_iterator_tag)
#9 0x007fbf5dc3b46c in int* std::_V2::__rotate<int*>(int*, int*, int*, std::random_access_iterator_tag)
#10 0x007fbf5de62fd7 in PlayerMain(int, char**)
#11 0x007fbf5cd41083 in __libc_start_main
#12 0x00564ede580029 in (Unknown)
Executing Unity Signal Handler
In the screenshots you can see the events happening on Multiplay. An idea what is happening? Is it Multiplay related or solely the server build is whacky?
I normally build a macOS dedicated server locally and test it. There are no issues with that. However for Multiplay I have to generate a Linux build. Therefore I can't tell if it behaves differently on my local machine :/
I checked my logfile for any exceptions happening. But it looks clean. I have no idea what the source of the problem is.
Warning: There's a known issue with Unity Editor version 2022 that prevents the SDK from working. If you use version 2022, ensure you use version 2022.2.3f1 or later.
https://docs.unity.com/game-server-hosting/en/manual/sdk/game-server-sdk-for-unity#Requirements_and_limitations
Sup
I have a few questions regarding Unity Networking
How good is it at handling rigidbodies
My players use a rigidbody controller and theres a lot of physics in my game so I'm kinda worried about dis
Physics is going to be hard no matter what framework you use. Unity physics is currently non-deterministic so that makes syncing very hard
Failed to find entry-points:
System.Exception: Unexpected exception while collecting types in assembly `Unity.Netcode.Editor.CodeGen, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null` ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Mono.Cecil, Version=0.10.0.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e'
at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in <ebb9e4250ed24cbfa42055e3532ef311>:0
at zzzUnity.Burst.CodeGen.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00039] in <a2dd15248a25411e914af2a2c82fb63f>:0
at Burst.Compiler.IL.AssemblyLoader.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00079] in <a2dd15248a25411e914af2a2c82fb63f>:0
at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00038] in <ebb9e4250ed24cbfa42055e3532ef311>:0
at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00006] in <ebb9e4250ed24cbfa42055e3532ef311>:0
at Mono.Cecil.TypeReference.Resolve () [0x00006] in <ebb9e4250ed24cbfa42055e3532ef311>:0
at Burst.Compiler.IL.Server.EntryPointMethodFinder.CollectGenericTypeInstances (Mono.Cecil.TypeReference type, System.Collections.Generic.List`1[T] types, System.Collections.Generic.HashSet`1[T] visited) [0x0002f] in <a2dd15248a25411e914af2a2c82fb63f>:0
Whats this
I see this when I import NetCode
Make sure you are on a supported Unity version
I am using 2021.3.16f :/
I am
and Burst Compiler is Up to Date as well
I get
The type or namespace name 'Netcode' does not exist in the namespace 'Unity' (are you missing an assembly reference?)
Even with NGO installed
Yea, it's not finifhing compiling so it's not fully installed. Are you installing from the package manager? v1.2.0
Yep The issue was with burst compiler
This solved it for me
The "Crash" is happening cause GSH can't query my server. It's starts and get allocated but no healthcheck is possible
The QueryHandler is part of the SDK. If you are on an up to date version of Unity, then open a support ticket from the Dashboard for the Server Hosting team
Do Client's need to initialize network object pools? I call an initialize when host joins
If you are using the one from the docs, it will initialize when it spawns in the scene for the clients
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/object-pooling
Netcode for GameObjects (Netcode) provides built-in support for Object Pooling, which allows you to override the default Netcode destroy and spawn handlers with your own logic. This allows you to store destroyed network objects in a pool to reuse later. This is useful for often used objects, such as projectiles, and is a way to increase the app...
So here's this. Client right, host left. I haven't set up explosions on the client yet, that's fine. I'd like to address the missile clearly not making contact on the client before despawning. (the server is triggering the despawn). Im using netcode for gameobjects and don't really want to add any other multiplayer api's. Off to bed for me, will check back in the morning if anyone can point me in the right direction. Obviously getting some rudimentary network stuff but I'm a noob.
Hey, sorry to bump on this old message. I upgraded my unity transport to the version you said above and this is causing issues with me 2D package and Unity's test runner framework. The whole collection package got upgraded alongside (probably due to dependency I am presuming). Is there a way to fix this?
the easiest way would be to remove those packages
What packages? collections and 2d?
I removed the 2D package however it seems like Collections is a core package
the test runner and 2d packages
@covert haven if the game requires voice, it may end up costing you money at the start of development. Then you'll have to hope eventually the players start generating the revenue to hopefully catch up with the expenses.
Like I said though, most players will use discord, especially for a game like phasmaphobia
I want to run the tests on the upgraded package...
Actually believe it or not, many players like to use the voice chat in the Phasmophobia because it kinda destroy the exprience if you dont use it xD, but yes I understand that it would cost money to start the game which is okay. The problem is I'm only worried what if it doesnt generate much and the game is left with only few players, then I would have to close the servers cause I just cannot keep them up forever, but I would feel bad for the players that are there, but I mean
If 500 CCU would cost me around $200 per month
And the game price is around $15 I guess that
For the game to reach 500 CCU there would have to be at least 10x the sales of the CCU value
Right xD?
Turns out microtransactions are not just developer greed
You would need at least 13 sales a month to cover the cost of Photon. If you believe you can do at least that, maybe it would be the best option. There would be things to consider too; how many platforms will the game support, how will you manage your store front (SEO), etc.
Just remember though, it's better to add new features when a game gets more popularity than it is to remove features from current players.
Exactly 😄
That is a 100% true statement. It's really not always greed. Depending on the popularity of the game and how much work they actually put into them, it's usually just to fund the game. Most game developers are just passionate about the hobby, like you or me. Most are like everybody else.
Well it will be my first Steam release so I don't know what to expect, I'm not really sure how hard it is to get sales on Steam
should probably take sales talk over to #497872469911404564
It can be quite tricky for a new IP. Some don't see success till later after release, some have already built a community. Then there are the few that get picked up by gamers right from launch and it does amazing, but remember "what goes up, must come down". So you'll just have to keep on top of your store pages keeping them fresh and updating the game fairly frequently
Uhh alright, well I guess the right thing to do would be just to try it and see what happens xD
Thank you for the tips!
Exactly! I would hate for you to use all your resources in the hopes you end up having them replenished and it doesn't happen, whether it be time or funding. Especially when the paid feature could be added after you've seen whether the game is popular or not. However, these are just my thoughts, ultimately it's up to you. You know the game and situation best as you made it. 
balls
Well thank you so much! For the replies and also for your time! That's right I guess I'll see during the development whats best for my game. I'm just planning it out a little bit at the beginning so I know what I need to do xD
just use nothing and when it starts generating revenue use photon
The game will include both singleplayer and multiplayer lobbies but the game should be more marketed towards the players who like playing with someone, like in Phasmophobia
what is the game about ?
I'm trying to combine In Silence with Phasmophobia
But can't say much right now
No problem, anytime! Excited to see what you'll release
whatever networking you go with, I'm sure it'll be the right decision
then for a horror game with multiplayer i say go for it
Do you have an email or should I just ping you in the server? Would love to show you the progress after some time, if thats okay! 😄
Yup thats what I'm thinking!
Of course, just @ me in this server under the appropriate channel 
Alright got it! 😄
Its for PS3D so I wouldn't randomly send him an email there xD
you can ask him there since he wont reveal his personal email here
I would say the support email, but that is used for support tickets haha. Already enough of those as it is
. Account restoration for old players coming back though 
and he doesnt check dms for some reason why is that tho @quaint sierra
The reason I don't have my DMs is for the safety of myself. I would rather have all conversations public, that way nobody can twist words around or fake conversations. The game has gained quite the popularity and there are a lot of bad people out there who would do stuff for clout. So I just medigate the risks of anything 
tbh someone can dm you and talk to themselves and make it look like you talked
Respect!
Yeah, they could. However, it'd be different numbers after the username and on my end, DMs have always been closed 🔒
tru tru
I highly doubt any paid game added IAP just to cover server costs.
Even web ads cover the Photon bill
Are there downsides to increasing the tickrate to large amounts (apart from unnecessary bandwidth)?
Lets say 1000TPS or even 10kTPS
Modern networking interface can easily handle this amount of packets if not many more
Sure this excludes players from the lower end of the spectrum, but I'm just speaking hypothetically.
is anyone a expert with networking , i never done it by myself , but i want to do it on my survival game
@slim scarab this ^^^
Asking if someone is an "expert with networking" is not a productive question.
However, I'm sure there are plenty of experts on this discord and the internet in general.
a good place to get started with networking for your game is to look at Unity Netcode for Gameobjects
https://docs-multiplayer.unity3d.com/netcode/current/about/index.html
Learn more about the available APIs for Unity Multiplayer Networking, including Netcode for GameObjects and Transport.
Whats the current free solution for Unity Netcode relay? Seems like Unity has their own Relay service but charges through the moon.
The free tier of Unity Relay is an avg of 50 ccu per month. The free relay services that I'm aware of are Steam Networking and Epic Online Services
Ok thanks
hey everyone! I am making a 2 player game. One player I would like to be the host and the other player connects to the host. can I make this happen without it costing me money?
how do you use the networkobject.trysetparent functioon from unity netcode ? it always gives me an error that it is a group method
You can see an example here
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/d37c360bc8cdbbbf680e2afc5963571e20f28ffd/Basic/ClientDriven/Assets/Scripts/ServerPlayerMove.cs
hi, how can I spawn a object across the network and have it attached to teh amateur of the character?
unity tells me it can only be spawned as a child of a network object, when I try to make the mount point a network object it tells me nesting is not allowed
I need to attach a weapon here, but how
ok I might have a solution, can someone tell me if this is stupid, I just spawn the axe, with a client network transform and set the position and rotation on the client site
not sure how I could do it otherwise, because the unity doc way of just spawn everything seperatly and join them together, is quite unaceptable for a skeleton xD
You can use NetworkObject.TrySetParent after you spawn the item
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/networkobject-parenting
A NetworkObject parenting solution within Netcode for GameObjects (Netcode) to help developers with synchronizing transform parent-child relationships of NetworkObject components.
Does this allow for a non networkobject to be a parent?
I mean there is noway I can make the entire chain to network objects, so I'm kinda lost on how to attach something to my skeleton
Thank you
Yea. it can take a transform or gameobject too
good I will try that, if my next attempt doesn't work, I figured why attach it to the hand, if I can create a gamobject which follows that and uses that as a parent. It's far simpler
honestly that's they way I would do it. I've used fixed joints to attach things to hands as well
sometimes the simple solutions aren't what you think of first
damn that was simple
it works, like first try
Is there one you recommend more? Can I use the epic and steam ones without putting it on steam or epic if it’s on like itch?
I never used either. The steam one has to be on steam. As far as I know EOS doesn't have any such restrictions
okay perfect
and just using base unity for netcode costs money even for just peer to peer?
no. NGO is just the network library. The Unity Relay Service costs money if you go over an average of 50 CCU per month
Major shot in the dark here but; The bullets in my game are being spawned as game objects from a NetworkObjectPool, they fire fine for about 30 seconds but then they stop spawning in for the client. They're still visible for the host though. No errors.
Are you despawning them as well?
returning them to the pool edit: Came up with a solution. You have to call NetworkObject.despawn() for the object to be considered inactive by the network object pool. Thanks a ton for pointing me in the right direction
@spiral lark actually it doesn't need to be on steam, but it makes it much more easy. YOu can use the appid 480 instead and use the ingame join, that's what I'd recommend doing at first anyway, to get a prototype, before you buy an appid
that said putting it on steam makes a lot of sense even if you just want to publish it f2p, since being able to upload it on steam and give keys to people makes it alot easier to find people to play test with
I have a NetworkList with a struct that I cannot seem to sync with my client. Adding items to it with a serverrpc that's called from the client does not add a new item, except when the player is the host. When a client connects to the host, it can actually see the populated NetworkList of the host, but can't request to add anything to their own list, because that causes nothing to happen. Any ideas why?
The 'AddItemToList' serverrpc calls a clientrpc in which the client debugs the length of the list at the moment for testing purposes. The list is populated when the client connects. If the client is a host it works fine...
What Unity + Mirror networking version is the most stable or widely used?
Usually I use a LTS version of Unity just cause I don't want to deal with any funny unexpected issues
does you serverrpc require ownership? (it does by default)
[ServerRpc(RequireOwnership = false)]
void yourServerRpc() {}
yes, but I'm not getting any ownership errors
so the code actually get's executed, but nothing get's added?
exactly.
the clientrpc that is called from the serverrpc even gets invoked
but nothing is added. Not even on the server
Oh I can't help you then, I struggle with netcode my self xD
okay no worries. Let's hope someone else can because this issue left me speechless
how could i sync values under a room? something as simple as an int, that gets synced to every player when joining? i have been sitting on this for days now and can't figure it out!
hello, do you know if UnityWebRequest is a good way tosave datas for my Multiplayer game ?
You could do a network variable or a roomManager, where you store the int and when a player joins it requests the saved variable, the NetworkVariable is easier. You have to set it in a srver rpc tho
I’m sorta new myself but is there a network object attached to it? is it an instance? have you tried keeping an array of all the client lists and iterating through the list to update them from the server?
it's a script that's attached to the player object
does netcode for gameobjects have any way of making someone else the host in the event the host disconnects?
i saw a post from march 2022 saying NGO doesnt have host migration but cant find anything more recent to see if that's still true or its been added
Issue with Network List
Are you using Unity Netcode or Photon?
Not out of the box. You can use the Lobby and Relay Services to reconnect after the host leaves. But the original connection will be lost
https://docs.unity.com/lobby/en/manual/host-migration
Anyone knows if animation layers work with Netcode for GameObjects (NGO)?
I have a Animator Controller with 3 layers, 1st for movement only, the other 2 are the same, attack combo layers, but they use different Avatar Masks if the character is moving or not.
Thing is, the layers are not working when I change the mask weight when using NGO.
I tried debugging changing to a near identical Animator Controller, except this one has just 1 layer with everything the other 2 layers have inside, and no Avatar mask is used. It works like a charm, but obviously the animations and the experience is nowhere near the same.
I'm using a client based animation sync approach with:
protected override bool OnIsServerAuthoritative()
{
return false;
}
And managing the animator parameters locally on each client. The only NetworkAnimator call I make is to .SetTrigger, as the documentation says.
With only that, layers don't work, and I'm not getting any logging either.
As I mentioned earlier, when I change to a single layer approach, everything works as expected.
So, anyone knows if they work with NGO?
photon
Photon has netvars you can use or you can save things to the Room's custom data
how would i do that?
network Animator will only sync states and parameters. It will sync different layers. Mask weight is not something that gets sync as far as I know.
I don't use Photon, so you'll have to read the docs for that. Check the pinned message here for links to Photon's discord and docs
uff,,, okay, thanks!
Thank you, I'll keep investigating!
By "Mask weight" you meant "Layer weight", right?
You said mask weight but yes. You'll need to send it in a network variable or clientRPC
If we allready are by network variable or clientRpc, what is the advantages of using a NetworkVariable over a rpc, you need to do both from the server side, so are they just interchangable, if all you want to do is sync values?
RPCs are one time events. Late joining clients will always get the most up to date network variables. If you don't have late joining players or you want more control over your data bandwidth then you can use RPCs for everything if you want.
That makes sense, thank you
@sharp axle It worked! Thank you for your suggestion!
with NGO are there any issues replacing non-host players who leave with an AI player?
Shouldn't be any issues with that.
So I am currently building a multiplayer city builder using NGO, currently to update all players resources, I iterate through each player each second, and tell the clients of each what to change their GUI to be. This seems incredible inefficient at scale, how would you guys do it?
why is that inefficient, thats how you do it, just that you don't send gui changes you just send the data from which the client infers what to display in the gui
Valid
Premature optimization is the devil. Use the Profiler to track performance. If you are seeing big spikes then deal with those first
You right
what happen when a client calls function that is meant to be called by the server but is not protected by the server attribute ?
what happens in that case ?
It gets executed locally but not om the server side, which could mess up the syncronisation.
For example, lets suppose we have those two easy functions:
TossCoin() {
SendResultsClientRpc("head");
}
[ClientRpc]
SendResultsClientRpc(string res){}
If you cal it from the server in a serverrpc for example everything gets executed as it should, if you called coinToss from a client instead, nothing will happen, because a client cannot trigger a clientrpc, if you instead would run call it on the host, it would work, since the host is the server and a client, so you get funky buggs and that's just a simple example
So tl;dr: it depends on what the server function was supposed to do, how bad the screw up would be
General rule of thumb, for what I'm doing: if it is supposed to run on the server, just make it a serverrpc and it will run on the server regardless of where you call it from, if you are allowed to call it (ownership properties)
thanks does it apply to all engine like mirror photon ? cuz I use mirror ?
Hi I need a little help I am adding multiplayer to my 2D platformer game using Photon and it all works fin until a second player joins the game/lobby then the camera I (or another person) sees from is not on the Player Object that they control why is that? here's my code and tutorial
https://hatebin.com/rwfjkcieiq Thats my code
The second tutorial in my online multiplayer unity game series. In this we will look at how to create and join game lobbies/servers and how to add player movement.
Photon engine - https://www.photonengine.com/
Multiplayer episode 1 - https://youtu.be/nmPukdOsYQA
Player movement tutorial - https://youtu.be/YcJ8q8hEKm8
Animation tutorial - https:...
thats my tutorial
the fundamental concepts should be equal, I use ngo tho and nevcer used mirror
ok thanks for telling
have you deactivated the camera in the prefab?
you could also use this instead:
private void Awake()
{
if (photonView.isMine == true)
{
PlayerCamrea.SetActive(true);
PlayerNameText.text = PhotonNetwork.playerName;
}
else
{
PlayerCamrea.SetActive(false);
PlayerNameText.text = photonView.owner.name;
PlayerNameText.color = Color.red;
}
}
this will make sure, that the camera is deactivated, if it is not the local player, I just added one line to your code
Im going to try that ill let you know if it works
if that doesn't work, I have no idea, I assume it could be, that you just forgot to deactivate the camera, happes to me all the time, when I change something
OMG THANK YOU SOO MUCH I HAVE BEEN ON THIS FOR 3 MONTHS AND YOU GOT IT WORKING! THANK YOU THANK YOU 🙂 🙂 🙂
3 months? damn you are patient, I would have probably just scraped everything and redone everything from scratch with another tutorial xD
and no problem, have fun further developing
xD And you too! And again THANK YOU
Hello, I'm at a loss. I'm trying to follow a tutorial on how to set up multiplayer through Unity's netcode, but the tutorial is having an easier time by having the networkmanager create the player prefabs which I have to handle myself. I can get it working on the host's side through:
PlayerNetworkController clone = Instantiate(playerNetwork).GetComponent<PlayerNetworkController>();
PlayerNetworkController.instance = clone;
clone.GetComponent<NetworkObject>().Spawn();
But I'm getting errors when doing it on the client side because Spawn() seems to be something you can only do on the host's/server's side. Now I'm finding contradicting information, some people say you should be using ServerRpc so I made a method with the same code using [ServerRpc] and I'm not getting the error that only the server can do it anymore but the prefab is still not being created. And then there is also https://docs-multiplayer.unity3d.com/netcode/current/basics/networkobject/index.html which talks about using methods like GetComponent<NetworkObject>().SpawnAsPlayerObject(clientId);
What am I missing here?
I tried doing it with the latter but it's also not working (and I don't understand what that method is for in the first place)
Hey
Ive seen so many resources for NGO
Not even close to any other solution
But ive also hear thay its only for small party games
And wont work for a fast paced shooter
How true is this
I've made some progress. The 2nd player can join in now and will see the 1st player (server host) moving, but for some reason the prefab of the client doesn't get spawned.
if (PlayerNetworkController.instance == null)
{
Debug.Log("Player does not exists.");
if (IsServer)
{
Debug.Log("Is server. Creating server player");
SpawnPlayerServerRpc(0);
} else {
Debug.Log("Is not server. Creating client player");
SpawnPlayerServerRpc(1);
}
} else {
Debug.Log("Player already exists.");
}
Any reason why? It reaches the part where it says "Is not server." but it just won't spawn the client player object
[ServerRpc(RequireOwnership = false)]
public void SpawnPlayerServerRpc(ulong clientId)
{
Debug.Log("Spawning player with id: " + clientId);
GameObject newPlayer;
newPlayer = (GameObject)Instantiate(playerNetwork);
NetworkObject netObj = newPlayer.GetComponent<NetworkObject>();
newPlayer.SetActive(true);
netObj.SpawnAsPlayerObject(clientId, true);
}
This just means if you want to use it for more you need to be prepared to extend it with the required functionality. It’s design is not inherently limiting it to small games. For competitive games you usually have to do so much extra work on top of what ngo (or any library) provides that it makes little sense to market it as a solution for that, but you can still use it as a framework to get there.
You'll want to look into Netcode for Entities if you want fast passed and competitive. DOTs Physics is deterministic so it makes client prediction and reconciliation much more doable.
Are you using a Singleton for your player controller?
Hello guys,i am creating a game about Air Hockey and i am using photon PUN2 to do it,to syncronize the position of the disk between the 2 players i did something like this: The owernship of the disk at the start is of the master client than everytime that the players hit the disk with their controller the owernship is passed. I implemented this but i tryed a game with a friend and the position of the disk is not "syncronized" between the 2 players. My question is,do you think that exist a better solution?
Considering you have multiple players that may not be a good idea
Does that really apply to multiple instances of the game running? I mean there are also other singletons in the game and one of each is running on each client
unless the networking has specific issues with singleton player prefabs
I don't know how your game is set up. But when a 2nd player spawns in with a 2nd player controller, that would screw up the Singleton
the player controller just contains methods to move around the player, but I was playing around and created an empty game object without any script but the network ones attached to it and it still doesn't spawn it
there must be some other issue
I got an idea from reading the forums, someone was talking about callbacks and making sure you aren't trying to spawn an object when the connection hasn't been fully established yet
so maybe that's it
I don't know, maybe it's just something you're supposed to know on your own, maybe it is mentioned somewhere... but I think it's also weird not having this somewhere in the Unity docs mentioned when not using the NetworkManager's built in prefab spawning from the inspector
it seems like that thing is doing a lot in the background which you have to do and make sure on your own when doing it in code instead
the only thing I found out is the stuff about assigning clientIds etc. but I'm still not sure what else it does exactly
How do i get custom room properties?
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
public class Player : NetworkBehaviour
{
[NonSerialized] public float speed = 10;
private Rigidbody rb;
public override void OnNetworkSpawn()
{
if (!IsOwner)
{
Destroy(this);
}
else
{
NetworkSetPositionServerRpc();
}
}
[ServerRpc]
public void NetworkSetPositionServerRpc()
{
transform.position = new Vector3(-10, 7, -28);
}
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
rb.velocity = new Vector3(x, 0, z) * speed;
}
}
The host moves both players and the other client cannot do anything
You need to check whether the person moving the player is the owner or not. Use IsOwner() and maybe watch a tutorial on YouTube because this is really basic. Code Monkey has one on this
You should not be destroying the component just disable it if need be. Plus on spawn i do not think the owner has been set yet.
isn't that just destroying the script?
Gonna need more info. What are you using here, photon?
ahh ic
alr solved it, thanks tho ^^
i watched code monkey's 6 hour tutorial on NGO recently and recall in some spots he'll use something else in place of Awake for network objects, but cant recall where in the video he was doing that or why. any chance someone knows? guess i need to rewatch 😄
i think OnNetworkSpawn is what i was thinking of
has anyone used epic online services here? was it good? i'm gonna make a multiplayer 2player coop game using peer to peer networking to hopefully cost me nothing
This will tell you when those functions get called. The timing can get tricky
https://docs-multiplayer.unity3d.com/netcode/current/basics/networkbehavior#spawning
Both the NetworkObject and NetworkBehaviour components require the use of specialized structures to be serialized and used with RPCs and NetworkVariables:
I’d just recommend looking at netcode for gameobjects, it’s unitys baked in multiplayer plug-in, and then use epics transport
If anyone has used the Facepunch Transport for unity gameobjects
(https://github.com/Unity-Technologies/multiplayer-community-contributions?path=/Transports/com.community.netcode.transport.facepunch)
Do you know how to get the steamId of a client who is connecting?
using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
public class Player : NetworkBehaviour
{
[NonSerialized] public float speed = 10;
[NonSerialized] private NetworkVariable<Vector3> velocity = new(writePerm: NetworkVariableWritePermission.Owner);
private Rigidbody rb;
public override void OnNetworkSpawn()
{
if (IsOwner)
{
NetworkSetPositionServerRpc();
}
}
[ServerRpc]
public void NetworkSetPositionServerRpc()
{
transform.position = new Vector3(-10, 7, -28);
velocity.Value = Vector3.zero;
}
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
if (IsOwner)
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 value = new Vector3(x, 0, z) * speed;
velocity.Value = value;
rb.velocity = value;
}
else
{
rb.velocity = velocity.Value;
}
}
}
Why is the clients movement pretty laggy?
as playing as the client the movement has a noticeable delay
Hi guys, anyone knows about Mirror? Will It be affected by UNet deprecating?
Obviously not as UNet was deprecated like 4 years ago
hey i have network transform script on player prefab and i turned on position and rotation but it's only transforming rotation
it transforms the rotation from host to client
Hi I have a question, when client connects to relay, background UI gets smaller, so player icons look small, what is causing this?
Your UI should not be networked. Its getting synced with the host with a different scale
Thanks it solved it
the method AddPlayerN() isn't being executed on players if they aren't someone with actor ID 1... if i play this in the editor it makes me wait 3 seconds as intended, but for every player i build and then make connect, it just doesn`t go anyfurther then the LogError() any idea why?
thats what I was planning on doing. Im just really trying to not spend money
and its a turn based game so latency due to peer to peer isnt an issue
I’m pretty sure it’s free
Netcode is free. The unity relay service has a free tier of under an avg 50 ccu/mo.
can anyone help?
When storing data (player stats; only has to be updated when game round is over) on a databank server like mysql for example and Im having players from each region, like europe , asia, na etc.. Do I need servers in these each region and sync them together or can I just host servers in 1 region because In my usecase, a short latency isnt required? Please tag me in your answer that I'll get notified. Thanks!
If there are no errors, then you'll need to implement some kind client prediction to smooth out the lag
I mean you are saying that but why the velocity only being managed by the server
This just depends on how large your player base is. Nobody wants to sit around for 30 seconds after a match while their stats save
client is only moving because I am setting the velocity NetworkVariable
do a virtual movement client based which is a prediciton on where the player is moving, if the prediction is incorrect due to lags, then the player has to be teleported to the right position which the server has managed, -> its done in various triple A games
the problem is (afaik) that the velocity is being fully managed by the server, if I don't use a network variable here then the client will refuse to move at all, can I not use velocity in this scenario? I am using a Networked Transform if that changes anything
Yes thats right, would it be possible and allowed to avoid hosting additional servers for player stats by creating for example an achievement via steam api and using the current progress as value like -> "Achieve Level 100" -> Current Progress Level 56/100 -> The player is level 56 !
hmm maybe I need a network Rigidbody? I'll try it idk why i didn't try it previousl
also what would be the theory behind network prediction? Would I just make it so that if the servers variable of the position is very different from the players then it changes it back to the server position??
I remember watching this video, it might help you get a better view on network delays and how to avoid high delays
https://www.youtube.com/watch?v=eQt7TwCr6ao
I finally decided to tackle some of the more complex issues I was having with multiplayer, and this is how it went...
Next devlog: https://youtu.be/cYLnVp1ngwA
Pirate game playlist: https://www.youtube.com/playlist?list=PLXkn83W0QkfmQI9lUzi--TxJaOFYIN7Q4
⎯⎯⎯⎯⎯⎯
More about client prediction & reconciliation: https://www.gabrielgambetta.com/cli...
alright I'll watch it
its very entertaining and educational
I usually show people this video
https://youtu.be/TFLD9HWOc2k
Welcome to this Unity Tutorial where we go over Determinism, Fixed Tick Rate, Client Prediction, and Server Reconciliation. Deterministic Programs and Fixed Tick Rate are more theory but really important to understand in order to implement Client Prediction & Server Reconciliation. I then go into how to code Client Prediction & Server Reconcilia...
Both steam and unity have Cloud Save services. I assume epic has a free one as well
how can I use the built in Network scripts to achieve this though? Unity has a Network Rigidbody component but it doesn't have any type of Serializable properties or even public properties I can change
okay thanks, Im just a couch programmer, havent looked into all the available services out there. Steam and Unity Cloud Save Services are synced and dont depend on the region right?
There is no built in client prediction. You have to write your own system
so can I even use velocity for something like this?
because it's just gonna be delayed on the client right?
and the client only cares about the velocity on the server (from what I can tell)
Not sure about steam but I know Unity's is not region locked.
Okay thank you sir!
Syncing physics is a very very hard problem. Unity's physics is nondeterministic. So normally you would just grab the current server position and lerp to it if your prediction gets too far off
alright, thanks for your help
In Unity Mirror, is there a convenient Method I can call from the Server whenever a new Client connects? It looks like there was a legacy OnServerConnect(...) which was retired some time ago.
Alternatively, I'm open to suggestions on how to initialize a Dictionary from Server --> Client immediately when new clients connect. If I can't find a Method like the retired OnServerConnect(...) then my backup plan is to use OnStartClient() to send a [Command] to the server to echo back a [TargetRpc] with the Dictionary ... but that all sounds very clunky.
Am I supposed to use the beta version 2023.1.0b10 or the alpha 2023.2.0a8 of unity to use com.unity.multiplayer.playmode? or will the LTS versions work aswell?
Have a look at the implementation of network variables and make a custom one for your dictionary
Any version 2023 should work
Hello
It is my first time using NetworkList (https://docs-multiplayer.unity3d.com/netcode/current/basics/networkvariable/index.html), it states in the documentation that if both permissions "write" and "read" are set to "owner" that server can still read and write to NetworkVariable, I am not sure if the same applies to NetworkList (but I would hope so).
Anyway, in my scenario something is wrong, as when i run the game as "server" and try to remove something from network list, it returns m error: "InvalidOperationException: Client is not allowed to write to this NetworkList". I placed debug before the removal and I can see that the permissions are for owner and it runs on server, so I am not sure what is wrong.
The code for the whole class is here: https://hastebin.com/share/apocugohag.csharp
Can anyone help me?
From my point of view it seems that the statement about ownership for NetworkVariable is not true for Networklist
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I think the docs are wrong there. the server will always be able to read but it will not be able to write.
I thought so
I need help solving errors
this really isn't that good of an explanation - the implementation does so many uncessary things, implements a fixed tick system when not needed, etc.
extremely over complicated
If you know of a better better video, I would be glad to spread the good word
2023 is beta right? im using 2021.3 just so its a stable release without any errors that I will not find the source of, since the error might be caused by the beta version
yes. its currently still in beta
No idk, problem with YouTube tutorials I suppose
But this really ain’t a good example of how to do CSP
i watched the entire tutorial now, yeah this is.... uh.. dont do this
I'm very new to networking, and I was wondering how using Photon one would calculate server-side changes. Such as, if I have an AI with random movement, I can't just calculate the random movement on each client, otherwise it will not be synced.
Depends on which photon product you're using
I'm using Photon PUN plugin for Unity
PUN doesnt have a server
Does that mean I am unable to do what I wanted, or do I have to find a third tool, or should I stick with a static world?
you can have the master client act as a server
I am using netcode for gameobjects for a fps game the player doesn't controll the same camera from which he is moving
I haven't finished a multiplayer game before, so I'm trying to start with fairly small goals.
@ancient mist check our support discord
Are you permitted to link me to it?
Is this a question?
yes
What are you asking then?
i don't know how to fix it
Fix what?
dont think so lol
the player should control the same camera as the character he is moving
just google photon engine discord or something
And what exactly is happening?
it'll come up
Thanks 🙂
i am moving another character and seeing from another characters prespective
@normal peak just assign the camera to the local players object
can be done in a script on the camera, just find the local players object
done
how do i do that exactly
The above answer works, just have the camera follow the local client with NetworkManager.Singleton.LocalClient.playerObject.transform
How would you go through creating server authoritative resource management for a city builder, just out of curiosity? I currently use two separate gameobjects one is a server object that does simulation and another for visuals
¯_(ツ)_/¯
there's no answer to that question really
it's like asking how would you build a car
here is the original camera code can you show me where to implement using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
public class CameraMovement : NetworkBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
if (!IsOwner) {
return;
}
float MouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float MouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= MouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * MouseX);
}
}
I think there is a link in the pinned message here
not to us i think
well, its a link to the join page from the photon dashboard
ah
Hello friends I have a multiplayer game with a dedicated server build and I'd like the server to be able to handle certain inputs. Specifically, I have a desktop thats running a simulation, and the phones are using that simulation data to display stuff on screen. I want the desktop to be able to pause the simulation with an input (doesn't matter what the input is, can be a button on screen, can be a keyboard press) but can't figure out how to do that with a dedicated server build. Is this possible?
As far as I know, you can't do that with a dedicated server build. They don't have graphics, audio, or user input. You could do this with a host build. Or just have another client on the desktop connecting to the dedicated Server and have it send a serverRPC.
hi there, looking for assistance setting up fusion. im following the documentation but it feels like alot is missing.
https://doc.photonengine.com/fusion/current/fusion-100/fusion-102
with network for game objects, what's the best way to sync up UI elements? im making a game lobby and have the logic in place for players readying up using a ServerRpc. i tried creating a function that sets the buttons visuals based on ready status, and then calling that in a ClientRpc which is called at the end of the ServerRpc but it doesnt appear to be doing anything. sometimes i get it to work on the host but not the clients
the dictionary i was checking to configure the objects only had values on the server, not the clients. all good now 😄
I wanted to add multiplayer to my project, but I'm not sure what service I should use. Looking at netcode, photon, and mirror currently. Any suggestions? (Feel free to ping)
-4 Players
-P2P Only
-Unity 2021
does anyone know what Dani used for Crab Game? Photon?https://store.steampowered.com/app/1782210/Crab_Game/
Crab Game is a First-Person Multiplayer game where you fight for the ultimate cash price in different minigames based on children's games, until only one player is left to claim it all. Definitely not based on any online streaming pop culture korean tv shows, as that would get me in legal trouble, so we're certainly not doing that.Features Up to...
here is the original camera code can you show me where to implement using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
public class CameraMovement : NetworkBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
if (!IsOwner) {
return;
}
float MouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float MouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= MouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * MouseX);
}
}
IIRC its build manually on top of standard C# TCP sockets
How I can sync coroutines to client?
You can use a clientRPC to start a Coroutine
Thanks
Is this the only way to do mp for free? I heard that it costs money to have more users in a server for photon and netcode for game objects is pretty barebones right now
Epic Online Services has a free to use relay service as does Steam P2P.
and would I be using photon in the scenario?
As far as I know, you can use any network framework with them. Unity Netcode and Mirror both have custom Transports. I'm not sure about Photon
what's mirror?
is it any good? haven't heard about it before. Is there a reason it's never mentioned?
It's fine. It's been around forever. It's listed in the pinned message here
Its mentioned a ton.
Its basically a rewrite of unity's old networking.
Its pretty good and easy to learn but hard/impossible to add advanced/cutting-edge features to. Such as network reconciliation, prediction, massive simulation etc...
A more basic approach that is more open to expansion is Forge or FishNet I guess. Did not use them just from talking with devs and looking at docs.
impossible to write prediction? sounds pretty bad then idk
No, just hard, you will have to manually implement it 🤷♂️
I am making a 2 player card game but I cant comprehend how to make it online. Its going to be on mobile which I have figured out. but cant figure out how to assign host to player 1 and client to player 2. the board is shared and both people can manipulate it. both players draw from the same deck.
Well you need to host on player 1 and join player 1 with player 2
But I would advocate against this solution tbh
Here is what I would do, have a server which handles everything and create some sort of lobby system. Use the players just as clients after that, like you would do normal web dev, yk the browser is just running the html part and all the db stuff and so on is handled on a server
Reason for what I'm recommending: costs
You need some kind of possibility for your players to play, expecting them to open ports is not an option. Relay, unity's own system for handeling p2p stuff, will be costly I think, don't know the exact prices, but I'd be amazed if it would be cheaper than just renting a linux server and doing it on your own
I dont know the depth of either option but this is soley so me and wifey can play sequence and phase 10 without actual cards lol. I thought this would be easier to implement than keeping the childern from losing the cards in between the times we wanted to play. no, google play store does not have either game in play store with real online. just fake ai pretending to be real people
Im fine with setting up my pc as the server but idk long term having to turn it on and run the server before getting on my phone to play the game? that doesnt actually sound too annoying I guess
Oh I see, that makes stuff a bit simpler
Depending if you need to play from work or just playing at home a casual game it could be as easy as just having a raspberrypi sitting around somewhere in your house just managing your game state, since you don't really need a complex lobby system
Here is what I'd recommend, for private purposes, since it only needs to work and not be the besr:
-program an api to handle the game state, player hand and so on
-Grab an old phone or a rpi and put your own programmed api on it
-in unity just handle everything with http requests to sync it
I have a pi thats not being used. but Im fine running an ubuntu mirror vm or just setting it up on my windows pc.
I dont want to ask you for help but can you just give me some things to google to make this happen?
It's a super simple system
You could do p2p as well, but I don't know how that works on phones, you would need to have some kind of input field for the ip and port and you need to implement some sort of game saving, it has its pros and cons. I'd go for a client server architecture, but that's because I'm used to it
If you want p2p read the docs of your transport and networking system for this
If you want to go the client server way:
-Just google how to make an api with python or whatever language you are comfortable with, python is just super portable
-learn how to integrate a db into this (sqlite works great for such small systems)
-checkout how to do http requests in unity to sync your game
I've always used flask for my small projects, it is super simple to setup
Don't worry I'm happy to help
..... I actually know how to work with api with python on presetup api from other websites already and deal with sql on a daily. so really I need to just look into how to setup server client. I use django as my home automation server
is it a competitive or co-op card game?
I guess im just missing a piece of the puzzle to make any of this makes sence lol.
or like friendly competitive
@graceful zephyr competitve
if it's a serious competitive card game you need a dedicated server and standalone simulation and all kinds of shit
to make it feasible to deploy
a competitive card game, as in a proper achitectue for it, is quite hard to make
@graceful zephyr basicly connect 4/ bingo but with 2 decks of playing cards
for a non-comeptitive game... just make it deterministic
okey so when i say competitive card game
i mean like hearthstone lol
That's great, so it should be straight forward if you are allready used to that workflow
Here are the docs for unity http requests
https://docs.unity3d.com/Manual/UnityWebRequest.html
What exactly are you missing?
oh haha no no. more like comlex uno
just make it deterministic then
super easy to network and implement for a simple card game
As far as I have understood it, it is just he and his wife want to play cards without cards, which removes all the really complex parts
and can run on basically any type of networking
p2p, client-server, relay, etc.
w/e u want
That's why I just recommended the client server architecture, because it is the easiest to get into, in my experience and you could do it fairly complex if you are willing to put in the time for writing a good backend, it isolates the network part from the game part
Im looking into server way, seems simpler and If I was to expand this would be the way for that too
but im not creating a new game, just stealing whats already existing just dumbly
Good luck and have fun playing with your wife
Any recommendations on places to learn netcode? YouTube?
Im in the same boat. I have went down a giant rabbit hole and it really seems like there is no standard practice. every video they set up everything completely different. @plucky ravine
If you mean Unity Netcode for GameObjects, then CodeMonkey has some of the most comprehensive video series out there.
so if I go photon route I have to pay in the end right?
like I won't be able to let players atleast host local games and invite people to those?
Not sure what to do at this point
And if someone wants to switch transports here is a good tutorial for the steam/facepunch one
https://youtu.be/9CYsQ2Rsr2c
I have commenred this under the code monkey video as well, he wants to do tutorials for this too
The docs and to an extend chatgpt. The last one won't give you good code (because there are too many netcode versions and it gets confused) but you can talk about what you are trying to achieve, what problems you encounter and it gives you some informations or ideas you didn't have. So the chatgpt route is more when you allready set it up and are a couple hundred lines into development
Hey, I'm testing out Netcode for gameobjects with a host/client setup.
Once the client connects, I'm having the host instantiate a bunch of units (and "Spawn" them on network). It's working fine but on the client end, all the animations and skills etc. are not showing up, the only thing that's syncing is the Transform pos and rot
I already added all prefabs to netwrok prefab list, and network animtaors to all prefabs with animators
Any pointers as to why this might b happening? Thx!
nvm ^ figured this out should've read the docs
need to reference NetworkAnimator for setting triggers
You can use any other network framework. There are links in the pinned message for few of them. Servers and bandwidth are not free so someone has to pay for things at some point. Steam and Epic both have relay services that they subsidize.
But what about listen servers? The client plays as a server
You will still need a Relay Server to connect the other clients to the player Hosts. You can ask your players to set up port forwarding I suppose.
Hmm ic
three ways:
- Relay
- Nat-Punch
- Manually Open Ports
usually all 3 are used/possible
Hi, if let's say in a couple of years photon goes out of service. Is there a way to recover my games and be able to play them if they're only online?
other than backing up the source code of course.
Alright thanks
You usually need all 3, or at least the first two, for any live game @brisk bluff
Lately it's been more and more popular to only use Relay connections to protect privacy of each player
What service would I be using in that scenario though? Does it matter? Am I creating my own?
the issue with NAT punching is that you actually connect the players together, which can be a security risk (both in terms of hacking but also in terms of people getting doxed/found irl)
@brisk bluff We provide cross-engine/platform compatible relay (Photon)
Unity, Steam, and Epic all have relay services available as well.
How does netcode for gameobjects handle receiving RPCs out of order? Does it use timestamps? Does anything go on behind the Scenes to fix the timeline?
By default, RPCs are sent reliably. So on the same GameObject, they are guaranteed to be in order.
i was following along with a tutorial that had the players spawn via this line of code in a ConnectionApprovalCallback
connectionApprovalResponse.CreatePlayerObject = true;
id like them to spawn a little later though when the game actually starts and not in the lobby. what's an easy way to go about doing that?
Netcode for GameObjects' high level components, the RPC system, object spawning, and NetworkVariables all rely on there being at least two Netcode components added to a GameObject:
public class ConstructableElement : NetworkBehaviour
{
//...
}
public class WorldTiles : NetworkBehaviour
{
private readonly SyncDictionary<(int, int), ConstructableElement> roomMatrix = new SyncDictionary<(int, int), ConstructableElement>();
//...
}
public static class CustomReadWriteFunctions
{
public static void WriteTuple2Int(this NetworkWriter writer, (int, int) value)
{
writer.WriteInt(value.Item1);
writer.WriteInt(value.Item2);
}
public static (int, int) ReadTuple2Int(this NetworkReader reader)
{
return (reader.ReadInt(), reader.ReadInt());
}
}
I'm working with the Mirror Library: Whenever I introduce a NEW client, that client receives all of the roomMatrix SyncDictionary ... however, all Values (type ConstructableElement ) are null. The Keys of type (int, int) synchronized correctly.
Any idea what's going on? Do I need a custom read/write for the ConstructableElement, even though it inherits NetworkBehaviour?
I don't use mirror, but normally you can't just send a class like that over the network. You should be able to make it a network variable struct of some kind.
public class spawnRes : MonoBehaviourPunCallbacks
{
if (PhotonNetwork.LocalPlayer.ActorNumber == 1)
{
GameObject sco = PhotonNetwork.Instantiate(Score.name,new Vector3(0f,0f,0f),Quaternion.identity);
GameObject go = PhotonNetwork.Instantiate(Dice.name,new Vector3(0f,650f,0f),Quaternion.identity);
sco.transform.SetParent(Canvas.transform, false);
go.transform.SetParent(Canvas.transform, false);
}
else
{
GameObject sco = PhotonNetwork.Instantiate(Score.name,new Vector3(100f,0f,0f),Quaternion.identity);
GameObject go = PhotonNetwork.Instantiate(Dice.name,new Vector3(0f,650f,0f),Quaternion.identity);
sco.transform.SetParent(Canvas.transform, false);
go.transform.SetParent(Canvas.transform, false);
}
}```
when two players are joining. they can only see their own instantiated objects
and cant see each others
what is the problem?
i have added a photon view component along with a photon transform view component to the prefabs of the instantiated objects
is there a way to connect two projects together like two clients? i am in this scenario because i am trying to run a server on my android version and join on my pc version (both are different projects)
I am using mirror.
I may be wrong but I'm pretty sure Android version of Mirror doesn't support running servers -- or does it?
i never got any errors
about that
i will try doing it the other way around
how can i change the camera code to only control the local players camera
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
public class CameraController : NetworkBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
float MouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float MouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= MouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * MouseX);
}
}
On the first line of update:
if(!isLocalPlayer)return;
thanks
Really struggling with this one. (Using mirror) I've got an outdoors scene and a workshop scene. Every player can access the workshop scene on their own computer with a freeflight camera. It is completely not networked, so every workshop scene is stored only on a player's computer, and the player can switch between the networked outdoors scene, and the local workshop scene at will. The clients are no problem, I'm using scene based interest management, so I unload the outdoors scene and load in the workshop scene, and the network manager handles the rest. The host is the problem. I can't unload the outdoors scene, because then clients in the outdoors scene will just be left in an empty void while the host is in the workshop scene. I can't just additively load the new scene either, because then the players and objects from the outdoors appears in the workshop scene. What should I start looking for to handle this?
The name 'isLocalPlayer' does not exist in the current context
Does anyone happen to know of some good refrence material for using the newer input system with ngo?
https://docs.unity3d.com/Manual/class-NetworkBehaviour.html
Odd. Not sure why that is? I've been using mirror but afaik it uses the same stuff as builtin networking
Split the scenes in the world - separate them using different physics scenes and separate them on the Y axis
And then disable the server side render on the scene the server isn’t in
Alright, thank you. Was looking into physics scenes, but aam still doing research
I am trying to get a first-person game started, but I run into an issue when running into netcode for gameobjects.
Whenever I start in the editor as a host, the game runs fine, but when I open the game in a new editor and connect as a client, the game that was connected as host switches to a new camera, and I can look around with that camera, while the other "player" moves
I should be looking with the one on top of the ground, but the camera switches to the player prefab that is in the ground
I suspect that this is a problem with the fact that both prefabs have a camera child, but how can I make it so that I only see out of the original player prefab?
This is what the game looks like when only the host is active
I can walk around through the player in circled in red, but I only look around through the player in blue, I circled the prefabs in the hierarchy according to their colors too. The client at the bottom-right is functioning as intended.
Why is this happening?
I can't hear people in my game while using photon vr can someone help me?
You'll need to disable the camera on any remote players. You'll also need to make sure your input is only applied to the local player
@bronze eagle Please remove all the messages you've cross-posted in all other channels
ok
Is it better to have many small parallel connections to one client transmitting relatively small structures or rather one connection which transmits one huge structure? I know that in case of large number of cennctions i can starve all sockets in pool
You are going to have to use the network profiler to test and measure that
a connection is an abstract concept and is implemented by the protocol you use, conceptually you want just one, the thought should be put into which protocol you use, not how many connections with a given protocol you may use.
And what about serialization/deserialization of packets? Im not sure if its worth to put in another thread, but in this case i would need put it in some thread safe data structure like thread safe dict or queue based on mutex
your limitation will not be CPU spent on serialization/deserialization, if at all it will be memory pressure (due to garbage, if any) or the handling of the messages. you can push all serialization onto a separate thread but there is generally no need to parallelise it, in fact that may be detrimental to how many servers you can run in parallel on one machine
i mean, i want to make it asynchronous to avoid i/o waits. I guess it would be better to use some stackless coroutines than plain threads
as i said, put it onto another thread if that is a concern
but dont parallelise it
oh got it
but wait a sec i have no innfluence on cpu affinity
how to be sure that cpu wont parallelise it by itself?
depending on the project/use-case its a good idea to keep servers single threaded and rather have many of them (horizontal scaling) vs parallelizing one server and having it scale vertically
a CPU cant magically parallelize single threaded code, it doesn't matter what core it runs on
yeah, but you said to put it to another thread to avoid i/o waits
both from network and disk(or memory pages)
yes, so if you want to have some more control, make it all single threaded
and have the OS deal with the allocation of cores to processes
whether it won't affect responsiveness for multiple clients at the same time? Coz of rare context switches
there is no context switching if you have single threaded servers run on their dedicated cores
the only contention is over the IO resources
which is something you have to test and see
okey got it , so it would be these best to run it in single thread but in coroutines
you can use threads, just not ones implemented to run in parallel
okey so it should run on one single core of cpu. Thanks for help
if you want to scale horizontally, yes
hmm yeah, i think it would be the best option but, im kinda scared about pid starvation
also if i want to conteneraize it there is additional overhead from container runtime
you can hibernate instances and reuse them
but i would need supervisor in this case
should be minimal
the cost of a hypervisor / containers is well worth it over the hassle of setting that stuff up on bare metal
How do I disable the camera is the question? I am learning networking so I don’t really know how to do all of that. Is there any code example or something like documentation or a video you could link me to?
void OnNetworkStart() {
if (!isLocalPlayer)
camera.enabled = false;
}
@austere yacht you mean to scale it vertically by adding more resources (ram, disks)? Horizontally scalling requires also some loadbalancer that also adds additional overhead
If you are puttin everything on one machine then everything communicates in same process memory space sometimes by ipc
the load balancer will only be in the loop while establishing the connection, it is irrelevant for actual runtime performance, this isn't a website
oh got it ,after receiving "connection id" it will always route to specific server
yes, and realtime game networking is nothing like HTTP networking
its a dynamic bi-directional data stream
btw can i ask can you recommend me some good resoucres to learn about game server architectures?(server-clinet ,p2p, event based, poll based etc)
when I search on google I only get crap articles from the medium
there is a github with some links to resources, it contains the seminal ones https://github.com/vis2k/Game-Networking-Resources
realtime game networking is very obscure, there are no "how to" guides
its all based on you understanding the fundamental principles and being smart/creative yourself
and hardly anyone is "smart" or "knowledgeable" enough to handle it all on their own
But I guess there must be some foundation like the basics of server architecture or examples of binary protocols
depends on what you mean by architecture
Packet serialization/deserialziation, handling connection, retrying policy, etc
you can glean a lot from looking at how NGO/Mirror or even an Unreal Actor are implemented
thats protocol level stuff, you can read some papers about that, maybe look at the reference implementation of KCP for example
or another great resource is everything about ZeroMQ