#archived-networking
1 messages ¡ Page 9 of 1
Totally misread that, but yea it can call a clientRPC as well. Should get broadcast out like normal
Uh - must a Client or Server Rpc be on a Network object? https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/message-system/clientrpc/index.html doesn't mention it /except/ as it applies to hosts calling ClientRPCs on network objects.
Servers can invoke a ClientRpc to execute on all clients.
Yep, it does. It can be called from where ever though
so the method itself must be on a network object. Good to know đ
Anyone run into a situation where a ServerRpc call will sometimes simply not be received by the server? The same function works 99.9% of the time but as I detail in this forum post I sometimes get to a point in the game where that same call, even though I verify it's initiated on the client, is never received by the server.
https://forum.unity.com/threads/some-serverrpc-calls-not-working.1393840/
RPCs are sent reliably by default. So in theory that should not be happening
Any idea how to troubleshoot this? It's a blocker for sure. I've verified via log statements and breakpoints in the debugger that the client is attempting the ServerRpc call and the server is not getting it. This is obviously a case where I'm debugging on the host machine and the host player is encountering the issue. But I've gotten this behavior with the client sometimes as well.
Does it stop sending ServerRPCs all together? Or does resending it work?
No. I can try a different play and it will work. And another player can drop to the same spot. But it continually rejects that particular call from that player (note that this is the same ServerRpc function used for every card thatâs dropped).
The Network Profiler might help you track down where the call is failing. I'm pretty sure you can drill down to individual messages
Good morning!
Back to it then!
So, I made a few changed to how my customizer works. As the player is done customizing, an array of indexes is created, indicating which index each part character is using (Got a list of every modular piece in a list)
I can use this array to loop through this index list and activate each index accordingly.
How could I go about updating everyone when a player does this change?
Making it a networklist would probably be easiest. You can use the on change event to update the player whenever a change is seen and late clients will always get the most up to date list
Oh yea, Network list was a thing, I'll make sure to do that
Currently working on the whole ClientRpc and ServerRpc, will do that list later on
Okay, my initial assumption was false. The ServerRpc function is getting called. I thought it wasn't because apparently, when debugging, I don't see log messages from the server function nor do I hit breakpoints inside them (and I can't step into them). This makes debugging server issues tricky.
By passing more detailed log messages back to the client I've determined that the server is rejecting the drop in some cases. I must have an issue in my IsLegalDrop() logic I need to fix. Time for some unit tests I think.
is it wrong to leave all multiplayer components (networkbehaviours, etc) on the player prefab when they enter singleplayer? Will there be any conflicts or can I keep using the netcode components without any issues because the player is not a host nor a client when in singleplayer?
Because I don't think having both a multiplayer and singleplayer version of all of the player's prefabs is a good idea...
Usually for single player, you'll just start the player as host and leave everything else the same
o really?
does that require an internet connection though?
I'd like to hear people's opinions on that approach
no, connecting to 127.0.0.1 never hits the network
right. What about making sure no clients connect? Just add a client limit of 1 and that's all?
technically no one else can connect to 127.0.0.1
sure, but what if the steam transporter is used?
I've never used the steam transport but that shouldn't matter
Hello brothers,
can i stream and receive Renderer.material of objects in OnPhotonSerializeView?
and if i can how, what is the code i should put
for example any game object state
can be streamed with ---> stream.SendNext(GameObject.activeSelf);
And readed by --> GameObject.SetActive((bool)stream.ReceiveNext());
or how can i sync colors without OnPhotonSerializeView
if there is not a way with it
im trying to make when i press a button player tshirt color change
and i want to sync new color for all clients (for the player who press the button not all players t shirt get changed i ment only 1 player)
you wouldn't stream the material itself
just send either:
- an int that you map to the color somewhere
- the color itself
its a texture
Then have your code set the material as needed
is it like... something a player is uploading into the game?
Because if not you can just reference it with some kind of small ID
you don't want to be sending large amounts of data unnecessarily over the network
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class RandomMaterialScript : MonoBehaviour//, IPunObservable
{
public Material[] randomMaterials;
public PhotonView view;
// Start is called before the first frame update
void Start()
{
view = GetComponent<PhotonView>();
if (view.IsMine)
{
int TheRandomMetNumber = Random.Range(0, randomMaterials.Length);
Material TheRandomMet = randomMaterials[TheRandomMetNumber];
view.RPC("RPC_SendShirtColorToClient", RpcTarget.AllBuffered, TheRandomMet);
}
}
[PunRPC]
void RPC_SendShirtColorToClient(Material randomMaterial)
{
gameObject.GetComponent<Renderer>().material = randomMaterial;
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.IsWriting)
{
;
}
else if (stream.IsReading)
{
}
}
// Update is called once per frame
void Update()
{
}
}
This is my code now
Yeah don't do this
don't try to send the whole material
just send an identifier of some kind that your game knows how to find the material in its own files
you could use Resources.Load for example, and just send the string of the file over the network
or map all your materials to an int id, or an enum
Even better since you have this:
public Material[] randomMaterials; you can just send an int
i will put it in Resources folder
and every client will know to just grab randomMaterials[thatNumber]
Hello. I have build photon fusion's project. Want it to open 2 times, but when I click build.exe, it does not open in new window, I only get one game playing. How can I solve this?
I always have a build one and the editor one connecting to each other, but that's not in photon. You might try that, also don't know if this is the best solution.
Thank you very much)
anyone know why im getting this error?
i registered my project as android too so idk why im getting an error abt iOS
You probably need to remove those firebase dlls if you aren't using iOS at all
okay thanks
use code blocks instead of this, makes it a lot easier to read
What are some ways to pass data to the server on game start? I'm building a 1v1 card game where both users would have their own decks, player info, et cetera. Matchmaker's TicketOptions seems decent, but I'm not sure if its suitable to cram everything in there.
Is it normal to handle something like this in OnNetworkSpawn?
Both of those will work fine. Ticket Options would also be good if you want to match based on deck composition.
I'm using Connection Approval and dumping everything into a PlayerData Json blob. Sending it in a RPC on network spawn is perfectly valid too.
good to know, just wanted to make sure i wasnât barking up the wrong tree đđź
is there an order of execution for OnNetworkSpawn events? iâd ideally like loading the data to happen before anything else
Also, separate q - how would you handle bsending different data to different clients? For example, when a playerâs turn start, i want to send that player the info of what card theyâre drawing - whereas the other client should only know that the player has drawn a card.
I think this is what you are looking for: https://docs-multiplayer.unity3d.com/netcode/current/basics/networkbehavior#networkbehaviour-pre-spawn-synchronization
Both the NetworkObject and NetworkBehaviour components require the use of specialized structures in order to be serialized and used with RPCs and NetworkVariables:
This would be a case for ClientRPCs.
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/message-system/clientrpc#to-send-to-one-client-use-clientrpcsendparameters
Servers can invoke a ClientRpc to execute on all clients.
ahhh perfect
these are both exactly what i was looking for!
is this a unity GS thing or am i going smthing wrong
my server dissapear if i dont use it for a day
That is the list of currently allocated and running servers. Servers in that list are charging you for use.
but when the servers het deallocated i cant start a new one without allocating them manually.
when i try to start a game it doesnt start the server or could be the timeout time to short for fresh allocation
With matchmaking it's probably timing out before the new server starts
240sec and i get the error of max server capacity
can someone help me setup a simple rigid body box with netcode for Gameobjects? applying Network object, network transform, rigidbody and network rigidbody doesnt make the box movable on both host and client...
By default, it would be only movable from the host. As long as the clients also have a collider on them, they should be able to bump the cube around
wierd, in my project the box is only bumpable on the hosts side...
the client also has a collider tho
this is how my player is set up
this is what my box looks like right now (ignore the position)
try changing the cube collider to a box collider
oh that is something i forgot to mention
i need to call on collision enter on the box, in another script and that doesnt seem to work with the box collider
i sthere anything else that seems wrong with what i am doing?
i am new to netcode :/
try the collision with the box collider just to test. mesh colliders get weird sometimes
or try capsule collider on the player
ok trying it rn
does not seem to help
created a separate box in another scene, to make sure its nothing else, but its still unpushable on client side
hey, is there a way to do network discovery with NGO? I'm trying to find all local IP addresses in a LAN that are running the game
ik UNet had this functional, and that NGO probably doesn't since it's newer, but is there a way I could do this myself?
I don't know if this still works or not but it should give you a start at least
https://github.com/Unity-Technologies/multiplayer-community-contributions/tree/main/com.community.netcode.extensions/Runtime/NetworkDiscovery
oh sick this is perfect, thank you
anyone familiar with playfab what do i need to do here
What it says https://learn.microsoft.com/en-us/gaming/playfab/gamemanager/api-feature-settings-in-the-playfab-game-manager
thanks i found it
Up until now I've just been stuffing data into JSONs, but it feels natural to move away from this for an online, competitive game. What are you guys using for database stores? Do you rely on JSONs or a cloud SQL provider like AWS?
I've also been using SO assets, but a lot of this data won't be needed at all by the client. For example, for building a card game, the client doesn't need assets for every card in the game; the server can just tell it what has been played, and what effect on the game it's had.
I'm just using a SO with a list of CardData for my card pool and I'm just send indexes around. For storing persistent player data, my plan is to use Cloud Save for that.
Ah, so no references to cards anywhere, just passing indexes - even for things like a playerâs deck/collection? just indexes?
iâve done something very similar in the past, but had an issue with passing additional data - ie quantity of that card in the deck. i ended up having have a card pool SO, and then a separate card store SO which could resemble a deck/collection, which had a reference to the card and a quantity field
yea. right now decks and hands are just a list of ints
what do you do for quantity? multiple of the same index?
and is this stored on the client side? how do you prevent malicious clients from adding cards to their collection/deck that they shouldnât have?
yea. it was too much trouble otherwise
thatâs my main worry, figuring out how to store this without exposing anything to the client
So I've got a system where players can spawn their individual avatars from Ready Player Me at runtime. This loads the glb from there and parses it into a nice game object.
Struggling with how to sync/spawn that new prefab across other clients since that object isn't in anyone else's network prefabs list.
greetins
ok so basically
is it a bad idea to have a networkvariable only be around for a single frame?
i notice that when i have it so clients have a variable up for a single frame that it sometimes doesn't register server-side
out of curiousity, why do you need this?
yes, use a RPC, which captures more accurately the intent of what you are likely doing with the var
i use a serverrpc to change it
and a serverrpc to turn it off :)
A buffer has a fixed size, it wouldnât be a buffer if it could grow. The expected usage pattern of a buffer is to fill it temporarily with data to either aggregate it over time or to process a large stream in increments
Im using matchmaker and I have rules. Players have skill value, and teams should be balanced in reference to that skill. How can i retrieve information about player's team?
individual units of transmitted data in netcode should be of a fixed/statically known size to minimize allocations and memory pressure caused by variable size structures, the way to handle large/variable data amounts is through the use of buffers as described above. If there is a reason to size buffers dynamically the architecture would probably benefit from a revision
idk this depends on many details. when using a framework that already aggregates messages per tick, youâd just send inventory changes individually and design it in a way that only minimal info about the items needs to be exchanged, potentially in multiple messages or by representing all items by the same fixed size structure (but that depends on context)
heya!
considering that my game is run entirely server side
what are the top reasons for why a client could be running slower than the actual server
Hey guys, I am trying to create a multiplayer with a single dedicated server. However, I was thinking about creating multiple rooms inside the server.. Is it possible to achieve this using a single server? My game will consist of multiple room maps and I want them to be independent of each other (Like different virtual worlds).
Also, I was thinking about using NodeJS server which will store a list of rooms and will work as a room query system is this a good idea?
the game has like 20fps client side but 60fps server-side
Matchmaking rules
The Profiler will show you exactly what's going on
where dat
nvm found it
Is it also possible to implement a Room system from scratch without using Relay (only using a dedicated server)?
Hey all, has anyone here worked with photon fusion for networking? Or knows a good video on it?
i havenât, but itâs one of (if not the most) popular networking solution for unity. there should be tons of material or youtube & their docs
https://doc.photonengine.com/fusion/current/getting-started/fusion-intro#
Global cross platform multiplayer game backend as a service (SaaS, Cloud) for synchronous and asynchronous games and applications. SDKs are available for android, iOS, .NET., Mac OS, Unity 3D, Windows, Unreal Engine, HTML5 and others.
You can use the Lobby system with Dedicated Servers to make room list. Using Matchmaker might make more sense though.
Anyone know how to code with networking for games
You can get started here
https://docs-multiplayer.unity3d.com/netcode/current/tutorials/get-started-ngo
Use this guide to learn how to create your first NGO project. It walks you through creating a simple Hello World project that implements the basic features of Netcode for GameObjects (NGO).
i like to ask some here to try the unity 3d webgl multiplayer sample with webrtc/udp , where to put the itch is a test game channel link to hop in ? have put in work in progress if you want to join to test multplayer now https://discord.com/channels/489222168727519232/502171560359100437
I'm not sure what kind of meaningful answer you would be expecting from this question đ
I've got some weird jittering going on with my camera, im using cinemachine and photon fusion with the networkcharactercontroller. I know its something related to what time the camera updates, but after switching to manual update and updating in the network's fixed update, it still doesn't get rid of all of the jitter. it even shows a bit of rubber-banding. any ideas?
morning, some question about using remote config, i cant find prices, but i think this is not a free tool from unity, maybe is about the size used by my players ?
Have you created a dedicated server build?
Oh wait
Are you about to ask us how to run a Rust server?
Well then yes, make a server build of your game and run that
It's one of the options in build settings if you installed the module
Linux/Mac/Windows Dedicated Server Build
Then you'll be able to find the option in build settings when you build your game
Well yes, and you do not have the module
hey how can i check if a network object was spawned in the scene?
For anyone who uses netcode for game objects, does anyone know the function that calls on the host whenever a client connects
The main component of the library
ty
For anyone who knows mirror, I'm having a slight problem where my first player(who hosts) can interact with objects physically just fine but my second player has alot of difficulty.
ello
so
i have a networkobject on the server
with a networktransform
and on hosts it works just fine
but on clients it ungulates in ridiculous ways
even clipping through walls
Is there a proper way to transfer ownership of network game object from client to host and in opposite ? For some reason with this code I am getting, Client wrote to NetworkVariable ... without permission, Why I am getting this error, (I am trying to transfer ownership via Server rpc) ?
at the moment that I am starting a host or joining as a client, were can I fetch the data of the current loading/connection?
so I can make a loading bar
for exmaple
or display a message while its connectig
Hello, I have a client authoritative gameobject. When the object moves and collide a wall, I play a sound. My problem is that the sound is only played by the owner, other clients don't play the sound because OnCollisionEnter is called only on the owner side. So to play the sound on all clients, I would like to call an Rpc to tell to other clients to play sound but "ClientRpc" cannot be call from a client. What is the correct way to handle this use case ?
Currently the only way I can see is, call a servrpc, then the server calls a clientrpc. Seems to be very complicated for this use case.
within a Host, when I call a ClientRPC (which will also run on the server), can I be sure that the host version of that RPC executes before continuing to the next instruction? ie is
MyServerRPC() { SomeClientRPC(); if(SomeValueSetInClientRPCcall == X) DoSomething(); } reliable?
ManzellBeezy, I'm new at NetCode so I'm not sure, but from what I observed, RPC calls are synchronous (contrary to NetworkVariable synchronization which seems to be asynchronous).
synchronous meaning, it waits for code completion before moving forward?
yes this is what I have observed
@versed lily from the doc I just read:
An RPC function typically doesn't execute its body immediately since the function call is a stand-in for a network transmission. Since the host is both a client and a server, local RPCs targeting the host-server or host-client are invoked immediately. As such, avoid nesting RPCs when running in host mode as a ServerRpc method that invokes a ClientRpc method that invokes the same ServerRpc method (and repeat...) can cause a stack overflow.
So it is synchronous only when "local"
Got it. Avoiding nesting RPCs is proving to be a little bit of a challenge but I think that means I need to refactor anyhow.
Thanks.
why do network rigidbodies desynchronize?
i set the rigidbody2d.velocity of a server networkobject, and it just lags about on the client, whereas on the host it works just fine
Question, with Unity Authentication if you choose to give the player an anonymous login does it give that player the same login every time?
Nvm looks like it does, I figured it would. Just wanted to ask.
!!SolgaleoEnjoyer, I think me and you have the same problem. I'm using mirror, and I have this ball object which has a transform on it. My host can interact with the ball's pyshics just fine to knock it around, but my client can barely move the ball and the ball just behaves weirdly with it, almost like their physics won't interact together or something
How can i spawn 2 different player prefab using netcode any idea ?
There can only be one player object (that represents the server connection), but you can have a player own multiple objects and that ownership + regular spawning of a prefab would be how
If you mean like players choosing different characters, then you can spawn them after the player connects with SpawnAsPlayerObject(). Dapper Dino recently did a video on character selection
This Unity Multiplayer tutorial will teach you how to create a character selection menu using Unity's Netcode For GameObjects in 2023. For project files access, check out the repository here: https://github.com/DapperDino/Multiplayer-Character-Select
------------------------------------------------------------------------------------------------...
can you send arrays via RPCs?
Arrays of C# primitive types, like int], and [Unity primitive types, such as Vector3, are serialized by built-in serialization code. Otherwise, any array of types that aren't handled by the built-in serialization code, such as string], needs to be handled through a container class or structure that implements the [INetworkSerializable interface.
Guys is it okay to send an rpc and then send an rpc?
Im trying to send data to a client from host when they connect, but the on connect function runs on client. So I was thinking that I can send an rpc to the host, which will then send an rpc back with the data
Yea. that's the way you kinda have to do it. You'll get an error if you try from the host onConnect first. Just make sure to set the client list on the ClientRPC so its not broadcasting
Ok thanks a lot dawg
`private void OnConnectedToServer()
{
SayHelloServerRpc();
}
[ServerRpc]
public void SayHelloServerRpc()
{
Debug.Log("Hi Server");
}`
Does anyone know what I did wrong? I'm not seeing any debug on the host
Make sure its actually getting called on the client. You should be subscribing to OnClientConnectedCallback
sorry for being a dumbass but how would I subscribe to OnClientConnectedCallback? I'm kind of new with events and stuff
wait nvm
I think I figured it out
actually yeah I could use some advice
NetworkManager.OnClientConnectedCallback +=
Do I put the function I want to use on the right side?
NetworkManager.Singleton.OnClientConnectedCallback += OnConnectedToServer;
private void OnConnectedToServer(ulong clientId) {}
Yeah I got it working, I needed to subscribe and do the client Id
tysm for the help though
Actually, this is a better place to ask this problem. Very fundamentally, been trying to use ParrelSync and Mirror, and it outright throws errors based on object hashes not matching. I'm working on a game with a lowish player count, high object count, and wondering what workflow I can and should use. Right now its Mirror + ParrelSync, but they don't play nice. (Mirror also hates disabled objects to boot)
Is there something else I should be using to do this?
Nope. Disabled objects in netcode are considered destroyed as far as the netcode framework is concerned, that isnât specific to mirror.
That helps to know. Outside of that specific item... is there something you'd suggest I pivot to? I'm looking at a low player count, high object multiplayer game... so I was using Mirror for now. What I'm running into is that ParrelSync and Mirror don't sync properly - Mirror thinks the clone directories are 'mismatching'.
Is there a workflow you use?
Is there a way I can sync the game state to a new client when they join the game? Currently when a new client joins mid game, their game state is unchanged from the original game state.
I'm beginning to think I'm just going to have to have two computers at my desk (to test multiplayer)
there is no inherent problem with parrelsync and mirror, it works fine for me and plenty other people, maybe its something else thats causing it.
In Unity Netcode, all Network Transforms and Network Variables are synced to late joining clients
Thanks for that feedback, it is helpful to know you have that workflow working fine!
I'm not sure what could be causing it. I'll probably have to do a complete start-from-scratch build
are you using any other sync tools with the project like dropbox/google drive/etc.?
github. a little bit of resilio, but only on an empty assets folder
I'm not even sure that was added until well after I found the error... hm. I created a multiplayer menu scene in order to start working with Mirror - while I have the HUD starting and connections working, none of the menu objects I created with network behaviors actually work. (they all throw errors when I create them, and none create a synced version on the other side)
So the original is running host (server+client). the clone jumps in as a client only on localhost. this is all with the provided mirror network HUD. the break is during OnServerAddPlayer. I run the base function to generate network player agents for each party (the player prefab). where things break is the custom function to create a networkbehavior prefab object, LobbyPlayerData.
The client tosses a "spawn scene object not found for A92..etc. make sure that client and server use exactly the same project. This only happens if the hierarchy gets out of sync." and never spawns the lobby objects.
Hey yall I am working on making a game i made into a multiplayer game using photon, I have these "pieces" that i do not want to have an "owner" because it makes moving the pieces on the board really annoying. is there a way i can have network transform object that do not have an owner
It could be the client isn't getting the prefab for some reason? I have it in the "RegisteredSpawnablePrefabs" list though
Do I need to use a different function than Instantiate?
NetworkServer.Spawn() after you instantiated the network object on the server
Ah. So I call GameObject.Instantiate(prefab) in the server function (OnServerAddPlayer), then I call NetworkServer.Spawn() on the server side as well?
that seems to be it
hm. but it's not enough...
I still get that error. Though I'm creating the data objects at least
Okay, is there a way I can sync animations too?
There is a network animator that syncs animation states and parameters
Okay cool thanks.
It seems like, for whatever reason, the NetworkManager.Instantiate call is what is causing this error spawn scene object not found for A92EE62..etc..CF. make sure that client and server use exactly the same project. This only happens if the hierarchy gets out of sync.
Could not spawn assetId=0, scene=A92EE62... netId=1
So it seems to be related to the scene, somehow? Or am I misunderstanding?
I'm probably spawning the player before the actual prefab list is loaded
hm. I'm doing it during OnServerAddPlayer... so I'd have to wait for something on the client and request for the rest of the scene... or something?
Please, can you explain can I send RPC calls from ContextBehaviour? And what is difference between it and NetworkBehaviour, where should I use them? Thanks
How do I disable the Syncing Time To Clients message in console?
what is photonview.isMine equivalent in Fusion? How to check if I am the local player?
Change the debug log level in the network manager
Can i get some help with Photon Fusion??
I need to update the Backfill ticket from Matchmaker to be able to join back/during the game. And i have to add and remove players from the ticket.
Now how can i get the UnityPLayerID when im using Fusion. I have a server/client setup. Server script is GameManager and it keeps the ticket updated/Refereshed. Now how can i get the players ID that has joined or left
Using OnServerReady, but it's still giving that error. It syncs, I just have no idea why it's giving that error first...
The issue is definitely with the Instantiate call. I am pulling the prefab from the spawnPrefabs list (on Network Manager) directly. so the prefab has been registered. the call is being done in OnServerReady now, so after the client has loaded the scene
ooor is it. hm. commented out the whole block, still getting the error...
Ah. Additive Scene Loading is still an issue in Mirror?
I removed additive scene loading, and I'm -still- getting that error
but only on the player prefab now
Hey guys, I have a function to launch a projectile
private void LaunchProjectile(double itemDamage, GameObject projectilePrefab, Transform rotationObject, float projectileSpeed, float projectileLifetime) { { GameObject bullet = Instantiate(projectilePrefab, firePoint.position, rotationObject.rotation); bullet.GetComponent<NetworkObject>().Spawn(); Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>(); Projectile projectile = bullet.GetComponent<Projectile>(); projectile.Projectiledamage = itemDamage; projectile.Projectilelifetime = projectileLifetime; rb.AddForce(firePoint.up * projectileSpeed, ForceMode2D.Impulse); } }
This works for host, but when I tried to make a copy of this function for spawning projectiles over a network, I got a strange error
anyone have any idea whats causing it? I'm new to rpcs and stuff so I might be missing something obvious
You can't send gameobjects and transforms over the network like that
Ah okay, ty
I'm having a problem with photon RPCs it keeps giving me this error and here is my script https://hastebin.com/share/yogevexoga.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
there is a size changer in my game, i am using pun 2 and photon voice. im trying to look for a way that i can change the pitch of a users voice for other players to hear?
Make sure the clients that throw the error have the updated code and the component attached to the view 1001
I'm currently having an issue where I want to make a NetworkList<T> where T is a custom struct that contains another custom struct as a field. I am able to create a network list of each struct individually, but when I put one inside the other I get this error:
The type 'PlayingCardData' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NetworkList<T>
Anyone know what might be causing this?
It even happens if my custom struct contains a unity provided struct, such as FixedString64Bytes
I am trying to make a Multiplayer game using NetCode, and currently I am trying to implement other clients viewing a client's hand item.
I tried adding a NetworkObject to the GameObject for the ItemHolder (which is on the player's right hand game object), but I still can't really see the ItemHolder's sprite change on the other client when I change it on the main client.
Any possible way to do this?
One of the fields of PlayCardData is probably a class instead of a value type.
You will need to Spawn the network object then attach it to the player hand
So basically
I have to make a prefab of the object, remove it from the player, and then add it to NetworkPrefabs list, correct?
and of course then I can just make it position on the player's hand
but then that may visual annoyances, no?
it wouldn't rotate the way the player hand's rotating
and it would look as if it's frozen
You can set the parent after it spawns. But I've been using a physics joint instead.
Ah, that is also possible yes
Thank you.
I am trying to solve which network service would allow me to solve this architecture diagram. Basically, I am processing a picture (in AWS Lambdas - I don't need help with that) and I need to send a notification to the clients that the picture is processing, and has processed. I think that PubNub is an option but is there a Unity hosted Multiplayer setup that would be better? I was looking at Remote Config but that seems to be more for the game rather than alerting the players. Any help would be appreciated.
what does that mean?
@wide girder it's grabbing the photon view from this script
using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GetScript : MonoBehaviour
{
public static PhotonView pView;
private void Update()
{
pView = GetComponent<PhotonView>();
}
}
because the photonview is on a prefab
The script that the rpc is called in needs to be on the same GameObject as a PhotoView.
Need what? The rpc?
yes the rpc is called on trigger enter
Then add a photon view to it?
to what?
To the trigger go
Or have a better code structure and call an rpc on the proper object instead.
đĽ Join the multiplayer NGO webinar series! đĽ
Looking to build a small-scale cooperative multiplayer game with Unity?
Then sign up here to join us for this four-part series with our Multiplayer team!
âĄď¸ https://create.unity.com/game-implementation-with-boss-room
Weâll dive into the Boss Room sample to explore building a production-ready multiplayer game with Unity and Netcode for GameObjects.
đ The four webinar sessions will cover the following topics:
[Feb 16th] Episode 1: Game implementation with Boss Room
[Feb 23rd] Episode 2: Production-readiness, exposing your game to the internet
[March 2nd] Episode 3: Making your game resilient to your players
[March 9th] Episode 4: Our game dev processes
đĽ Sign up to the series once and you'll be added to every session, and receive recordings after the series is over.
what happens if my game runs at 30fps but i'm trying to read packets at 60hz?
do the extra packets get dropped by the operating system?
oh i think the extra packets would get read, like if it's 30fps and 60hz then 2 packets get read each frame
Hello, I have a client authoritative gameobject. When the object moves and collides a wall, I play a sound. My problem is that the sound is only played by the owner, other clients don't play the sound because OnCollisionEnter is called only on the owner side. So to play the sound on all clients, I would like to call an Rpc to tell to other clients to play sound but "ClientRpc" cannot be call from a client. What is the correct way to handle this use case ?
Currently the only way I can see is, call a servrpc, then the server calls a clientrpc. Seems to be very complicated for this use case.
@wide girder I am back on are you able to help me now?
Sending a serverRPC is really your only choice. Unless you write your own collision system with raycasts or something
You don't need to wait for me specifically. Research info and possible solutions based on my reply, make some effort, and if you have additional questions ask the community.
I didn't sign up to be a personal assistant.
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
public class PlayerRespawn : NetworkBehaviour
{
//Put this on the playerParent.
public override void OnNetworkSpawn()
{
PlayerSpawnPoints playerSpawnPoints = FindObjectOfType<PlayerSpawnPoints>();
if(playerSpawnPoints == null)
{
Debug.Log("SpawnObject not found");
}
if (IsServer)
{
if(playerSpawnPoints != null)
{
transform.position = playerSpawnPoints.GetRandomSpawnPoint();
Debug.Log("Spawned at a random posistion");
}
}
base.OnNetworkSpawn();
}
}
The playerspawnpoints always returns a null, but there's an object with the script on it in the scene.
Is this a limitation of OnNetworkSpawn() or anything?
- are you sure PlayerSpawnPoints object already exists by the time this is called? 2) Is PlayerSpawnPoints a network object?
checking that now, to make sure
it might be nr1, but I'm not sure on how to fix that.
{
NetworkManager.Singleton.StartHost();
NetworkManager.Singleton.SceneManager.LoadScene(gameplaySceneName, LoadSceneMode.Single);
}```
the scene gets loaded after the hosting bit
Well you could, for example, create an empty gameobject at the spawn point, then in your OnNetworkSpawn initialize a public transform for it, and set the spawnpoint equal to that gameobject's location
That way you'd at least be certain the spawnpoint exists in your scene by the time you're trying to access it
if anyone knows fishnet can i have some help with this error code line also fishnet is thw networking thing
NullReferenceException: Object reference not set to an instance of an object
NetworkHudCanvases.Start () (at Assets/FishNet/Example/Scripts/NetworkHudCanvases.cs:149)
Or you could spawn the PlayerSpawnPoint in OnServerStarted
Glad I could help, hope you get it sorted out
With the info you gave us all I can tell is that at line 149 of the NetworkHudCanvasses script the line of code is trying to access another gameObject or anything and it's returning a null, as in, it can't find it.
Ok thanks I'll try tmr
The player object who requests the spawn is a prefab but the spawns which are going to be used on different maps are not, so I can't use the public transform way as far as I know. That's why I try to get it working with a FindObjectOfType, but even when OnServerStarted it keeps returning a null.
Have you also prefabbed the spawn point object and added it to the network prefabs?
No, because when prefabbed I can't change them anymore. Some maps might have 2 spawn points but bigger maps might need 6 and all on different locations in every map they're used.
Hmm. You can definitely change the properties of prefabbed objects after you spawn them on the server. Like if you spawn a prefabbed PlayerSpawnPoint, you will be able to access it and change its location etc, and spawn more spawns as needed. But perhaps I'm not understanding the architecture of your game properly. In any case that's pretty much all the advice I can offer since I'm pretty much a beginner myself - hopefully you get it working!
Thanks for trying to help me out. I'll see if I can get it working with prefabs.
just poll.
From the docs:
Some collision events aren't fired when using NetworkRigidbody.
On the server all collision and trigger events (such as OnCollisionEnter) will fire as expected and you can access / modify values of the Rigidbody such as velocity.
I think that it is "On the owner" instead of "On the server" right ?
Can you be more specific. What do you mean by just poll.
upload the picture to s3 or whatever and do the call. then the player polls a well-known url with the image. when it returns 200, well, you have the image
With network rigidbody, the server is always the owner
to use Backfill feature. I have the server do the appeal ticket (ApproveBackfillTicketAsync()) does the server need to be signed in to use this. And if i do this does the player need to sed a backfillTicket or use normal CreateTicket function becouse for some reason i cant get it to work
@sharp axle Are you sure ? I have a ClientAuthoritative object and the OnCollisionEnter is called on the Owner (client) side and not on the server side.
the object is created using: SpawnWithOwnership
With a client network transform, it is owner based. With regular network transform it is server based
@sharp axle Yes I have a client network transform
Afaik, clients just connect normally and won't know if it's backfill or not.
I have an object in an area which triggers an "OnTriggerEnter". Then:
- I disable the object (using client rpc)
- I set the object position outside of the trigger area (the position is updated by the owner and synchronized by a client network transform)
- I enable the object (using client rpc).
The problem is that, on some clients, "OnTriggerEnter" is called again because the object position has not been updated before the object enable.
Could you please tell me how to handle this use case ?
Any idea @sharp axle ?
Don't disable the object. Just turn the renderer off
anyone know why im getting this error when trying to remove player from Backfill ticket??
That error is coming from Multiplay not the Matchmaker
Thanks I will try this.
its a fuion thing when calling the RPC without premmision
um one more thing how do i know if my backfillTicket is working
If you get new players after one dropped out. Or start a half empty match I suppose. The backfill should keep adding players until full
ello good humans (or robots)
i am having a hard time syncing a fast-paced object over the network. When I select the interpolate setting, it results in the object
'syncing,' but that only means that it gently floats along the trail of the server, which ruins its movement.
a quick and dirty way is to have the clients save their Player ID in a Network Variable.
For fast paced game, you will basically have to write your own network transform.
đ
alrighty then
i have an idea for that anyway
thanks <3
i need help with this fishnet error code line fishnet is the network
NullReferenceException: Object reference not set to an instance of an object
NetworkHudCanvases.Start () (at Assets/FishNet/Example/Scripts/NetworkHudCanvases.cs:149)
Show us the bit of code that causes the error, we need a lot more info to figure out what's causing the error.
Ok
MIRROR 73.0.0 IS LIVE ON THE ASSET STORE
Download: https://assetstore.unity.com/packages/tools/network/mirror-129321
ChangeLog: https://mirror-networking.gitbook.io/docs/general/changelog
How good is the new official Network package? I'm talking about the NGO (Netcode for GameObjects). Is it up to date with the Mirror or FishNet features/ease of use/performance wise?
Does anyone know if there is a good guide for photon quantum out there? I have searched everywhere and cant seem to find almost anything.
The only things really missing from NGO are client prediction and Interest Management. Both of those are thing you can write your own solutions for.
I have some trouble with the Despawn function. According to the documentation:
"to despawn but not destroy a NetworkObject, you should call NetworkObject.Despawn and pass false as the parameter. Clients will always be notified and will mirror the despawn behavior."
But when I try this the client destroys the game object even if the server called Despawn(false) and the server does not. Is this the intended behavior?
I believe that is correct. What did you need Despawn to do in that scenario?
hmm okay. A little bit confusing with the documentation then imo. I wanted to use the despawn to add some client only rigidbodies for death animation and then destroy it when the server destroys it. I'll just do it with a rpc or something instead I guess
For that I would just spawn in the ragdoll when you despawn the player
That is possible, however I did not want to spawn an identical object just to do the death animation. Anyway it's a minor issue. Thank you for the help!
So I'm making a game and I just started with networking
I have world generation, and I am worried that if the player enters a world he will see clients in other worlds instead of the same world he's in.
I am using the Netcode package & Multiplayer Tools package
How would I go about making it so I could only see people in the same world??
split the game so you have a main server and from there you have multiple server running seprete worlds. Something like that
Wouldn't that be way too difficult?
I have no idea where I'd have to start
and I don't know how I would split the server into multiple
you would have a host or dedicated server that starts up with custom scene. But have a master servcer where the player first connects to then when a server selects the world it just moves him to the server that has been started
Syncing generated worlds
Since i cant find anything online Im just going to ask here. A little problem i have been having with the backfill tickets and using matchmaker to join back into a running server. I can start the search for a server that spins up a new one but if i try to join once started i cant. I believe that the ticket is being refreshed but adding the player and removing him from the ticket is a bit tricky. Im using Photon Fusion. Once the player joins i call a RPC from a player to the server then the server call a rpc to the player to add him self to the ticket but im getting and error of server.config not found path
Hi, can anyone help me with spawning items on a spawned player in Netcode. I keep receiving the error {Spawning NetworkObjects with nested NetworkObjects is only supported for scene objects. Child NetworkObjects will not be spawned over the network!}. How would one go about making a networked inventory manager that spawns in networked Items. Any help is greatly appreciated!
@boreal wharf How can I create a real-time physics multiplayer game using web-socket?
@queen leaf Please don't tag random people for your questions.
sorry
Hello everyone, I have a weird reason. I am currently using Netcode for GameObjects and Facepunch Transport to make networking for my game. Currently I have a button that is supposed to open the Steam Overlay. But it doesn't seem to work. SHIFT+Tab doesn't work either.
Is there a way to do host migration with NGO?
I hear it's not supported at all
:(
You can kinda do it with the Relay and Lobby services
https://docs.unity.com/relay/en/manual/host-migration
Is there a way cleaner way to do update on each frame on a multiplayer using the Unity.Netcode?
void Update()
{
UpdateClientRpc();
UpdateServerRpc();
}
[ClientRpc]
void UpdateClientRpc()
{
}
[ServerRpc]
void UpdateServerRpc()
{
}
Is update just called on the server or client
This question was brought up by this script right there
private void Update()
{
if (!IsOwner) return;
float x =0f, z = 0f;
if (Input.GetKey(KeyCode.W)) z = +1f;
if (Input.GetKey(KeyCode.S)) z = -1f;
if (Input.GetKey(KeyCode.A)) x = -1f;
if (Input.GetKey(KeyCode.D)) x = +1f;
MovePlayerServerRpc(x, z);
}
[ServerRpc]
void MovePlayerServerRpc(float x, float z)
{
transform.position += new Vector3(x,0,z) * moveSpeed * Time.deltaTime;
}
If you are the host, MovePlayerServerRpc is called twice per frame
And I wouldn't want the server to do the code in the update.
The only fix I could think of was to do an other Update method with the [ClientRpc] tag.
Did you look into NetworkVariable: https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/ways-synchronize
I didn't though about using them. Thank you for bringing it up!
Hi! If i spawn an object and move/rotate it only on the host, does it get synced on clients or do i have to use a Network Transform/Network Variable?
The later. You could also use a ClientRPC
Thanks! Yes ClientRpc is probably the best approach
I am trying to make the player move to a new position when it collides with this object.
This script runs on the object the player collides with.
public class OnCollisionMove : NetworkBehaviour
{
public GameObject NewLocation;
private void OnTriggerEnter(Collider Player)
{
Player.GetComponent<MovePlayer>().SetPlayerTransform(NewLocation.transform.position, NewLocation.transform.rotation);
}
}
This script runs on the player.
public class MovePlayer : NetworkBehaviour
{
public void SetPlayerTransform(Vector3 Position, Quaternion Rotation)
{
GetComponent<Transform>().position = Position;
GetComponent<Transform>().rotation = Rotation;
}
}
There are no errors and both prints run and the player moves to the right place for about a frame before snapping back to the original. What am I doing wrong?
Make sure you are using Network Transform and not a Client Network Transform.
I am using a network transform
Sorry I got that backwards. You need to be using a client network transform instead.
Or just not use the clientRPC. Only the server can move network transforms
It doesn't work with either.
In that case you have something else in your server resetting the position
I'll check, that would make sense as the player is bounced back even when the code is run directly by the client when using a client network transform.
Would this line in the player controller be doing that?
controller.Move(transform.TransformDirection(moveDirection) * speed * Time.deltaTime);
that is run every fixed update
Yes. Character Controller overrides transform.position
I got it working, Just had to disable the player movement script while I run the tp
Thanks for your help
how to join a host with additive scene loading with 3 scenes, where only 1 has to be synced? I got a core, base and environment scene and only need to sync the environment scene. It keeps additively loading the base scene as well and I'm trying to ignore that scene somehow
If you are using unity Netcode, then you would need to uncheck the manage scene option in the network manager. You might just be able to use the normal scene manager instead of the NetworkSceneManager to load things additively
will the networkmanager automatically handle syncing the host's networkobjects to the client if the client loads the scene using the scenemanager?
Not the in scene placed objects
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.
how do i make a function to set the addres and port of the server to connect to?
In Unity Netcode
https://docs-multiplayer.unity3d.com/netcode/current/components/networkmanager#connecting
The NetworkManager is a required Netcode for GameObjects (Netcode) component that has all of your project's netcode related settings. Think of it as the "central netcode hub" for your netcode enabled project.
This is mostly a "theory" question: Why can't we send instanced objects (classes) through RPC calls (or, I guess - why can't class instances be serialized)?
probably not 100% corrent but i think that RPC's were designed to transfer simple data types to a certan size limit (sending numbers and text).
Technically they can be serialized, that's part of what implementing INetworkSerializable in Network Variables is for. But it mainly comes down to the difference between value types and reference types.
Yeah I guess my question is "is there a reason it's not simple?"
There is no straight forward way to âsimplyâ serialize every possible class instance including all its references. Theoretically this could mean that you would have to dump the entire process memory into the RPC message if your stuff is tightly connected. You can technically do it though, itâs just useless to do so (too much data). Consequently what netcode serialization wants you to do is to be specific about what data needs to be sent over the network for your game to function correctly, because no system could possibly infer that automatically. To make netcode simple, you need to architect your data to be simple.
can someone help me figure out why thiscode works on host but not client im making my first multiplayer so im very new
if (!IsOwner) return;
Camera = GameObject.FindGameObjectWithTag("CM Main Camera").GetComponent<CinemachineVirtualCamera>();
Camera.Follow = gameObject.transform;
Which part is not working? Is it not finding the Camera? Is it not assigning Follow? Is everything else correct but the main camera isn't moving?
It's not assigning the camera to the variable I checked by making it a serialized field
It runs on start btw and is a private variable
That's your problem. It's not in the scene at that point. It needs to run in OnNetworkSpawn()
But why would it work on the host and not the client in that case?
I have an object who's velocity is manually synced after it is changed on server, but it still desynchronizes. The script takes the server velocity and calls a client rpc to the corresponding client-side object to sync it. However, this doesn't work entirely.
Hey does anyone know if Fishnet is actually usable ?
Ive heard that name before but people were making jokes on its behalf, did that change i googled and it seems like its actually pretty good
People were likely making jokes given the aggressive nature of the style of advertising FishNet's creator used
thanks it works now still dont understand why it worked before but only on host tho
On the host, the player spawns in instantly. The timing gets weird on clients.
i see thanks
one more question how woud i sink a sprite renderers color? cus i have a gray scale character and i want to make it possible to change its color and also can i delay the spawning of the player character to for example make a lobby before you start the game cus i dont want people joining mid game
There are multiple ways to both of those. You can sync Colors by Network Variable or RPCs or send it in Connection Data.
You can use the Unity Lobby service if you want to find a game to connect to. Or you can have a separate lobby scene after the player connects
Is Fishnet actually better then Mirror tho, are the claims of FishNet true, like with the easier setup or built in clientside prediction etc
alr thanks
Who knows, many claims were made with no evidence to back them up
Best thing you can do is try them both with an open mind and see what you like
yeah right
tbh i will skip trough some tutorials on both and i will see if the setup is actually easier for FishNet
if the claims are true it should be easier and it automatically should come with client side prediction and other features
A lot of those features in Fishnet are behind a Pro paywall.
isnt the pro paywall like a one time 10$ charge
yeah its one time 12$ and then 2$ for updates to pro
thats acceptable
12$ for client side prediction and stuff
I will go with mirror since there is more help for that available, i think thats more important then ease of setup
So I am working on netcode. For my host, everything works as it should. For my client, everything from OnMove is ignored. Everything else works for the client. When i tested the if statement below for movement, it worked for both host and client. My question is, why does OnMove not work for my client?
public void OnMove(InputValue movementInput)
{
Vector2 movementVector = movementInput.Get<Vector2>();
movementX = movementVector.x;
movementY = movementVector.y;
}```
___________________________________________________
```cs
if (Input.GetKeyDown(KeyCode.W))
{
movementY = Input.GetAxis("Vertical");
}```
Is there something special i need to do with the new input system to get it to work with netcode?
Your input is only called locally. So you'll need to use a Client Network Transform or send your movement by a Server RPC
now when you say my input. what are you referring to?
ELI5 please
Video for context
OnMove() or Input.GetKeyDown will only be called locally. You might not have authority to move the object. Unity Netcode is server authoritative by default
if you re read my original post, one of those works, the other doesnt.
The host has server authority. the client does not
then why can the host and client both jump?
if (Input.GetKeyDown("space") && IsGrounded() && canJump)
{
rb.AddForce(Vector3.up * _jumpForce, ForceMode.Impulse);
canJump = false;
jumpTimer.Start();
}```
literally everything works on the client except OnMove()
Do you have the project setup to use both old and new input system?
are you referring to my cs using statements?
no, in the project settings. you can set it to use the old legacy input manager or the new input system or both
currently set to both
which one do i deleat/rename??
I am making a registration system for my game using Netcode for GameObjects
I happened to just realize that everything is working on the host, but not on the client.
When I attempt to do anything server-side, it doesn't work. When I click register for example, ServerRpc gets called.
and in the ServerRPC void, since it's server-side, it will check the files on the server and respond by for example changing the page for the client.
It's not working though, and I'm not sure why. Have I done something wrong? RPC is pretty confusing tbh
I also tried doing Debug.Log("x"); in the ServerRPC void to test it out, and on the server-side I don't see anything in the console when the client clicks the button that calls ServerRPC
I would remove the one not in a package. that package will get reinstalled during updates
so the Fusion one
I have an object who's velocity is manually synced after it is changed on server, but it still desynchronizes. The script takes the server velocity and calls a client rpc to the corresponding client-side object to sync it. However, this doesn't work entirely.
If you mean Streetpass then what you are looking for is Network Discovery
I guess you'd need a direct peer to peer ad hoc network in that case. But that's a security nightmare.
Ive got a question,
so im trying to change scenes using relay
ive got my players in a relay together but how would i get them all to join a scene together?
Thanks đ
I am making a registration system for my game using Netcode for GameObjects
I happened to just realize that everything is working on the host, but not on the client.
When I attempt to do anything server-side, it doesn't work. When I click register for example, ServerRpc gets called.
and in the ServerRPC void, since it's server-side, it will check the files on the server and respond by for example changing the page for the client.
It's not working though, and I'm not sure why. Have I done something wrong? RPC is pretty confusing tbh
I also tried doing Debug.Log("x"); in the ServerRPC void to test it out, and on the server-side I don't see anything in the console when the client clicks the button that calls ServerRPC
So I have this edge case in my head that has been bugging me for a while.
We have a client and a server, the client connects to the server, the server spawns a networked object for the client and invokes a non reliable RPC on that network object.
The client receives the RPC command before the network object spawn command, so when it comes time to invoke that RPC on the client, the client will error out saying that the Entity for this RPC doesn't exist.
How would one tackle this issue?
I would have the player object request that RPC from a serverRPC in its OnNetworkSpawn()
That would solve that indeed.
What if it was a broadcast RPC tho, server spawns object -> sends to client -> client requests server RPC -> server sends unreliable broadcast to all other clients.
The other clients could still technically receive the unreliable broadcast before its entity is spawned on their end.
Very very unlikely, but still possible?
If its important data, you either use a Network Variable or use OnSynchronize()
https://docs-multiplayer.unity3d.com/netcode/current/basics/networkbehavior#onsynchronize-example
Both the NetworkObject and NetworkBehaviour components require the use of specialized structures to be serialized and used with RPCs and NetworkVariables:
Yeah, I suppose that's an option too
Thank you
For P2P Networking for a Multiplayer/Co-op game where I don't care if someone cheats....
Whats the easiest solution? I've messed around with Mirror in the past, but, if theres something easier I'd gladly look into it.
Mirror, Photon, Fishnet, and Unity Netcode are all about the same complexity.
Thats sort of what I figured.
Does Unity Netcode support Steam easy? I know Mirror does.
There are a couple of Steam Transport available for it. Dunno how easy it is. I've never used the Steam Transports before
Thats fair. Hmm.
Yeah just trying to gauge the easiest solution for me.
Overall my assumption on how I'll be setting things up:
- Server controls Enemy/AI and just relays that information to the clients (EG: Other player + Host)
- Clients (EG: Players, both) just send their controls to the server to relay to others.
- Clients would control damage dealt/received.
I know this would open up to cheaters, but again, co-op game, so, you're really just ruining the fun for yourself.
I assume however, that with Photon, it seems that I'm limited by CCU even when doing P2P. So I think thats out of the question.
Hello everyone! I have a bit weird of a question
Can I use Unity relay, when not all clients use Unity? I'm thinking about a game like Jackbox, where players use phones as controllers.
Can it be done through Unity multiplayer solutions or should I just write my own backend?
Basically, what I want:
- There's a Unity game running on Desktop that acts both as a server and, khm, screen for the players
- There's a lightweb web app optimized for phones that has nothing but a couple of buttons
- When a player presses one of the buttons on their phone, a message is sent to the Unity game, that processes this input and updates the game state
- Phone clients receive an updated state and use it to display some other buttons, etc
I have an object who's velocity is manually synced after it is changed on server, but it still desynchronizes. The script takes the server velocity and calls a client rpc to the corresponding client-side object to sync it. However, this doesn't work entirely.
Hello!
I started using Photon today for multiplayer project, but when I added it to the project. I got an error for it, but I have no idea how it works. And how I can get rid of it. Does anyone know what I should do?
Failed to find entry-points:
System.Exception: Unexpected exception while collecting types in assembly `PhotonRealtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null` ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Photon3Unity3D, Version=4.1.6.17, Culture=neutral, PublicKeyToken=null'
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
at Burst.Compiler.IL.Server.EntryPointMethodFinder.CollectGenericTypeInstances (Mono.Cecil.AssemblyDefinition assembly, System.Collections.Generic.List`1[T] types, System.Collections.Generic.HashSet`1[T] visited) [0x00057] in <a2dd15248a25411e914af2a2c82fb63f>:0
at Burst.Compiler.IL.Server.EntryPointMethodFinder.FindEntryPoints (System.String[] rootAssemblyNames, Burst.Compiler.IL.Hashing.CacheRuntime.HashCacheAssemblyStore assemblyStore, Burst.Compiler.IL.AssemblyLoader assemblyLoader, Burst.Compiler.IL.NativeCompilerOptions options, Burst.Compiler.IL.Server.ProfileDelegate profileCallback, System.Boolean includeRootAssemblyReferences, System.Boolean splitTargets, Burst.Compiler.IL.Helpers.DebugLogWriter debugWriter) [0x0019d] in <a2dd15248a25411e914af2a2c82fb63f>:0
--- End of inner exception stack trace ---
at Burst.Compiler.IL.Server.EntryPointMethodFinder.FindEntryPoints (System.String[] rootAssemblyNames, Burst.Compiler.IL.Hashing.CacheRuntime.HashCacheAssemblyStore assemblyStore, Burst.Compiler.IL.AssemblyLoader assemblyLoader, Burst.Compiler.IL.NativeCompilerOptions options, Burst.Compiler.IL.Server.ProfileDelegate profileCallback, System.Boolean includeRootAssemblyReferences, System.Boolean splitTargets, Burst.Compiler.IL.Helpers.DebugLogWriter debugWriter) [0x001d9] in <a2dd15248a25411e914af2a2c82fb63f>:0
at Burst.Compiler.IL.Server.FindMethodsJob.Execute (Burst.Compiler.IL.Server.CompilerServerJobExecutionContext context) [0x00133] in <a2dd15248a25411e914af2a2c82fb63f>:0
While compiling job:
Something like this would be done through websockets. Unless its running a webgl client, a regular webpage is not going to be able to connect to Unity
hi guys on quick question how i can make an rpc affect only me ? example , how the others will be notified that i closed or opened my flash light ?
If you are using Unity Netcode, you can set clientRPCparams that will only send the clientRPC to one or more clients
I am using photon
how can i change the game version on mirror
Anyone have an example on how to correctly utilize NetworkList<T>?
As in sure i know how to create one but what is the intended way to change the values of an element structs values? Or do i just need to do a full replace for the member? Seems rather wasteful
Syncing physics is a very very hard problem. Ideally all physics is handled by the server and Network Rigidbodies syncs the rest
You could send an RPC, yes. It is also OK to set a Custom Player Property, telling others if the flashlight is on or off. Then you'd use SetCustomProperties() to set this (and possibly other) value(s) when it changes.
The Custom Player Property would possibly be my preferred approach, as late joining players also get to know this.
Only changes get sent in a networklist
Just had the bright idea of actually reading it's source code since it's available and didn't seem to be that complicated. Get it now, seems there's a few minor issues with it overall and it doesn't support writing only a delta of a structs changes but the whole struct. So the answer is if i'm not happy with it write my own from the example đ
I would argue that if sending the whole struct is an issue then you probably need smaller structs
Admittedly i have a tendency to make "too performant" code, but i'm not insane however, shall profile if it's even worth it before committing to making my own NetworkList
One test worth a thousand expert opinions and the like
Premature Optimization is the Devil
That it is, my only problem with that slogan is that far too many devs seem to have an incredibly loose definition of "Premature" where it means noticing at the last 2weeks before launch their game runs like crap and then failing horribly at optimization. The skill is in identifying what is the correct time in development to test a feature and do the tests in controlled sizes so you don't get fooled by ones own lack of full understanding on how the engine works overall
My personal answer has been to do an hour of profiling once a month or so and do an immediate test if you're almost certain "hey this could cost quite a bit" so you don't build other systems to rely on something you have to gut later. That is a time cost aswell, not noticing issues until well after you've committed to them
The corollary slogan is "Profile all the things!"
Hadn't heard of that, good one i like it! Thanks
Thanks for the info I worked on a project with too many custom properties and I was insane how much lag was there... Don't know if it was a project fault but it didn't work well. I set this to rpc target to other
someone knows why the player get disactivated when I instantiate in photon pun?
it wasn't supposed to happen
and my prefab is not disactivated
i am using photon pun2 and my bullets are jittering a lot (btw i am using rigibody.velocity)
maybe a script is deactivating it?
I checked every single script I have, no one has this function, I also tried another game object without any script and it still desactivating
Hello to everyone! I am facing such a problem when using Network Animator. What is the reason of this? I'm pretty sure I'm using the latest version of Netcode. v1.2.0
ello
so
how exactly would i make an overarching database for all the players on all the servers
I want like
leaderboards and stuff
kthxbyehavegudday
nvm I found what the problem was
I forgot to add the photon view component to the object
Anyone come across this error message before?
It happens when I am testing using Parallel sync, when the client disconnects, the host gets these error messages. The messages continue to spam the console even after the game has exited play mode.
Kind of hard to tell what's going on in your video, are you firing the bullets in the build and getting jittery performance in the editor?
How are you syncing the position? Using some kind of transform sync? If so, you should look into just spawning the bullets locally on whatever client is firing them, then sending an RPC for everyone else to spawn a bullet too. That way the physics can be simulated locally and will always run as smooth as your game allows it to run
Hi, I am trying to decide which networking solution I should use.
Here are some of the key things I'll point out:
I don't want to use photon since it's very limited(from what I saw) and you have to pay for pretty much everything.
I have no experience when it comes to networking whatsoever, this is the very first time I'll actually give it a try.
My goal is to make a self hosted, dedicated server(pretty much like what you have in cs 1.6, community hosted servers that people can join and play on them) and have a separate app just for that.
2 of the main solutions I am considering now are Riptide and FishNet but I really don't know which one I should go with.
I've seen unity's solution but I don't know if it's any good/free.
I am open to all of your suggestions and thanks in advance!
Heya!
I'm a noob myself, but I can say that, for my skill level and for what I'm doing, that Unity's Netcode is a fine choice
It has many useful prebuilt features and also makes it incredibly easy to talk between server and client.
is it free tho?
and can you host servers the way I described?
It is an entirely free package which you can install in unity and, to my knowledge, it can host servers in the way you wish to do so.
A good resource is the Multiplayer Unity Documentation.
This site provides Unity Multiplayer documentation, references, and sample code tutorials.
I'll take a look into it, thanks!
when playing animations on the host's client, it plays it on every other client as well, why is this? I'm using mirror
are there any resources for writing your own transport?
there is a template here
https://github.com/Unity-Technologies/multiplayer-community-contributions/tree/main/Transports
The problem is usually more generic: Synchronizing too much in an inefficient way. PUN doesn't keep you from using a lot of bandwidth with bad practices, so this can happen.
Values you change somewhat often, should get their own Custom Properties key. So you can change them on their own, not sending all the other values.
If you have a lot of Custom Properties, you a) can set some of them in one SetCustomProperties call and b) want to avoid to set them all in each call. So avoid SetCustomProperties(player.CustomProperties) under all circumstances.
Fusion is better for this, because you can define the game state as networked variables and it will automatically detect changes and only sync those. That is very lean without you taking care of it.
can someone help me with setting up my project for unity servers (multiplay)
Which multiplayer engine are you using?
I was wanting to use the unity multiplay sdk and their game hosting servers
Hey I'm curious if there's any discord specifically for Netcode for Gameobjects? I'm hoping to find separated channels to talk about things since there's so much going on with it and the amount of resources is pretty slim. Thanks
There is. I'm a mod there. I can't post the discord link but its listed at the bottom of the docs here
https://docs-multiplayer.unity3d.com/netcode/current/about
Learn more about the available APIs for Unity Multiplayer Networking, including Netcode for GameObjects and Transport.
Howcome this results in my host jumping and not my client?
aka OwnerClientId logs 0 and the host/client jumps, OwnerClientID logs 1 and the client does not jump
Are you using Client Network Transform? ServerRPCs only will run on the server
Yes, I am using Client Network Transform for my player prefab.
I am currently working through codemonkey's netcode tutorial and his explanation of ServerRpc's didnt really lend me a great understanding of it. I am working on a competitive physics esport style game and i want collisions etc verified server-side, so I should be using ServerRpcs's to do just about everything right?
in theory yes. but client network transforms are controlled client side only. You should be using regular network transforms for server authoritative games.
Syncing physics is a very very hard problem. You will need to implement some kind of client prediction system. You will always be fighting against lag
i am aware of the general problem facing syncing physics... I have like 1100 hours of Slapshot: Rebound.
will test with reg network transform
I'm using photon pun, and I have a dev build, and the standard unity window running, whenever I create a room on one, I can't join the other. I haven't changed any script that is related to joining, but it stopped working. What can I do to fix this?
Hi I'm semi new to networking in unity. Is Mirror or Netcode better for smaller scale games? Also which is better to learn for jobs?
both are fine
professionally there is no reason to master any specific library, those skills get old fast. learn fundamentals, be able to custom build your own, based on understanding or the problem-space and the principles behind their solutions, is the best qualification.
Hi, I am planning to work on 2 multiplayer projects.
I can't say that I have any experience with networking other than watching quite a few videos so I am looking for other's advice.
Should I use FishNet or Netcode for Game Objects?
The first project is a pretty simple game(imagine bloons td6) where a person hosts a server(prob up to 4 people) and you just play with your friends for fun.
The other game is a bit more serious and I'd like everyone to be able to host a dedicated server.
What I mean by that is that I want to have the game build it self in which you can join servers and then the dedicated server app which you can use to host a server for the game.
I have a bit more detailed questions about that by it self but I can ask that once I am actually building the game.
As for right now, I am just looking for the best networking solution to learn and it doesn't have to be either of the two I mentioned.
I've heard that riptide is pretty good but I haven't seen a lot of tutorials for it.
OnCollisionEnter2D dosent work whys that?
both object have Edge Colliders, RidgedBodies2d, Network RidgiedBodies2d, Client Network Transform one of the object is a player the other is a network object
They are both fine. I personally use Netcode. It's fairly new and there are not a whole lot of tutorials out there but it's maintained by Unity itself.
Make sure the collision is being checked on the client. The server will not see any of those collision events
So the host can't use onclissionenter2d?
It can for its own collisions. Client network transform makes everything owner authoritative. So each client will be responsible for its own collisions
Well why does it not work I have a bullet thats a network object and shid run some code while colliding with something a debug.log to be specific but it does not
Is the bullet owned by the client?
It's a network object spawned with a serverrpc
Sorry forgot to replay in the previous message
OnCollisionEnter2D dosent work
ok, as I said, I am not experienced when it comes to networking so this could be wrong.
From what I've seen, you need to attach prefabs and well everything to your server component on both fishnet and netcode for go.
How would you do that if you had a server as a separate project?
The only thing that comes to my mind is a workaround of just sending for example strings of what to instantiate to a player's game.
Anyone have experience with setting up unity servers (multiplay)
Netcode uses Prefab Hashes that can be overridden. But I've found dual projects to be more trouble than its worth
well a server being say 500MB instead of 20GB is great
Heya!
I intend to use PostgreSQL as a database for my multiplayer PVP game for storing persistent data (like kills).
How would I have a Unity server communicate with a PostgreSQL database whilst making sure that players can't access it themselves?
You would only give the Dedicated Server credentials to the database. Ideally in a config file so it's not hard coded anywhere.
thx! How would the servers communicate to the database though, not just the other way round?
There are lots of C# libraries for communicating with SQL
right right, forgot bout that
however
this leads into another question
in my demo builds, all players are able to host or play.
however, I know I'll eventually have to go to dedicated.
how do you connect players to dedicated when the builds aren't the same?
This is part one of the Porting from client-hosted to dedicated server-hosted series.
Is there a way to remove addressables from dedicated server build?
If you mean the addressable bundles you can just reupload your server files without them included
The best option is the one that works for your current project. I know that's a non answer. But the only real difference in most of the networking frameworks are price and advanced built-in features. I use Unity Netcode because Photon ended up being too expensive.
are there any ways to differentiate different users aside from their accounts? I am making a game, and if there are cheaters and I ban them, I am worried they'll just make 20 alt accounts. How would I circumvent this?
You can use Unity Authentication to tie Player Ids to Steam, Facebook, or OpenID. But nothing will stop bad actors from just creating new accounts.
Hallo
Is there any way to change a texture of a Network Player in Photon while in a server?
Thanks for feedback I want to make games with Bot using AI and I think right now Unity system feel the most friendly for me đ
is there any other way to deal with this
?
You'll be rich if you figure out a way to stop people from making alt accounts
UnityWebRequest keeps downloading old data thats like over 30 minutes old. If I ctrl click the url in visual studio, my browser opens and displays new data... i know the data on the remote end is updated but i cant figure out how to get unity to get a fresh copy. I've tried usehttpcontinue = false but it didnt change the behavior.
Has anyone got Netcode for Gameobjects working for multiplayer VR using XR Interaction Toolkit?
Just wondering how difficult/buggy it might be to get a basic model viewer app running (2+ ppl using VR on local network) view,/scale/edit a model on a table in front of them on a digital table
Thank you
Hallo please how to make fps microgame multiplayer?
yes
lmao ok then
The interaction Toolkit is not built for multiplayer at all. You will have a much easier time handling everything manually.
Maybe some some of the newer toolkit updates changed things, but reparenting network objects is a huge hassle
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 NetworkObjects.
Best start by looking up which netcode solution to use
damn thanks a bummer. Thank you
what I was thinking about was how minecraft makes you pay for an account
@graceful zephyr do you nanosockets on mac silicon?
does anyone uses NanoSockets with mac silicon? m1
You too can make people pay for accounts
Doesn't prevent alt accounts
ik, but that would at least put hax behind a paywall
so how do they do that?
To be quite honest, I believe you're putting the cart firmly before the horse
Have you even got a working prototype?
im at that phase where im building the database for persistent data
I think you're gonna waste a lot of time worrying about something that probably won't happen
Easiest way to make people buy an "account", whack it on Steam for ÂŁ20
make a fun game first, then build the rest of the infrastructure
making a fun game is the hard part, and the infrastructure is useless without anyway
so start with that
Thank you for the help man
lol
You cant just say if you use it on mac silicon m1? im losing days trying to make it work
it will take like 5 seconds for u to say this ..
thank you
hey @graceful zephyr , i've compiled the nanosockets library for mac m1 using cmake. Client and server are both up and running, but server doesn't receive any messages from client
any idea how to debug?
any steps on how you made it work for m1?
can help a great deal
did it work out of the box or had to jump through some hoops?
i dont remember, been using it on M1 mac since M1 came out basically
there's no difference to M1 mac to any other platform other than that native code needs to be compiled properly for it
also if you're just starting out, just use regular .net sockets
no point in using nanosockets or any other lower level abstraction
it just makes it harder for you and gets in the way
can't use it with burst
u dont need burst lol
Can i send raw binary data on unity transport? a byte pointer?
Hey Paco, do you mind if I DM you?
ok
Is there some limitation on when you can call Rpcs? Such as are you allowed to call one in OnNetworkSpawn()?
Reason i'm asking is that i'm getting absolutely irrational behaviour from them in a super simple game where there is only a Host and a Client that both use a RegisterClientServerRpc(MyDataStruct someData) to update a NetworkList<MyDataStruct> myNetworkList field in a shared NetworkObject(as in only one of these exists)
The Host and Client have a different amount of elements in the list (client has 1 extra ghost value).
I'm calling the RegisterClientServerRpc currently in OnNetworkSpawn, the Rpc has requireownership set to false
The Host has correct amount, the NetworkList also seems to run two value updates but that i presume is due to using the Reliable Rpc delivery attribute?
The problem you are running into is that OnNetworkSpawn() on the host happens before the objects have actually been spawned on the clients.
I have the clients call a ServerRPC when they are ready instead.
I'm propably missing something very obvious here, but the part about Host behaviour vs server seems way off kilter to me and perhaps this is why i don't get it.
But could you please explain "when they are ready" part specifically here if it isn't too much trouble? What is the actual thing that is causing my issue so i can avoid it in the future.
everything spawns on the server/host first, then a packet is sent out to spawn the object on the clients. So on the sever, OnNetworkSpawn() will get called and any RPCs there will get sent before they have actually spawned on the client themselves.
I'm suggesting that you use OnNetworkSpawn() from the clients since you know at that point everything is spawned and ready
So in plain english you think my issue is that the NetworkList value change is received by the Clients copy of the NetworkBehaviour before it has had time to initialize the NetworkList and as such adding it twice? And this would indeed be due to the code adding an element since it doesn't exist there yet?
If so i think i'll be redesigning that portion of the NetworkList for my own purposes đ
Thanks for taking the time to explain this
Check out OnSynchronize if you need things updated before/when they spawn
https://docs-multiplayer.unity3d.com/netcode/current/basics/networkbehavior#onsynchronize-example
Both the NetworkObject and NetworkBehaviour components require the use of specialized structures to be serialized and used with RPCs and NetworkVariables:
Thanks once more, yeah i guess my need is exactly that, when stuff spawns i want the fields to be synchronized.
I'll need to update the project for that though but that'll have to wait since i can't currently due to a semi-big bug in the IL2CPP (completely unrelated but blocking upgrade to latest 2021.3 versions, jagged arrays don't work with binary formatter).
But atleast i know how to work around for now and how to simplify once the bug is patched
Hello, what is the correct way to have the same random number on all clients ?
Check out Random.InitState
https://docs.unity3d.com/ScriptReference/Random.InitState.html
You'll want to somehow have synced the same seed for all clients.
If your game is in a way that all clients are on the same frame/tick, you could use that as an example.
All randomness should be controlled by the server/host. Then you can send the results via a ClientRPC.
Thanks for your help guys đ
Hello, I'm using the Steam API and I'm having a problem inviting players.
First, I'm creating a lobby with Steamworks NET. Then, if the lobby is formed, I send a data to the lobby. Then I invite someone using the Steam interface. But when the other party accepts the request, nothing happens. I'm listening to all "GameLobbyJoinRequested_t" and "LobbyEnter_t" callbacks and printing with Debug.Log. But there is never any result.
Hey everyone, I'm trying to make a multiplayer game using Networking for Gameobjects. I've created a server object and a client object. I'd like to call a server RTC in the server object from the client object, but I'm struggling to figure out how to get an instance of the server object in my client 
i was downloaded the boss room project, reading the code etc.. take my project id, enable relay, lobby, etc and still happen the same error"i have to enable game service in unity" first day training and problems
i think you dont have to do in this way, take a look on boss room project
rtc you mean RPC? i think all networks solutions are using same names, so when you send a RPC you dont need to search for the client object or i dont understand what you want to do sorry
I don't know what the Server class here is. But if you instantiate a network object on your host/server, you then have to call .Spawn() on that networkobject. The client can then call the serverRPC on that networkobject.
The serverRPC will need requireownershp=false in it's attribute.
Make sure the services are enabled in the Unity Dashboard for that project
they are enabled all
hey i have a question. i'm trying to explain to someone why i cant use netcode for gameobjects with my unity server hosting, because of how netcode gets outscaled. unfortunately i'm not able to articulate it in a way he can understand. maybe you could state why using netcode isn't realistic when setup for server hosting in a way that i can explain to him.
Hello!
Is there a way to implement video chat on Photon?
I don't think anyone's got video chat built in. You'll probably have to roll your own with WebRTC
should i have installed netcode or something? i. have enabled realy and lobby into my dashboard but still showing "i have to enable this server"...
Hello
I have a NetworkVariable with some data
On disconnection, I don't destroy this NetworkBehaviour/Object
And on reconnection, the objects spawn again
The problem is, if the server updates the NetworkVariable during the clients disconnection phase
the value isn't immediately updated
on Spawn of the new network object
Sometimes the update value comes up, sometimes the update doesnt and its all default values
I do not want to add a manual delay of certain seconds before I get the latest state
is there a callback for this?
Im doing a turn based game, where the game state updates every turn.. so subscribing to OnValueChanged seems unnecesary
i just send rpc calls with output data
how to sync video over network with photon fusion?
Have the same problem
I think this is what you want
https://docs-multiplayer.unity3d.com/netcode/current/basics/networkbehavior#networkbehaviour-pre-spawn-synchronization
Both the NetworkObject and NetworkBehaviour components require the use of specialized structures to be serialized and used with RPCs and NetworkVariables:
If you want to send video over the network you will need to use a library like WebRTC
Thank you)
Does anyone know what causes this?
I'm trying to call a server RPC to send a simple message. When I create a host it works, but if I try and create a separate build, host on there then create a client in the editor it produces this error
I'm using default settings of local host and port 7777
They've definitely connected as there are 2 player prefabs
nvm I've figured it out
it's because I was trying to send the Rpc message too soon after connecting
or before they were connected fully ig
I do have another question about structure of game logic. Currently what I've done is create a serverGameLogic prefab which is only created on a host/server, and a clientGameLogic which is only created on client. Then I have an intermediatory interfaceGameLogic networkobject which has a reference to the serverLogic on a host/server and a reference to clientLogic on host/client, which executes server and client rpcs. Is there a better way to lay this out or does this work? I'm trying to separate my client and server side
Yea, don't call clientRPCs in OnNetworkSpawn(). The host spawns them instantly before being spawned on clients
it was a server rpc but same thing I think
So I have some Authoritative server questions / opinions that I am wondering if I have the right viewpoint / concepts, etc.
I have a multiplayer hockey game, problem now is the player names in the back of the shirt. i have that code line that puts its on the back OnNetworkSpawn() but all players have now my name, how to make all players sync in the server their name ?
Hey guys , i have a question, i want to connect photon to my project which have starter assets package in it which means my player have first person controller script my question is will it be possible to connect photon ? and do anyone have a similar project so i can have a look on it and try to do the same steps
You mean if it's possible to sync the FPS controller from said starter pack? It will be some work to do that but it's possible. Just don't expect it to work out of the box.
If you create an FPS, you should possibly use Fusion. In that case, maybe our Fusion character controller is an option for you? It is networked already, so it might be less work to get used to that instead.
Join the Photon Engine discord (via the Photon Dashboard Account page) if there are more questions...
Thank you , I'm trying to find a way to connect it in my project
Hello is there any way to sysc webcam on unity and photon
There is a Photon Video SDK for Industries Circle members.
https://www.photonengine.com/industries
Is there a way to store an Array of GameObjects in a network variable, I already know the answer really but i just dont know what to do
I have 4 units per player and need to store a reference to other players units so I can set their materials and stuff
nvm sorted it i think đŤĄ
For future searchers, you can use NetworkObjectReference for this
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/serialization/networkobject-serialization#networkobjectreference
Brief explanation on using NetworkObject & NetworkBehaviour in Network for GameObjects
holy shit this is what i need thanks
i didnt end up sorting it
Can someone with experience in using Photon Fusion dm me?
I'm fairly new to coding multiplayer and am confused about something that should be simple
I guess I could ask it here as well. I'm currently trying to get a variable (just called x) to be synced across devices. When any player presses their mouse button, x should increment by 1 on all devices. I'm having trouble figuring out how to do such a simple thing. Here is my approach so far:
Create a network prefab called MathManager
Create a singleton script MathManager with [Networked] variable x
When the host starts game, spawn a MathManager object in the scene
Is this sufficient to share a variable x with all users?
I don't use photon, but you probably need to set the permission of who can write to the network variable. In unity Netcode by default only the server/host has write permissions. In which case a RPC would need to be sent to increment that variable. Or give the clients write permissions.
hello everybody,i am creating a multiplayer game using photon,i started to set it up,but it is 2 days that when i build the project photon doesn't work,somebody know how to solve the problem? In the editor all works correctly,just in the build it doesn't work (just if i build for android,the build for pc works)
It seems like the issue may be related to the build settings for the project. Since the game works correctly in the editor, but not in the build, it could be an issue with how the game is being packaged for distribution.
One potential solution could be to double-check the build settings and ensure that everything is configured correctly for the intended platform. It's also possible that there are missing or incorrect dependencies that are causing the issue.
Another solution could be to check the Photon documentation and support forums to see if there are any known issues or solutions related to the specific platform and build settings. It may also be helpful to reach out to the Photon support team for further assistance in troubleshooting the issue.
[solved*] can anyone here confirm that a unity 2022.2.5f1 WebGL build using entities and net code 1.0.0.prev-15 has the UNITY_SERVER symbol defined? I am trying to build a client webgl build but unity is adding a UNITY_SERVER symbol when i want a UNITY_CLIENT. there doesn't seem to be a Project Settings > Dots Settings with webgl. how can i make it a client only?
edit: this seems to be a bug related to switching from a dedicated server build to webgl where the Server flag is set? I had an editor script set the subTarget to Player and that seemed to fix it *maybe
So I'm a literal rocket scientist, yet I can't for the life of me figure out unity's netcode. It shouldn't be this hard. I've done the unity multiplayer tutorial, but camera control with custom perspectives based on movement are proving to be difficult. Does anybody have a good tutorial using multiplayer netcode with cameras that aren't simply following behind the player that I can look at?
Cameras
all worked 3 days ago,i don't know why i did a build and from than all the buildings stopped to work,the only thing that i can do now is to ask photon assistance.I also asked in the unity3d forum and photon forum for help.https://forum.photonengine.com/discussion/7682/solved-photon-pun-broken-in-build-works-in-editor i also found this thread but it doesn't explain how to solve the problem
Hello! I am using Netcode for gameobjects and I am trying to display the ping of each player.
public TextMeshProUGUI pingText;
private float pollingTime = 1f;
private float time;
private float frameCount = 0f;
private NetworkTransport networkTransport;
private ulong clientId;
private bool networkSpawned = false;
public override void OnNetworkSpawn()
{
networkTransport = GameObject.Find("NetworkManager").GetComponent<NetworkTransport>();
clientId = NetworkManager.Singleton.LocalClientId;
networkSpawned = true;
}
// Update is called once per frame
void Update()
{
if (!networkSpawned) return;
time += Time.unscaledDeltaTime;
frameCount++;
if (time >= pollingTime)
{
ulong ping = networkTransport.GetCurrentRtt(clientId);
pingText.text = $"{ping} ms";
time -= pollingTime;
frameCount = 0;
}
}
This is how i am doing it. The player that hosts the game has 0 ms latency, but when a client connects, it outputs this error:
KeyNotFoundException: The given key '1' was not present in the dictionary.
It references this line ulong ping = networkTransport.GetCurrentRtt(clientId);
Ola, I am learning how to use netcode in Unity đ And I am little bit confused, I know how to make player prefubs and spawn player, but what If I want to do something like GameManager? Script which holding methodes for every player? Bcs for example my script have to pick one random question for players, but when it is just dropped in scene, it will pick one random question for each players. Any idea how to make this script (gameManager) same for all players? đ
Does anyone know if Facepunch fixed their p2p ip leak thing in Facepunch.Steamworks ?
I last remember Dani having problems in Crab Game with DDOS attacks cuz of it
I need help with photon multiplayer
I need to change the scene but when it changes, the players that were in the other one, still in the new one. Can someone help me?
can someone help me: i have 2 players, 2 photon views, i want the host to have player 1 and photon view 1, and player 2 to have photon view 2, when the second player joins, photon view 1 AND photon view 2 is owned by player 1, i believe this is causing the issue that the second player doesnt move on player 1s screen
fixed by transfering owner ship
are you using PUN?
https://hatebin.com/pundqbysmj
var alloc = await RelayService.Instance.CreateAllocationAsync(lobbyData.MaxPlayers);
```This worked perfectly before but now freezes the editor. It doesn't throw any errors and refactoring to coroutines does not work.
This is the console before it crashes
yes
I fixed it
by doing nothing and it suddenly working again
i love programming
I'm working on a don't trust the client basis
Is there a better way of laying this out?
I don't want to use a network variable because then it will share the role with all clients when they shouldn't know
Server knows their role, then when a client should know it will call revealTeam as well as the client it should reveal it to
which will then construct the rpcParams and then call the clientRpc
I have already stumbled onto a problem with unity netcode that im trying very hard to solve but no luck. Im making an fps game and when i host a server and join as a client from a different window, the client works perfectly. When I use the move keys only he moves. But on the host theres a problem. The host moves its body but sees everythig from the POV (camera) of the client so he sees himself from a 3rd person view. Basically im wondering how to tackle with multiple cameras attached to prefabs?
Anyone?
I'm making a competitive fps and I can't trust the client for anything. I have learned you apparantly can't send GameObjects in RPC's. How would you then go about having the server move the client if I can't tell the server which client?
[ServerRpc]
private void MoveServerRPC(bool w, bool a, bool s, bool d, GameObject thing)
{
Vector3 moveDir = new Vector3(0, 0, 0);
if (w) moveDir.z = +1f;
if (s) moveDir.z = -1f;
if (a) moveDir.x = -1f;
if (d) moveDir.x = +1f;
float moveSpeed = 3f;
thing.transform.position += moveDir * moveSpeed * Time.deltaTime;
}
Tried this, but I'm not sure what to do when I can't send gameobjects
you could send ServerRpcParms?
That tells you which client has made the function call
I'm not sure if another client can send server rpcs to make it looks like it's been by another client though
that's a question I actually wanted to ask here
only the owner of the object in question will be able to call it
FPS Cameras
The serverRPC already knows what object it's attached to.
There is a (Requireownershp=false) parameter you add to the ServerRPC attribute if you need to call it from another object like UI buttons.
But to answer the original question, you can send a NetworkObjectReference instead of GameObject
Oh, thats neat! Ty!
[ServerRpc]
private void MoveServerRPC(bool w, bool a, bool s, bool d, NetworkObjectReference thing)
{
Vector3 moveDir = new Vector3(0, 0, 0);
if (w) moveDir.z = +1f;
if (s) moveDir.z = -1f;
if (a) moveDir.x = -1f;
if (d) moveDir.x = +1f;
float moveSpeed = 3f;
thing.transform.position += moveDir * moveSpeed * Time.deltaTime;
}
Doesn't seem to work?
You don't need it at all. You can just change the transform
Oh, I can just do transform.position?
I'm dumb
I thought that would change the position of the server, but that's not possible
Makes sense, ty!
As long as you are using a Network Transform, it will automatically sync
đ
Quick question: Is it necessary to do camera rotation on server using serverRPC or is that fine to do on a client. I don't see any reason to do it on the server
Question.... I'm using NetCode for GameObjects. Why can I not add a component to a local client with AddComponent<Camera>()...? When I spawn a player I figured it would be easier to just add a camera to that client instead of trying to disable all the other players cameras.. I can't seam to add anything with the AddCompoment (as far a a client).
So I check isowner in the client a million times and send an RPC call, which only modifies a variable, never the network object, but when the clientRPC comes back isowner is never true. Why would isowner get changed?? :/ anybody else have this issue?
debugging the clients POV of the networkmanager, btw
Hello, I am doing peer to peer multiplayer via deterministic lockstep.
I have a deterministic ball collision simulation.
I keep them in sync via lockstep. (I mean I am waiting for all the players inputs before stepping the simulation)
The player shoots balls in my game, and if I keep doing the regular lockstep way, there will have to be some latency before the player can see the recently shot ball.
I am looking for a good way to eliminate the latency to shooting balls.
Any ideas?
anyone know if upgrading to a higher bandwidth service from my ISP will lessen the impact my neighbor's usage has on my service during peak hours?
Hey, just wondering. I need to reference a transform other than itself. How can I do that inside a ServerRPC?
how do I make it so clients can change the network variables of their own player but are unable to do so for server-owned or other player-owned objects
basically
the player is only allowed to speak in variables
how do?
and as a side question
can clients forge rpcs that are unknown to the server to cheat?
No? RPC's are literally saying "Heyy, server, can you run this piece of code for me?" and if the server doesn't recognize that code it won't runn it
kk thats kinda what i thought many thanks
so if i am making a competitive physics esport, what kind of RPC do I use to make sure that the physics calculations are fair for both players?
IDK, I'm pretty much a noob at networking aswell. To answer the other person's question I just repeated what I heard in tutorials.
any brilliant minds know the answer to my q?
Physics would be handled by the server in that case. Then replicated out to the clients.
the serverRPC does that, right?
Speaking of server-side physics, I'm having this weird issue with jumping where you can jump while in the air, only jumps by a very small amount and gravity is super slow. It works fine on the singleplayer version of the scripts, so I'm not sure what the issue is. Could you take a look at the scripts?
Network/server side: https://hatebin.com/wputwqwtzw
Single player: https://hatebin.com/vlqawpjaqm
Almost the exact same, but with the movement code in a ServerRPC in the network script.
Business tier will usually get you out of bandwidth sharing but only your ISP can answer that
Anyone know anything?
Server movement
Tyty
god i wish there was more support for client restrictions in unity lmao
How can I do x piece of code whenever a client connects/disconnects? Also, when a client disconnects, will their player prefab be destroyed? And if they are disconnected non-gracefully(for example alt-f4) will their prefab still be deleted?
what networking are u using
Just netcode for gameobjects. Nothing special. Most of the calculations are server-side as its a competitive fps.
There are Onclientconnected/Onclientconnected callbacks
https://docs-multiplayer.unity3d.com/netcode/current/components/networkmanager#connection-notification-manager-example
The NetworkManager is a required Netcode for GameObjects (Netcode) component that has all of your project's netcode related settings. Think of it as the "central netcode hub" for your netcode enabled project.
how do I make it so clients can change the network variables of their own player but are unable to do so for server-owned or other player-owned objects
basically
the player is only allowed to speak in variables
how do?
Owner Write permissions
https://docs-multiplayer.unity3d.com/netcode/current/basics/networkvariable#write-permissions
Introduction
I have a TCPClient program build that works with an existing third-party server, and I have been attempting to instead swap over to connecting to my own TCPListener server running in Unity. The client seems to be correctly initiating the connection and the server seems to be accepting the connection, but the client's 'on connect' callback never fires. Is there something I'm missing?
server
void Start()
{
_instance = this;
Client = new TcpClient();
Server = new TcpListener(IPAddress.Loopback, 1001);
Server.Start();
Server.BeginAcceptTcpClient(new AsyncCallback(onClientConnect), Server);
networkThread = new Thread(new ThreadStart(Listen));
networkThread.IsBackground = true;
networkThread.Start();
}
private static void onClientConnect(IAsyncResult ar)
{
try
{
TcpListener server = (TcpListener)ar.AsyncState;
Client = server.EndAcceptTcpClient(ar);
Connection = Client.GetStream();
Debug.Log("Client connected!");
}
catch(Exception e)
{
Debug.Log(e);
}
}
client
...
Client.BeginConnect(Dns.GetHostAddresses(ServerAddress), ServerPort, new AsyncCallback(onConnect), Client);
}
private void onConnect(IAsyncResult result)
{
Connection = Client.GetStream();
networkThread = new Thread(new ThreadStart(ReadTCPConnection));
networkThread.IsBackground = true;
networkThread.Start();
onLoginConnect.Invoke();
}
The server prints out my Log line, and the thread for listening to the connection passes through an if(Client.Connected) check afterwards, but on the client the onClientConnect never fires 
What makes it more confusing for me is that the client works fine as-is on the third party server
Turns out that swapping to a localhost connection caused an issue with a Unity function being called before the thread context could switch? I ended up just tossing it into a UnityMainThreadDispatcher.Instance().Enqueue() and everything is working as expected. This thread thing was literal non-issue when connecting to the third-party server... strange.
Hi, I want to know how IsOwner works. Client is the owner pf the player that network manager instantiate only? or that gameobject is also owned by server?
NetworkManager.Singleton.OnClientConnectedCallback += (ulong id) => DisableOtherCameras("Player");
NetworkManager.Singleton.OnClientDisconnectCallback += (ulong id) => DisableOtherCameras("Player");
void DisableOtherCameras(string tag)
{
foreach (GameObject player in GameObject.FindGameObjectsWithTag(tag))
{
Camera playerCam = player.GetComponentInChildren<Camera>();
Debug.Log($"is playerCam null {playerCam == null}");
if (playerCam != null && playerCam != selfCamera)
{
playerCam.gameObject.SetActive(false);
}
}
}
So I have this piece of code, and it works. A little too well. Currently, whenever someone connects/disconnects, all the cameras other than the one of the player gets disabled. And that's fine, that's what I want. Except I just want it to do it locally, not globally as it is doing now. I don't want them to get disabled across the network, as that breaks things for all players. Alternatively, is there a way to set what camera it should render to the screen?
Question about Unitys Netcode, do i have to use unitys paid relay service if i use netcode or can i handle the relay stuff over steam for free ?
Well Steam relay is free at point of use, but to put a game on Steam is ÂŁ100
yes but once 100$ is far cheaper then unitys relay service or photons ripoff prices
I notice you deleted your Photon rant, probably smart of you to do so
Your baseless unsubstantiated claims? No
ive just calmed down im not going into that
Is there a way to have a null value in a network variable?
I basically want a pointer to a client
but some times I don't want it to point to any client
so youre not forced to use unitys relay system if youre using netcode
No, and there is a Steam transport for NGO
currently I'm storing a ulong in a network variable, which means I can't store a negative value to represent not pointing to a client either 
I suppose ulong.MaxValue would work
It'd be difficult to get there just by clients joining, so it should be aight
yeah
I plan to have a cap of 10 players too lol
so I'd be very surprised if that ever caused a problem
I'm guessing ulong.minValue would just be 0
Yes
Thank you very much
i will look into mirror and NGO
and see who has more feature out of the box i need, i think i had a stroke when writing that
I will look into both and see which one has more of the features i need right out of the box
I think NGO might be better regarding peer to peer, with host migration and late joining
Mirror supports none of both out the box, just offers work arounds in their docs
Neither support host migration out of the box, but both can do all that?
what ngo has even documentation for that https://docs.unity.com/relay/en/manual/host-migration
That is Relay, not NGO
oh
They are different products
yeah ive spotted that
so yeah both need work arounds
i think mirror might be the better choice then
just cuz its more established and had more people work with it, there might be more help out there for mirror
Hi. Whats more beginner friedly/easier to pick up? Photon Fusion, Photon Pun, Fishnet or Netcode for game objects? What would you recommend for someone tryna make a small multiplayer game to mess around in with some friends?
the easiest is Photon Fusion/Pun, if you wont exceed 20 people its completly free
after that its very expensive for what it does
20CCU, which is a tonne of players
not really
Oh it is
i have more then 20 friends lol
Who are all going to play at the same time?
Yeah I've heard about that. Not planning to exceed 20 ppl. Thanks.
yes cuz thats possible, very easily
Cloud cuckoo land mate
Well just tell some of them to piss off for the time being (:
we reach 30+ players on our ttt server sometimes and 17-18 out of them are close friends
GMod is far more popular than your game
so yeah we have a ritual of playing games together
so yeah i would have about 20 ccu even in the dev time cuz they are hella interested in my game
cuz im mad enough to make a multiplayer game lol
i mean its over 20 ccu but only occasionally
most of the time if its just ramdoms in ttt it hangs about 8-12 players
yeah i guessed so, but you never know if my game hits big lol
i dont either, but since its based on a relativly liked game with an unique concept that was only killed by greed i have my hopes up to get atleast 200-400ccu from the playerbase of the old game thats still waiting for something to happen (people promised to make remakes but didnt, cuz they stole assets and got sued lol)
The 20 CCU subscription is for development. You can't use this to publish a game to the general public.
Which doesnt make it better btw
photon is very costly for a managed peer to peer service
id rather look into mirror and nat punching if you go public
The 100 CCU subscription is a one time fee for a year and you can get one quite cheap in most Asset Store sales (via PUN 2 Plus, e.g.).
if you can get it for cheap that is, otherwise you have to pay 95$ for a game for you and your friends
wich is like nah
for a public game its like fine i guess
but then if you go over 100ccu youre already stuck to photon and then they open their pockets with 125$ a month
Yes, not arguing that it's maybe not fitting for all cases.
yeah if you plan to go "bigger", photon quickly becomes very pricey for just beeing a managed p2p relay
even unitys relay service is cheaper
Relay is not the same, you do realize that?
it kinda is, it relays the peer to peer instances over the unity network
photon does the same with pun/fusion
No.
yes.
Fusion is doing a lot more.
what exactly
if you talking about any of the features on the front page with the lag stuff or client prediction, thats only for the server based fusion, the enterprise solution lol
I guess you know but don't care. Which is fine. You don't need any of what it does, so .. don't use it.
It really depends on what you need / want out of a solution.
the normal shared/premium fusion only uses a relay and its peer 2 peer
Oh, is it?
I have to talk to my colleagues then.
i mean yes
sadly lol
its just p2p over a relay and they charge loads for it
Well that's simply untrue
Bro did you even look at that picture
they even tell it
its peer 2 peer with a relay server
there cant be more to it lol, thats the way their stuff works, theres no secret in relays or like anything else
its peer 2 peer with a relay
You're paying for the other features
This is a misunderstanding.
We / Photon just doesn't do hosting. You can export server builds and run them on any machine you like. But Photon doesn't do that.
If you want that, Unity's relay and others alike are not going to help either.
why do you advertise it like that then
If you are after hosting of dedicated servers .. you'd need some machine, not a relay.
why do you advertise it like that then
And where do we do that?
right on the start page
you advertise all kind of stuff thats only possible on server-client
None of that says: We host that for you?
Fusion is doing that but in a host / server executable.
i see that differently
And we are back to: Ok, I won't argue. Fine.
everything looks like youre buying a all in one package
so youre paying for something you could have
lol
Ok, yes, the latter screenshot is easy to misunderstand, I agree.
everything combined the first advertisement page in combination with the photon cloud pricing
yeah its very misleading imo
Sorry about that.
well are you responsible for that ? Apparently, you wrote "We / Photon"
Something that's hard to convey on marketing pages is this: Fusion does everything that is advertised. The matchmaking and relay are online services (always) but the Simulation, Prediction, etc is something that runs in-Unity and we don't host that. Players can run it (very easily) on their machines (hosting the game) or you'd actually need someone to host Unity instances and you'd run dedicated servers.
I will try to convince my colleagues to make this more clear at more places (it is somewhere in the docs).
Thanks for the feedback.
Well, I am working on Photon.
Yeah i was very upset by the fact that it ended up beeing peer 2 peer when you talk about lag compensation / client side prediction which normally uses a server-client system and then one of your discord people tells me its all peer 2 peer with a relay server.
And I think Luke and you just had a misunderstanding. You don't have to run dedicated servers or Enterprise servers. That's absolutely not needed.
You can run a Unity build as server (dedicated or whatever).
Especially talking that photon fusion gets very pricey very quickly for the fact that it doesnt even host servers for the games
but i guess you have to pay for the service as a whole
you get way easier networking setup and buch of nice features out of the box, but you have to pay for it
I think what Luke wanted to say is that players connect directly to the Host / Server. This is normal and even if you paid someone to host your server instances, the clients would still attempt to connect directly.
Direct connections are often called peer to peer but that's sloppy at best, if you use a host / server, which is in fact the center of all connections and entirely authoritative.
but they do connect to one player beeing the host, not an actual server
so its as insecure as usual peer 2 peer
witch cheaters, luke even confirmed that
What is an actual server?
what
You mean a dedicated server?
yes
cuz an player acting like a server isnt like an actual server, just a host in that moment
A machine that you run...
That is a dedicated server. It is also a server you could run at someone's home or at a player. So ...
well yes
Yes, ok.
but your system uses hosts
not dedicated servers
unless i buy an extra ded server
Fusion can use one or the other.
If needs be, run it on machines dedicated for that.
If security needs that, it's possible.
But yes, we don't host that for the price of the subscription. True. And as said: I have to agree that it's not clear on the pages you quote, so .. point taken.
You can host Fusion instances dedicated on basically all services that support Unity instances.
You could even do a mix: Some hosted (by players) and some games are dedicated.
Then, to make this clear too: Unity Relay, Epic Online Services or Steam also don't host any of your builds, afaik.
well yeah its that obv, but its still overpriced imo if you go over 100CCU its 125$+ a month for a system to build your game on, basically a license to use their product, i think just the 95$ a year for all CCU's would be more fair since they arent hosting servers or anything, just the relay server
100CCU is a tonne of players, so if you have that many sales you can afford to pay
well but epic/steam also dont charge you for their relay services
unity does too, so i already had that put aside
As said: We may be too expensive for what you need / want. As far as real customers are concerned, none went bankrupt because of our fees and most are happy we are constantly working on all the involved systems to improve.
And we don't just relay when it's absolutely necessary. There is permanently a connection to find players, fill rooms, etc.
100 players is like not much even zula some shit csgo ripoff has a monthly ccu of 300
It's also $7.99
what, zula is free to play
Unless you have a ritual to play the game on a specific time, hitting 300 CCU is in fact quite a bit.
were expecting on hitting 300 ccu as a base and having 1000-1500 on the "gaming times".
Those are calcualtions based on the still active players from the old game that were "remaking" and expected new players from steam and ads
Very bold projection...
with photon we would have to buy the 250$ a month thing, which is highly expensive for a free to play game
not bold for a free to play game with a userbase thats already there and planned ads
free to play games have a higher player count anyways
Bold of you to assume they'll come to your game and stay
that has nothing to do with ccu, if they want to play and cant cuz our ccu are capped
well
there they go play something else
Players playing has nothing to do with CCU, you heard it here
it has ?
The CCU are not capped for the monthly-paid plans. You can decide if you want to cap it but it's not capped by default.
just not about the ones leaving, but the ones that are trying the game or playing it
who cares if they stay if the ccu is still exploding at the gaming time from people wanting to try it out
the problem is not the mau, but the burst ccu (1-2 hours i guess)
in the fineprint it says after the first burst you have 48 hours to upgrade your plan or we will most likely cap you at your limit
Honestly, if your CCU explodes, you have luxury problems. Hosting dedicated Unity instances for every f2p player will be a bigger problem than anything else if you can't run a lot of instances on few machines.
"After your first burst you have 48 hours to upgrade your subscription plan before we, subject to our sole discretion, may cap your number of CCU to the agreed number."
Afaik, we never had to do that. But yes, in theory, this is what we could have to do.
so it is capped but you may exceed it once so you can go a step bigger
Usually, we figure out a plan with the developers.
Having too many players is rarely a problem.
If you can't monetize the game or don't want to, yes. But then do yourself a favor and don't run dedicated machines.
if i constanly run at 200ccu but in the high times i run at 2000ccu for like 2 hours, would that be when you had to cap my ccu ?
if i bought the 500cuu package
We'd cap your CCUs if your max is 2000 and you pay for 200. Yes, sure.
i do want to monetize, but not really heavily and i fear that it might not collect the money i pay for photon
so i end up on a net negative
Let's cut this short: The pricing doesn't fit for your game.
I am not happy about that but can't help either. It is what it is.
I only wanted to clarify what we do and what we don't and I learned that our marketing and pricing pages are not good enough.
Do look into the pricing of actual hosting. Make sure to understand the traffic and performance your game will need when running a dedicated server, because that's going to define your costs.
Fusion might still be cost effective for you if you are able to run more instances on fewer machines with less traffic paid for but .. that's just a hunch and may depend on what you do.
im still looking into photon vs mirror with steamworks
you explained a lot of stuff i seemed to have misunderstood
yet the biggest question stays if i will be able to afford the price with the few microtransactions my game will have
Yes, that's a tricky question. Always.
If you don't mind, our advice (pretty much everyone at Photon thinks like this) is: make a fun game first.
You can make it player hosted (no matter which solution you choose) and figure out how it's being played. You invest time already. If some tool will save you time and costs a reasonable amount, get it. This includes but is surely not limited to a one-time subscription for 100 CCUs, should you use Photon.
If your game is successful, there is usually some way to make the next steps. If it's not played by anyone except friends, then this is what it is.
Man wait till you find out people are selling 3D models in the asset store when you could just learn blender and make them yourself.
Turns out you can probably do most things yourself for free. You pay for someone else to do em because ideally your time is better spent elsewhere. Yeah, you can set up a p2p networking service for your game for free, but if you are making the hourly rate for game developers it's gonna cost you a whole hell of a lot more than $125 a month to maintain
If it's not in your budget then that's fine, but a lot of people just don't want to deal with that at all, and if a sub-four-digit expense on network infrastructure is outside of your budget, chances are slim you'd even need to pay in the first place.
I might have miscalculated if 500 ccu is like 5000dau, then thats 50k different useres monthly aprx, that should easily run in 165$ from our micro transactions to afford photon fusion + chat
CCU * 20 ~= DAU
DAU * 20 ~= MAU
40k MAU are often not more than 100 CCU.
Of course, if you run tournaments, events or release updates the calculation may be off.
Im mostly speculating for the release window
Where those numbers arent really accurate
There its mostly ccu*4 = dau from what i have seen, since ccu peaks at release windows, but its completly unpredicable what the mau is gonna be
Thats my problem
How would i handle the masses on release if i have like normally 80-100ccu afterwards, but on release i have 5000ccu cuz marketing worked and ppl want to try out the game theiy heard about since its free
But like only 1% of those actually buys something thats in the end maybe 300$
I think i like the mirror route more tho since its not pressuring me to earn a certain amount of money to keep the networking alive
Self sustaining to say
Either by beeing completly "free" (besides my time) to run or by having micro transactions
But then again if i use the 1% route its still 20000mau = 200 purchases = atleast 200*4 = 800âŹ
Wich i can afford the 165$ with
Give both networking solutions a try.
See if you like either solution better or not. Keep in mind that the first steps can be confusing and don't guarantee you can reach the goal in the end. Just as example: PUN 2 has a tendency to become more complex to reach the best results in the end, while Fusion is a bit more complex initially but should not surprise you later on (to just talk about 2 solutions I know somewhat).
You now know that a 100 CCU one time subscription can get you a long way in terms of MAU. If needs be, you can cut the cost to this price point. So you can decide if you like the solution and if it's worth it to you.
Good luck. I'll be off.