#archived-networking
1 messages · Page 7 of 1
Ah, that make sense
Another problem is, OnPlayerJoined doesnt get called on server either on host
callbacks registered yet?
join the photon server, the support may be able to help u
runner.addCallbacks()
shouldnt the callback is automatically registered by the runner?
INetworkRunnerCallbacks, no. the other should be but not sure
the callback get's called when the host itself entering the room
but not when client joined the room
is it INetworkRunnerCallbacks or IPlayerJoined ?
INetworkRunnerCallbacks
public class Runner : MonoBehaviour, INetworkRunnerCallbacks
{
public void OnPlayerJoined(NetworkRunner runner, PlayerRef player) => Debug.Log("Player Joined");
public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) => Debug.Log("Player Left");
}```
how do you register the callbacks?
this btw
Fusion Customer Service?
photon discord server
good question, how should I?
the callback works when host joined btw
Runner.AddCallbacks(this)
add before the session stars
{
public void OnPlayerJoined(NetworkRunner runner, PlayerRef player) => Debug.Log("Player Joined");
public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) => Debug.Log("Player Left");
private void Start()
{
if (_runner == null)
{
_runner = gameObject.AddComponent<NetworkRunner>();
_runner.AddCallbacks(this);
_runner.ProvideInput = true;
Debug.Log("Runner initiated");
}
}
}```
it still not fired when client join btw
🤔 maybe it doesnt joined the correct room
Start is unity monobehaviour's Start btw
yes, it can be called after the OnPlayerJoined
Do you mean, that the runner can get destroyed somewhere then recreated again?
The runner Start is called before the player joined the session, so how could it get called after OnPlayerJoined? 🤔
wait.. were you loading other scene? or its the same scene
currently on the same scene..
I tried loading other scene but had no luck since only the server able to change scene
so rightnow, the room is in the same scene as the lobby
seriously, fusion needs better manual/tutorial. I never have the same problem with pun
show full code
which one, the runner or the lobby?
why the you name your behaviour "runner" ?
Good question, I'm not sure why I named it that, but I could rename it if you like
You can find the photon discord here
https://doc.photonengine.com/en-us/pun/current/getting-started/get-help
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
In NGO if I get component <Player> will that return all game objects on the server with that script? Or just that instance of the client? Or does being server or client change it’s effect?
No that's just a regular Unity thing. It gets the component on that specific game object. You might be thinking of FindObjectsOfType<>() That will find all objects currently loaded in the scene
Well what if I only want to find the component of a specific client with NGO
Netcode for Gameobjects' high level components, the RPC system, object spawning, and NetworkVariables all rely on there being at least two netcode components added to a GameObject:
For example, each player will have farms, but I only want the farms to affect the player who built them
For that I would spawn the farms with client ownership. then your farm script can check isOwner
Thank you, I’m prepping for my next title for when I publish my current on the first and trying to build the pseudocode in my brain
hey quick question, for my fps controller if i wanted to sync the vertical aiming of the client (based on a float value), would it be ok to use a NetworkVariable for that or is that too inefficient and expensive
i basically need to sync that value whenever the player aims, which is a lot. i tried a network transform but it didnt work since im using IK for my model and each spine bone would need to be synced
right now im using a network variable and it works fine, but im not sure if network variables are designed to be used that way
I'm pretty sure Network Transform uses network variables under the hood. I would have the IK target have the network transform. then the IK will just do its thing naturally
Anyone with experience in working with the Playfab SDK here?
Want to make a Facebook and account login possible for syncing with server databases and inviting friends to play with.
you can use the ClientAPI to log in client side, send the token over to the server, then use the serverAPI PlayFabServerAPI.AuthenticateSessionTicket to authenticate the user. so basically make a custom authenticator for playfab assuming youre using mirror/FN. is that what u mean?
Has anyone managed to get the official FPS controller working with Netcode fully.. My movements work perfectly but not the cameras for each individual user
You'll need to disable the camera on all remote players. When you spawn a player check isLocalPlayer then disable the camera on ones that aren't local
When a player joins a Steam lobby i would like it to change a number. Does anyone know how to see if a player joins a steam lobby?
Anyone have a 1st person multiplayer using photon that has a chat?
Hello, I have developed a game like Angry birds. The game is played on the internet(webgl) . My question is i want to add dedicated server for my game because of the security . What would you recommend for this? I searched mirror server but it seems difficult , how can i do this in the easiest way ?
How do I do that mate? what I have done is for each of my Player prefab there is a camera inside
it works if there is only 1 player if more join it gets weird up
Unity is only meant to have one main camera in the scene(unless you're doing some weird split screen thing) so any extra cameras will need to be disabled.
mhm Alright that makes sense
Does character control not work with network?
My character movement works as a Host but not as a Client
I am using client network transform
When I try to move my character using transform it works
but not character controller
character controller overrides the transform
so what should I use to make the server allow me to move?
disable to character controller on the remote players
How should I handle server authoritative variables such as player health points?
For example if I hit someone with a Ray cast and want to decrease its HP
what is the best networking solution for an mmo
If you're making an MMO surely you can do that kind of research yourself and come to your own conclusion
People be casually talking about making MMO’s
The best solution is the one your server team will build for you.
Are you concerned about validation? Otherwise you could trigger an ServerRPC on the client that gets hit and deduct the health.
hey,
im working on a lobby system for a networked game.
1 - I wonder if I could connect (.NET c#) with a database ? to store lobbies and list them on request
2 - if that is not possible, how reliable is a list of dictionaries to handle it ? ... what if 100,000s player were online at the same time, how reliable would that system be ?
also I have an old python based lobby listing system , I wonder if I could host both of them on the same ubuntu server
you can talk to a(any) database with c#, the question would rather be what kind of performance you need and to pick a DB accordingly (on disk, vs in-memory), what kind of robustness you need for the data (ACID or not) and whether or not you need scale (sharding, replication, consistency profile). If you don't need persistence, you can do it all without a database using data-structures of your choice, all the built-in data-structures in .NET perform very well under load and at scale, that is what they are made for. Whether the app you build from them is robust, depends on your decisions during development. Typically scaling of an app deals mostly with the nature of distributed architecture (wildly dynamic load, unreliability, consistency, resource congestion, security, ...) more than squeezing the most performance out of any individual component.
What is the best way for the client to get his angular velocity from the server when using networked rigidbodies? Currently I'm using a server rpc to set a networked variable, but I feel like this isn't a very good way to be doing it.
Can Unity Netcode for GameObjects handle ~10 players with simulated rigidbodies, animations etc. Evaluating network solutions for a 3D multiplayer shooter (doesn't need extreme accuracy like an FPS would)
whether or not it can "handle" it depends in how you implement your synchronization, the server hardware and network between clients and server. It can certainly update 10 client character transforms and a couple of animation parameters on a typical gaming PC with a decent internet connection.
Synchronization in terms of server tick rate and amount of data we're sending over the wire?
And the second question I have is more related to best practice architecture, what's the best way a dedicated server build can communicate with our API? Just send http requests directly from the server? Maybe inject a socket connection?
what does the API represent?
You can set the tick rate to whatever in the network manager. and it will send whatever you have serialized as a network variable
it's just our nodejs API that interfaces with player data, clan data etc
if you are planning to release on Steam, they have built in matchmaking and lobbies, if that helps: https://partner.steamgames.com/doc/features/multiplayer/matchmaking
yes but Im aiming for multiplatform so I cant use it unfortunately :S
assuming by nodeJS api you mean a HTTP API for CRUD of persistent player data / matchmaking / lobby, then yes, you'd use HTTP, you'd just make sure that access to this API is relatively infrequent to prevent any degradation of the realtime sync.
Hi, I keep getting this error. The weird part is that it works in 1 scene but not in another. [Netcode] Deferred messages were received for a trigger of type OnSpawn with key 19, but that trigger was not received within within 1 second(s).
google isnt really clear on this topic so any help would be apreciated
I've seen this happen if there are a lot of network objects getting spawned at the same time
Ill check it out
cool makes sense! yeah, another thought would be to just fire off events and process them elsewhere so we can have like MatchStarted, MatchEnded etc
ty!
this doesnt seem to be the case, any other ideas?
It could be the new scene taking a long time to load.
and is there a fix for that?
make smaller scenes? Load them additively
guys, how can i fix this in photon fusion ? controller only work on host
I have a game working but have to set up the IP to some laptop and it is inconvenient to demo. I had a free demo of Google Cloud in which it worked to have a dedicated server running all the time that the game just automatically connects to as the IP do not change.
Wanted to ask if there is a method of just having a server with like maybe max 20 players?
So that I don't have to demo it with a different IP each time.
Like resources where I can just run on some Virtual Machine or some dedicated IP for this? I am not sure what the method would be. I just can't demo with the LAN method much anymore because it takes too long to teach
Like I have to teach the players how to connect to the IP and enter the address and such. Opposed to games like Valorant which I assume just have an IP address hardcoded to some larger server farm or something
(I only need a server that runs like up to 20 players or something)
photon pun
@compact fox Sounds like you could use some free dynamic DNS service if you just need to deal with the IP changing.
I would just run the server through a relay service. Either unity's, steam's, or epic's. Once you're closer to going live you switch to a dedicated server.
I'm trying to test out some multiplayer fps ideas but I'm running into an issue where whenever the client connects, the host's view takes on the client's perspective, anyone know why this is happening?
I'm using the unity networking framework
Disable the cameras on non-local-player objects or have only the local player object grab the main camera
Hi a bit of a weird question, I got a few scenes that didnt work I copied them fully to new scenes and everything works. Is there something like a netwerk reset or something you need to do for older scenes or? It works so I can continue but this doesnt make any sense
What didn't work? What was the error message?
[Netcode] Deferred messages were received for a trigger of type OnSpawn with key 19, but that trigger was not received within within 1 second(s).
this one
it were just some toggles to enable disable gameobjects
how do I get all cameras in the scene from the player object? and the way this is set up is there is no main camera yet, but each player has its own camera
you just answered your own question
Using Unity Netcode for Gameobjects, I added a screen that shows my playercount. This turned the component into a NetworkBehaviour, which it wasn't before. Now, when connecting, my component increases 60% in size because of this, because it syncs the size with the client. if a build runs as 1280x720, my editor will appear like this to sync it. How do I disable this?
The right variant is what it's supposed to look like, but because of the resolution difference, the left size scales upwards for some reason.
I understand that the UI of the host is synced with all clients, but I don't need that here, since I just require the current player count to be updated.
When is a project ready for "Unity Relay Services"? I was going to just throw the game on there now but realize I haven't really finished all the code for the Client-Server LAN interactions. Currently there is no real win or lose state and no lobbies or main menu. I am modeling it sort of off of Valorant kinda.
The game is currently networked and you can interact and PvP, but like the actual game itself isn't that polished and doesn't have like all the game loops done.
(Basically, I assume the game should work on LAN before I decide to grab some dedicated server for it. My main issue currently is that I cannot demo it unless I give all players some quick lesson on like IPs and how to connect to LAN.)
It will be much easier to demo once I have a dedicated server, but I feel I should first make the core game loops polished and exist first.
Does the UI need to be a network behavior? You can put a player count network variable somewhere else and have it's OnValueChanged update the UI
I setup a relay and lobby quick join before I even had a player moving around
Ok. So the lobby or some sort of dedicated server demo should probably be first.
Dedicated server is just the hardware it's running on. That can be your laptop or hosted in the cloud. Both can spin up relay and host a lobby
Yeah, my laptop can't handle 2 people playing FPS or even Valorant.
I can do LAN but the demos requiring me to teach people to enter IP and connect and such
Is the new unity netcode worth using over using Mirror?
depends on what your needs are
True. I can actually change this and get the networkmanager directly, fixing my issue. I'm wondering why an UI component behaves like this in the first place, and if it is possible to avoid this issue.
This option exists, but it did not change anything for me when I disabled it.
I was wrong, my solution is not possible.
So I have to create a whole seperate gameobject just to sync it, because the UI scales weirdly when I turn it into a NetworkBehaviour? Welp
Alright so I moved anything related to the NetworkBehaviour into a seperate component that is invisible, and it now works.
I would still love to know if I can disable this syncing at all
So this
Probably a very simple question to answer for someone who is familiar with the new netcode, but what is the netcode equivalent of Mirrors NetworkIdentity?
A network object on UI turns it into an object to be synced by the network manager. When it spawns the UI will have the settings it had on the host. I'm pretty sure unchecking scene management on the network manager stops prefab syncing
It's network object
Earlier I would pass the NetworkIdentity of a gameobject as an argument for certain rpc calls, is it possible to just replace this with NetworkObject or do I need to do a roundabout way of passing the NetworkObjectId instead?
Network object is not serializable. If it's been spawned already then you can send a network object reference
So gonna have to rewrite some stuff I guess. It was for the purpose of parenting a spawned gameobject to a previously spawned gameobject. I'll have to pass the network object reference instead?
There is an implicit conversion.
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/serialization/networkobject-serialization
Brief explanation on using NetworkObject & NetworkBehaviour in Network for GameObjects
But also parenting network objects gets a bit complicated. I've been using physics fixed joint instead of messing around with that
So for equipment you would rather have it all handled offline through rpc calls instead of having the objects networked? I guess that sounds smarter than what I have been doing tbh lol
I see that I can use NetworkObjectReference.TryGet() to get the NetworkObject itself if it comes to that I guess
I'm pretty sure you can also just cast it back to a networkobject if you're certain it hasn't been despawned or whatever
But this stops all of them I assume?
And with prefab syncing you mean more than just the UI syncing I suppose?
In scene network objects get treated like is was part of the level. Like static geometry
If you have not already read the Using NetworkSceneManager section, it is highly recommended to do so before proceeding.
Had a few odd questions about Networking with Unity Relay.
What if suddenly I get more than 50 concurrent users?
Can a user launch some sort of attack that causes many bots to connect at once causing me to be charged lots for data usage and such?
And also wanted to ask about how public this will be? Mainly just worried of the ways people might make me pay money for the data and user amount charges? (And how quick I can cancel if something weird arises?)
Just sort of thinking about managing budget for this. Along with what to do for generating revenue. This is just portfolio material for college and career sort of based on Valorant.
You start getting charged after the 51st concurrent user connects. Bots would have to get past Unity Authentication.
Can Mirror Code be used with Unity Relay? I currently did my LAN in Mirror. I am now working on trying to set up a simple lobby with Relay. Also wanted to ask if there are any really good simple easy to follow videos recommended? I found like a handful and wondering if any in particular are clearer or better. (Or maybe if there is just template example code that already exists, and I can just copy paste the Mirror Code attaching it to it?)
I'm also wondering the same. It seems that https://unity.com/products/relay and https://support.unity.com/hc/en-us/articles/4410136449812-How-much-does-the-Relay-service-cost- claim that they use the average number of players per month.
You are correct, I was thinking of vivox that uses peak concurrent users. Relay is free for an avg 50 concurrent users per month. So sudden spikes won't effect you
Thanks, that's good to know
Not out of the box. You would need to get a Unity Relay Transport for Mirror. Which I don't think exists.
Mirror has an integration with Epic Relay, which is hosted for you for free. See Mirror Discord, "epic" channel.
Same to you as well ^
Is it really hosted by Valve? Interesting dynamic 😄
I guess it is more just a 'virtual machine' or something to run the server from 24/7?
Currently my game works completely fine with "LAN" if I run use my laptop and have people connect to it.
It also works when people are on different wifi and is like over the internet too.
I had the free month of Google Cloud which was an easy solution because I just ran a virtual machine 24/7 that you connected to because my game hardcoded IP and would always just connect to the IP of that virtual machine.
I guess one solution is to just buy a new laptop or virtual machine or something that can hold an IP that never changes?
I feel Unity relay might be too complicated for what I'm trying. I guess I am just looking to get a IP address that doesn't change so that instead of having to type in the IP each type it just automatically connects to that address. A virtual machine works but those cost like 35$ a month or something. There should probably exist one that is free?
I dunno how IP Address works anyways, the IP of a laptop changes and it is also hard to keep a laptop on 24/7, while virtual machines can easily be online 24/7.
I'm having an issue where when the player trys to switch weapons the model only switches with the local player but all the other clients don't see the change happen
You'll need to send a clientRPC to let the other clients know of the switch
it is still not working
the weapons are children of the player and thus have no network object on them
Guys how can i play animations to other players with photon
i have a ui
when i click a button i wanna play a animation with photon
oof - one too many brandy alexanders this morning - no idea what I was thinking there 😄
Does anyone know if there are any popular games made with Mirror?
aws has a free year of ec2 virtual machine. it has 30 gb of ram and like 1 vCPU iirc
Where can I learn about Netcode networking functions and etc? So I can learn more about unity networking overall.. Also- does anyone have a basic template or like something I can like "read/learn" with ?
UNet is deprecated and has been for years, Unity’s new solution is Netcode for GameObjects
Well do you know where I can find/learn about some Netcode stuff? Like the basic functions, statements, variables, and etc.. And definitions of what things are? I'm new to networking
There is a pretty good CodeMonkey YouTube tutorial called “Complete Unity multiplayer tutorial (netcode for game objects)” which is a really decent starting point.
Thank you! will look into it.
You can find the docs here
https://docs-multiplayer.unity3d.com/netcode/current/about/index.html
Learn more about the available APIs for Unity Multiplayer Networking, including Netcode for GameObjects and Transport.
Hello, I created a game scene with netcode, I would like to find ( a guide maybe ) a way to upload the server build in a linux server and run the game in this server. I f one of you have a clue you can share , thank you and happy hollidays
In the build settings you choose the Dedicated Server platform and select the Linux option there
Hi. One question, with steamworks what is the actual difference between a lobby and a server? Because when I try to get all the lobbies I can't get the name but when I try to get the servers I don't know how to set the name of the current one😅
@sharp axle I did it, but don't know how to upload the build and how can I run this from my dedicated server
That depends on your hosting service. If its just an AWS or Azure server then you can just FTP it and then run the executable
Hello fellow gamedevs! I'm adding a networking functionality for the first time and even though I have a somewhat OK understanding of what networking does and how it does it, I have a few questions.
For starter I'm working on P2P multiplayer with 1 host and 1-3 clients. For the moment I don't really mind anti-cheating or even server correction/client prediction, I'm just trying to get something working with a clean architecture that I can easily modify later.
I've currently solved all the issues I had with the serialization/compression and with the transport layer, and basically all that's still causing me issues it the application logic, i.e. the code architecture, when to do what, which pitfalls to avoid.
Basically I want the host to be authoritative over the clients, which makes me think that the host holds a schema of the game state (i.e. the complete data state of the current lobby/mission), and it should be possible to completely rebuild the lobby/mission from the schema only. Then, clients send actions to the host, which processes them, and then broadcast "patches" to the clients, allowing them to update their schema. So at the connection each client gets the complete schema, and then all the "important" data is sent through reliable packets that only contain deltas of the schema, basically. The other stuff that's less important (for example the enemies behavior) is sent through unreliable packets.
But even with that in mind I'm struggling to see how to properly build an architecture that wouldn't be a nightmare to maintain.
I've look online a lot and found some interesting articles, but most of these resources didn't go enough in detail in my opinion.
If you have anything to share I'd gladly accept your knowledge! Also my main idea might be completely garbage, and if it is please let me know 😉
Honestly, I would not stress about maintainability of your first multiplayer game. Its going to be a mess and you are not going to want to bring that mess into any future game.
That said. your architecture is going to vary wildly depending on your game's genre. Fighting games and card games are going to share almost nothing in common.
Thanks for the answer 🙂
I'm not looking for something very "frame-dependent" such as fighting game, so no rollback or anything. For now I just want solid P2P (well, more like "dynamic-host-based authoritative P2P", meaning that there is 1 host and 1-3 clients but if the host drops out it's possible for a client to transform into a new host - but this isn't the main point now), with "good enough" transport time. Basically I want a good foundation on which I can then work to implement things such as client prediction/host correction. When the transport time becomes an issue I'll deal with that. But I do want to have "real-time" P2P so not a thing like lockstep P2P.
In short I'm looking for a clean way to decouple as much as possible the networking stuff from the game stuff, while trying to not create too much redundancy because of the P2P nature of the networking (meaning that most entities might end up having two version, one host-side and one client-side).
But most articles I find do not actually show any diagram or any code regarding to the actual processing loop of such networking.
I just took a look at Game Engine Architecture and it barely says anything regarding networking unfortunately (3 pages for both client/server and P2P).
I already have code that makes the multiplayer works, with a lobby system and some packet definitions/handling for notifying the host and broadcasting data to clients, but it's already a mess and the game has almost 0 feature 🥲
Also my current code is not very resilient, i.e. some things can go wrong because I don't have very sound interfaces for packets management
I feel you. Your approach is also going to depend heavily on which networking framework you using. If you are custom coding everything in raw sockets, then go with God. You are not going find any help with that online.
No I'm not custom coding everything, I'm using a networking library and a serialization framework. The network library is LiteNetLib which seems pretty nice, acting as a thin layer over UDP. But it's still pretty low level which allows me to send whatever I want in pretty much any way. Do you have any framework in mind that eases the pains of working on networking?
I'm currently knee deep into Unity's Netcode for GameObjects. But photon and Mirror all work similarly. You serialize structs and you can sync them as network variables or send them as RPC parameters. There is a Custom Message Manager that lets you just blind fire messages at clients if you don't want to deal with network objects.
I see 🙂 This might be good enough for my game since it's only 4 players anyway. I don't really want to integrate Netcode because if I can avoid something made by Unity I'll avoid it lol
I mean it's a good opportunity to learn anyway 👍
I'll try to find some more resources on the subject
Does Photon Quantum support self hosting? I can only find documentation referring to self hosting and fusion.
One question, does anyone know why when requesting to get the lobby list for a steam game I get different results than others please?
has anyone done projectile with data buffer approach in photon fusion I dont understand their sample why all projectiles share one gigantic struct where is that struct even used to run projectile I want to know what I need for bare bones implementation not a whole system bruh
You can find the photon discord here.
https://doc.photonengine.com/en-us/pun/current/getting-started/get-help
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
yeah you would rather win a lottery than get answer there
ty tho
What do you guys think is the best networking solution
Or what networking solutions are better than the rest
Entirely depends on your project
in the script on trigger ive made it so the player disconnects but i want them to join or create a room but it doesnt work anyone have any ideas upon fixing it?
Use an RPC
im using PUN 2, i wanted to ask if 3 photon views(1 on gun, 1 for movement, 1 for wepon switch) will have a big impact on my performance
this is something i did
public AudioSource footstepAudio;
if (Input.GetKey(KeyCode.W))
{
if (characterController.isGrounded && characterController.velocity.magnitude > 2 && footstepAudio.isPlaying == false)
{
photonView.RPC(nameof(FootstepEffects), RpcTarget.All);
}
}
[PunRPC]
void FootstepEffects()
{
footstepAudio.Play();
}
```also you gotta make sure to have the audio source set as a 3d sound
Thanks a lot, that did work
how can I call a specific Audio tho, or should I make a function for each audio?
im sure you can find an audiomanager tutorial online for handling that type of stuff. i'm not that experienced when it comes to programmer but i think brackey's has a tutorial
Thanks a lot
np
What is the cheapest or easiest way to just get something that runs 24/7 and has an IP address that does not change?
Mainly so when demoing my game, I do not need players to type in IP address, and instead can just hardcode the address to connect to. (It is awkward to spend like 20 minutes to get the IP and then have players type in to connect)
whats the difference between kcp and tcp?
KCP is a protocol built on top of UDP to make reliable messaging possible. TCP is a reliable protocol. KCP is considerably more suited/efficient for high frequency, connection based real-time networking at scale than TCP
I guess that would be to call your ISP and ask for a static IP address. The real solution to your problem is to use a Relay service. If you are just demoing then you are not hitting whatever free tier that service offers
Hi, everyone can you tell me how many type of protocols have in photons?
I tried looking up Unity Relay and it seemed too confusing for something simple I am trying to do. I am wondering if there is just something simple? Like the way I currently Demo is by having players enter in the IP into the client connecting button and then the game works. My goal is just to make that IP always the same so I can just hardcode it and not have to have people type it in each demo.
Also Unity Relay and Mirror Networking do not seem to be nicely compatibles.
Like one solution that I had a while ago was just to get a Virtual Machine or actual Laptop that would be dedicated to running the server 24/7 or something. I am living with my parents and cannot call ISP. My parents are also the type who will not let me touching anything. They are not STEM, they are in life insurance endorsement relating to social media connections job.
I guess the solution could just be to have a build and run myself that has the IP hardcoded and just change what it is hardcoded to for each build.
I guess even if I buy a server or a laptop it will not working because my parents often turn on and off the internet which changes the IP sometimes frequent.
How does Internet even work? I believe my parents have to pay like monthly for it. Is there an 'internet' thing I can buy that is just 'I own it' and can just run it 24/7. I am only looking to hold a maximum of like 10-20 people.
One of my friends in college had a Minecraft Server. They apparently 'found it lying in a tech dump' and then were able to just turn it on and off to hold the server, and the server had a consistently same IP.
They showed me their server on campus in their dorm was just a pile of like stuff?
Can network variables be static, and can they be modified/read outside of their script, like how you would a regular static variable.
im looking to learn how to create database save retrieve data from it in unity now I did try some php to test the waters, disgusting language
tho watched outdated series what are the options nowadays? Can I use database without going through php? 0 prior experience btw so something easier pls
I don't think they can be static themselves. You could have a static property that references the network variable Value.
There are a ton of database assets on the asset store. Most are for some variant of SQL
Sure can use DBs from C#. Generally you pick a DB and then grab a library for it for your language, like this one https://github.com/praeclarum/sqlite-net for SQLite.
Nice thanks 
anyone know if facepunch steamworks still has IP leaking issues?
Hello. Can anyone help?(About TCP/IP)
You only read half of what I said, ask an actual question
How i Can connect to my friends without (Lan/Local IP) TCP ?
TCP is a protocol, don't like it, use UDP
UDP Is better ?
UDP is different, it's unreliable but that means it's quicker. You can read about the differences online
UDP for Network , TCP for InterNetwork?
What?
I saw some YouTube video they made with TCP
TCP is just a protocol to send packets over the internet
If you don't want to use TCP, you can use UDP, if you don't want to play with sockets yourself use a higher level library
There are lots of solutions for multiplayer in Unity that do lots of the heavy lifting for you, like Mirror, Netcode for GameObjects and Photon products
Thanks for the help.
I have a TCP sample that connects to the internal network but doesn't connect with PUBLIC IP and this shows ERORR. I turned off the FIRE WALL and let it go.
You'll need to set up port forwarding to connect to a public IP
how ?
Can't help you there. it different for every router
Thanks for the help.
Hi,
I am looking into networking solutions. I am working on MOBA like Arena game:
Matchmaking => Fast paced arena dueling (2 to 10 players)
I found several solutions for Networking, I put a lot emphasis to open source code so if some peculiar situation comes I can dive deeper into the code. I found Mirror and reading through documentations I seem to like it.
Are there better solutions that I should be aware of and I missed?
How about hosting it?
I found solutions like Azure PlayFab, Edgegap, etc.
I find Orchestration important part of the solution as I think it's correct solution - "no resources wasted" if I understand it correctly.
What hosting is the best pricing wise and scaling up from ground zero, etc.?
(Putting emphasis on price as I am trying to stay as lean as possible)
Any advice or tips for beginner learning multiplayer game dev from zero?
(I have prior experience in software engineering, web and backend dev, small game dev, etc.)
Quantum is really suitable for MOBA games
You choices for frameworks come down to Photon, Mirror, Fishnet, and Unity's Netcode (for GameObjects or Entities). Differences primarily are out of the box features and pricing.
For backend services, I really like Playfab and Unity's Game Services is very much on par. They only thing it's missing a Friend system, and that I believe is in beta right now.
Learning from zero is the same advice as always, start small. Cut your scope in half. Then cut it in half again. Don't try to make a full game right at the beginning. Start with just connecting a client and host, then moving a cube around, then syncing variables and sending RPCs, then get animations syncing, ect.
if price is a concern, Photon Quantum is a no-go, you can use Mirror but you'd have to build a lot of stuff yourself (basically all the hard stuff you'd need to make it suitable to competitive multiplayer), the same is true for NGO, your only option to move fast rn is Photon Fusion, it has a free tier you can use for development. Beyond that the price is fair. You may stumble over FishNet which promises competitive features but they are also not free and there are no known projects that use it at scale.
On the hosting side, you can develop on PlayFab for free if you are careful and it can get expensive real fast, Unity's free tier is a bit more comfortable as you don't max out your free contingent as easily.
If you want to learn from scratch, prepare for a long journey and best not use any of the mid level frameworks, but learn from them and build a custom system on top of a suitable transport (ENet, KCP, Unity Transport, Photon Transport)
Note that syncing some variables and implementing RPCs to work is relatively easy, the problems and difficulty only appears when doing a real project (with complex state) and then again when you try to scale it and your entire network stack needs to be rewritten. It is impossible to forsee all the issues you will have, which is why it takes so long to become competent. Middlewares like NGO speed that process up a bit and eliminate a lot of gotchas that you'd have run into if you were to DIY it all. Nevertheless they come with their own issues based on their nature as generic solutions. Whatever these issues will be depends on your actual journey.
First of all, thank you all for the detailed replies - it helps a lot!
What should I be aware of if I want to make the multiplayer game "competitive"?
Some that come to my mind now are:
- Client-Side prediction & Server reconciliation
- Disconnect & Reconnecting behaviour
What else should I be thinking of? No need to go into details, keywords are enough 🙂
MIRROR 71.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
Does anyone know how to isolate a Boolean from other instances of the same script in different players, so only one instance of the bool changes
You could read up on congestion and what happens if you run multiple server instances on the same cpu/VM and NIC
What exactly are you trying to do? Each player is already its own instance and changing on one will not effect the others. Something like player input should be checking if it's the local player before applying changes.
can someone explain to me why I would need to use unitys Relay service? I am confused, does the lobby service and Netcode for gameobject service already cover joining players and then syncing data for all players across the network? so whats the point of Relay?
The Lobby Service is not meant for real time communications. Its only for syncing connection info. If you have a dedicated server connection then you have no need for the Relay. If connections are Player Hosted, however, then you will need to the Relay Service to get through NAT routers.
you cant do a dedicated server connection through only lobby correct? so that means I have to use relay
like im not using anything else except lobby and NGO, and im trying to figure out if i need to use relay
well im GOING to use NGO.
You can use Lobby to connect to your server.
Hi, whenever a player creates a lobby and another player opens the game after creating the lobby they don''t see it. How can I fix this?
public void CreateRoom()
{
if (string.IsNullOrWhiteSpace(creatingRooms.createInput.text)) return;
RoomOptions roomOptions = new RoomOptions(); //Create Room Options variable.
roomOptions.MaxPlayers = (byte) creatingRooms.maxPlayers;
PhotonNetwork.CreateRoom(creatingRooms.createInput.text, roomOptions, TypedLobby.Default);
Debug.Log("Creating Room " + creatingRooms.createInput.text + "...");
}
competitive: lag compensation, tick aligned simulation, precise collision
has anyone ever had this issue with netcode for go
i want to drop the player in the player prefab ,
I am creating an extremely simple game for me and my friends. Is it a good practice in Unity NGO to keep a central "game state"? As in, for example, a dictionary playerId -> playerName that is "shared"? Do people use other more sophisticated ways?
Hi. I am making a multiplayer game using NetCode with Relay and Lobby and I'm using AuthenticationService.Instance.SignInAnonymouslyAsync(); in the awake method to authenticate anonymously. Whenever I'm running the game on my computer, everything works as intended. But when I send a build of the game to my friend, he gets this error:
[Authentication]: Token has expired.
RequestFailedException: Failed to decode and verify access token.
I have been looking for a fix for about half a month now and I haven't found anything useful. We are pretty desperate at this point and we have even tried installing unity on his pc and writing a short authentication script there. It still didn't work for him. That means that his computer is the problem. There's probably a setting (maybe a firewall rule or something) that he needs to change. I just don't know what it is. Does anyone know how to solve this issue? Thanks.
PS: I have made a thread about this but no one replied
I suppose it could be a firewall issue or if he's using VPN that can sometimes cause issues
Hello everyone does anybody know how i can make a multiplayer game where i can host the lobby on my pc and a random codes genaretes that i can give to other people and they can join me with the lobby code
public void JoinGroup(string squadName)
{
print("Button Work");
currentGroup = GameObject.Find(squadName);
if(currentGroup == null)
{
currentGroup = PhotonNetwork.InstantiateRoomObject("PhotonPrefabs/Squad/SquadDefault", transform.position, transform.rotation);
currentGroup.name = squadName;
currentGroup.transform.parent = null;
}
currentGroup.GetComponent<SquadManager>().squadList.Add(playerLook.gameObject);
}
public void LeaveGroup()
{
currentGroup.GetComponent<SquadManager>().squadList.Remove(playerLook.gameObject);
currentGroup = null;
}
Squad Manager:
public class SquadManager : MonoBehaviour
{
public List<GameObject> squadList = new List<GameObject>();
}
```how do i sync the squad member list beetwen clients
(similar to battelfield squads) -> pun 2
Would steam networking sockets work without steam?
I highly doubt it, and also, why?
ello
so im new to unity networking, and i followed this tutorial:
https://docs-multiplayer.unity3d.com/netcode/current/tutorials/helloworld/index.html
but when i generate new clients via the terminal, the client is unable to see the players whereas the host can
Tutorial that explains creating a project, installing the Netcode for GameObjects package, and creating the basic components for your first networked game.
it also seems that the client's inputs do nothing to move the players on host-side, too
Hi, does anyone what is the best free networking solution to make games?
Well if you want player hosted games so you don't have server costs, look into Mirror or Netcode for GameObjects
They can both do dedicated servers too
How can I save players' names/ids as a network variable, I tried lists and dictionaries, to no avail. (This is Netcode BTW)
You can use a network list of one of the fixed string types in unity.collections
But it's probably easier to just store them all locally in a dictionary
How can I use a local dictionary, and still have it be known to the other players' game instance?
@sharp axle If I use a local dictionary, how can it interface with the network to get to the other players
If you have the player name stored in your Player class, the OnNetworkSpawn have that player save it's client id and player name to a dictionary on a player manager
@sharp axle Aright, i think i understand, have the player manager in the scene already, because every player would have access to it, to put their id/name into it, and every player's I'd/name would be on their prefab. Okay, next question, do variables in the game scene, like attached to an empty game object, sync to the clients (the dictionary in this case), even though it isn't a network variable
It won't in this case. Every client will keep its own separate copy of the dictionary
Well... Then what case is the one you described to me in the previous message
We made sure that he wasn't using a VPN, so that can't be the problem. I also think it's something with firewall, but I don't know what. He clicked "Allow" when the firewall window popped up, but i guess there's something else he needs to change.
If you really have to have it sync, then you need to make a Network List with a struct that contains the client id and player name and implementation INetworkSerializable and IEquatable.
Do you think changing the network profile (private/public) could fix it?
Another solution would be to server rpc to notify server of changes, the server would send client rpcs to let clients know things are updated
Imo, it would be better than forcing sync every sync cycle with a network list 🤔 but maybe I'm missing smth
I doubt it.
Lists and variables will only sync when their values change. But yea, your only options for syncing data are Network Variables or RPCs.
Lists and variables will only sync when their values change. I didn't know that 😄 I thought they were synced at every sync cycle, which is like 0.2s
That would be an insane waste of bandwidth, lol. There is a dirty flag that gets set that triggers an update.
Ok, I guess I'll just have to dig deeper and find it somehow, thanks
Corporate or school networks can be blocking things too
He is also using a computer that he bought from someone else, so maybe the previous owner f-ed something up
Hey so I'm trying to figure out networking but I've run into an issue where the host can move around but the client cannot. I'm following a tutorial and it says to use Client Network Transform to fix this, but that didn't solve the problem for me. I've retried hooking up client network transform at least 5 times but still isn't working. Anyone have a solution?
Are you also using a character controller? That will also override the transform.
I've got a movement script hooked up to the player prefab, should I not have that?
It's set as a networkbehaviour and has "if (!IsOwner) return;" to make sure it doesn't move all players together
and that's the only movement script I have hooked up
That should be fine. Are you using the latest version of NGO 1.2.0? The client network transform has changed a bit in the last few versions
Yea, it says Netcode for Game Objects 1.2.0
There is one thing that didn't work for me and that's the link to the Client Network Transform package. But I got it from the Unity multiplayer doc https://docs-multiplayer.unity3d.com/netcode/current/components/networktransform#clientnetworktransform so I copy and pasted the code of the script
The position, rotation, and scale of a NetworkObject is normally only synchronized once when that object is spawned. To synchronize position, rotation, and scale at realtime during the game, a NetworkTransform component is needed. NetworkTransform synchronizes the transform from server object to the clients.
tutorial said that copy and pasting the script should work fine but just letting you know
Yea. That one should work
Is there anything else I can do or share to fix the problem?
what is the best way to communicate between server and client?
rpcs seem interesting, but vulnerable
If you are using NGO, the choices are Network Variables and RPCs.
And I guess Custom Messages
thx
i was looking into rpcs
and came up with an idea
but i have one more question
there is that isServer property (which is for hosts, which are what im using)
can that be manipulated by clients
if its running on their script?
IsServer will be false on clients. The only way to change that would be through something like Cheat Engine to manipulate the variables in memory.
so there isn't really a way to do bulletproof anticheat is there lmao
Yea. There is no such thing as bullet proof anticheat. You can do things like variable obfuscation, but that just makes it harder not impossible.
You’d strip server code from a client build so the variable would become useless
anticheat is about detecting bots, assistive tools and message tampering
true
I’d say first goal should be to have a game that is worth cheating in.
lmao i'll try
Or worth playing even.
Much like optimization, it's easy to get lost in the anticheat weeds prematurely.
i switched from normcore to photon, so this is what happened when i playtested (the player model is supposed to be in the glass room but it is instead in the sky)
can anyone help..?
can any server object modify network variables?
sounds like you need to set the player spawn position
If the write permissions are set to Server or the variable is on an object owned by the server
Dunno, I don't use photon. But there should be a place where you instantiate the player
oh okay
Hey guys, is there any reason why NetworkList<T> wouldn't accept a custom class* that a NetworkVariable<T> would? I've set up a struct which uses INetworkSerializable and System.IEquatable<T> but as soon as I try to implement it as a class it claims it as a nullable type.
*i've gotten it to work with structs but I'm unable to edit the values of a list of structs how I would prefer compared to a class.
public ulong clientId;
public int fuel;
public int ore;
public int carbon;
public int food;
public int goods;
public int victoryPoints;
public FixedString64Bytes name;
bool System.IEquatable<Player>.Equals(Player other)
{
return (clientId == other.clientId) && (name.Equals(other.name));
}
void INetworkSerializable.NetworkSerialize<T>(BufferSerializer<T> serializer)
{
serializer.SerializeValue(ref clientId);
serializer.SerializeValue(ref fuel);
serializer.SerializeValue(ref ore);
serializer.SerializeValue(ref carbon);
serializer.SerializeValue(ref food);
serializer.SerializeValue(ref goods);
serializer.SerializeValue(ref victoryPoints);
serializer.SerializeValue(ref name);
}
}```
NetworkList<Player> playerList = new NetworkList<Player>();
I need to use Unity hub for a company project. But unfortunately, they have proxies and a bunch of other network security tools set up. I am not all aware of.
I download Unity Hub 3.4.1 but I cannot login on Unity hub. When I click login, it redirects me to a a white page and nothing happens.
I checked the inspect and it had a link which I clicked hoping to be redirected to Unity. But I still cannot login. I check the log file and it has the following error: "UNABLE_TO_GET_ISSUER_CERT_LOCALLY" or "network error: ("Error: unable to get local issue certificate)".
Does anyone ever experienced this type of behavior ?
Hello guys, please let me know if this is not the right channel to post about this topic.
Hi, I need help! I have a weird problem that drives me crazy: I am using Mirror and Parrel Sync. When I run the game (host+client and client) for the first time, everything works fine. However, if I run join the server again without changing anything, my players transforms do not sync for a while. Has anyone got this kind of problem before?
I tried to debug my code for hours to understand why this desynchronization is happening before I realize that there is actually nothing wrong in my code! If I re-launch my Parrel Sync and run the game, everything works smoothly! The most interesting thing is that the animator syncs just fine! Why?? Is this problem related to my code or just Parrel Sync? Should I open an issue on their github or is this a me problem?
I have a short video attached showing this behavior.
Can't use classes. The type can't be nullable. So it's structs only
Wrong channel. You need to talk to your IT dept or just download the editor installer from the web
Check the project settings and see if the play mode domain reload is enabled. It think parrelsync needs it enabled
thank you! <3
Hi, I need help, I'm using netcode for gameobjects and I want the ball to reset it's position when it touches the goal line, The ball has a client network transform, and its in the network manager prefabs thing in the inspector, I tried doing this using a ServerRpc sent from the ball itself but for some reason when the reset postion function activates it resets the position of the player not the ball (???) anyone has ideas why that might happened?
Here's the code the controls the ball:
{
private void Awake()
{
//this happens on trigger enter for the ball
GoalCheck.Goal += (string s) =>
{
ResetPosServerRpc(); //send server rpc to reset postion
Debug.Log(s); //show that there was a goal scored
};
}
[ServerRpc]
public void ResetPosServerRpc(ServerRpcParams serverRpcParams = default)
{
var clientId = serverRpcParams.Receive.SenderClientId;
if (NetworkManager.ConnectedClients.ContainsKey(clientId))
{
var client = NetworkManager.ConnectedClients[clientId];
client.OwnedObjects[0].transform.position = new Vector3(0,0.5f,0);
client.OwnedObjects[0].GetComponent<Rigidbody>().velocity = Vector3.zero;
}
}
}```
And here's a video of the behavior
client.OwnedObjects[0] is always going to be the player object
aha i see this makes sense then, thing is the ball is not a client(?) like i dont call start client on it like with a player, i just instantiate it when two players connect, so like do you know a way to control it's position and have it update on client and host? 😭
Im trying to learn netcode for gameobjects. How do I modify values(velocity) of a rigidbody through the client?
There are many different ways to do physics in multiplayer games. Netcode for GameObjects (Netcode) has a built in approach which allows for server authoritative physics where the physics simulation is only run on the server. To enable network physics add a NetworkRigidbody component to your object.
Thank you. I think I should've been more clear with what my problem is.
I'm trying to add velocity to a network object on the scene. I have the following script attached to the host and the client an I can add velocity to the ball with the host character, but I cannot add velocity to the ball object on the client. I am spawning the ball object like this in OnNetworkSpawn: ball.GetComponent<NetworkObject>().Spawn(); I am not getting any error messages.
I have the network object, network transform and network rigidbody components attached to the ball object.
why is there disparity for the client position in the client view and the host view (the host one shows it correctly but the client view does not)
the code:
{
SetStartPostitions();
base.OnNetworkSpawn();
}
void SetStartPostitions()
{
if (!IsOwner) return;
if (IsHost) SetStartPosServerRpc(new Vector3(0, 1, -19));
if (IsClient) SetStartPosServerRpc(new Vector3(0, 1, 19));
}
[ServerRpc]
public void SetStartPosServerRpc(Vector3 pos ,ServerRpcParams serverRpcParams = default)
{
var clientId = serverRpcParams.Receive.SenderClientId;
if (NetworkManager.ConnectedClients.ContainsKey(clientId))
{
var client = NetworkManager.ConnectedClients[clientId];
client.PlayerObject.transform.position = pos;
}
}```
why is there disparity for the client
hi guys , I am planning to make a game similar to slither.io or diep.io , can someone guide me what should i use for networking , photon or the new unity multiplayer
Either of those should work fine
[ServerRpc(RequireOwnership = false)]
private void hitServerRpc()
{
rbBall.velocity = (cam.forward * hitForce);
}
how do I use the cam.forward in a ServerRPC since the server doesn't know cam.forward?
This script is in the client but the cam.forward returns null
What are some scalable networking solutions that can support hundreds of people with dedicated servers (like rust)
Supposedly Photon Fusion and Unity Multiplay can handle it. I'm not sure anyone has gotten hundreds of people to actually test it
https://doc.photonengine.com/docs/content/photon-fusion-br200-multiplay-integration-documentation-by-unity.pdf
Hi guys, I'm creating a MMORPG with Unity Netcode, but I fell in a problem where I can't settup the netcode to work with multi-scenes. I have a plan to creat a servers to each game scene, but this will cost alot of time, anyone have a better idea?
Hey guys, me again, still struggling with INetworkSerializable. I appreciate the feedback I got earlier. I decided to try to make a class with a list of other player classes that I've also set up to be serializable. I've verified that I can use the Player class as a NetworkVariable but when I use PlayerList as a NetworkVariable the game runs and everything seems fine but none of the clients are receiving any data. The List is always empty for them. What could be causing that irregularity?
public PlayerList(List<Player> newList) {
list = newList;
}
public PlayerList() {
list = new List<Player>();
}
public List<Player> list = new List<Player>();
public bool Add(Player newPlayer) {
list.Add(newPlayer);
return list.Contains(newPlayer);
}
public bool Contains(Player testPlayer) {
return list.Contains(testPlayer);
}
public int Count { get {return list.Count;} }
public Player this[int i] {
get {return list[i];}
set {list[i] = value;}
}
void INetworkSerializable.NetworkSerialize<T>(BufferSerializer<T> serializer)
{
int count = 0;
if (serializer.IsWriter) count = Count;
serializer.SerializeValue(ref count);
for (int i = 0; i < count; i++) {
if (serializer.IsReader) list.Add(new Player());
serializer.SerializeValue(ref this[i].clientId);
serializer.SerializeValue(ref this[i].fuel);
serializer.SerializeValue(ref this[i].ore);
serializer.SerializeValue(ref this[i].carbon);
serializer.SerializeValue(ref this[i].food);
serializer.SerializeValue(ref this[i].goods);
serializer.SerializeValue(ref this[i].victoryPoints);
serializer.SerializeValue(ref this[i].name);
}
}
}```
Look into the NetworkManager.SceneManagement class. The host should be able to change the scene for all clients there. You'll also want to manage which object you'll need to not destroy on load (the network manager is that way by default). Hope that answers your question.
Thanks, I'll take a look
oki
Sorry for the very late reply, but there are many ways to do this.
For example, you can try Netcode combined with the Relay package, or if you're looking for something much simpler, I recommend Photon (just know that the free plan can only allow 10 concurrent players)
I am looking into networking
NetcodeForGameObjects seems great, but if I wanted to, could I export my own dedicated sever? I know a lot of the server files are wrapped up in the client or even shared.
If I went for ENet... Could I re-use C# code between the client and server? It seems foolish to attempt to write the server 100% separate and assume zero overlap code with the client. And it's also very low level. Is it still feasible without all the high level stuff in NetcodeForGameObj?
Also open to other networking solutions. I want control, but would only be operating in a small team (< 5 people) so I am not looking for anything ambitious
if you use NGO your server will be a headless unity app built from the same project, that is the architecture of all the popular frameworks. You can however use the transports standalone (Enet, unity transport, kcp, …) and build your own abstractions and then split the projects. You can also venture into the wild and use things like MagicOnion/gRPC/PhotonServer or a distributed message pipe/protocol framework like SharpMQ that would allow you to do whatever you want and split server/client in as many fragments as you like
NGO?
Netcode for GameObjects
ah
Btw all the high level stuff in NGO is just basics you’d have to DIY anyway, so unless there is a major issue with how NGO does it, there is no point to doing that
So you wouldn't call NGO's tools a huge crutch at all?
What about the authority stuff or interpolation?
something so useful, you couldnt go without it
NGO just saves you a year of groundwork
All the hard parts like interpolation/prediction/rollback are left for you to develop
There is nothing in it that is game/genre specific, which makes it different from photon products
I see. I was thinking about some interpolation code thats done for you in some unity components. Like maybe character controller?
you mentioned the "year" of groundwork done for you. I really should try NGO for myself, but could you give me an idea of how much groundwork is there?
Connection management, rpcs, data serialization, network variables, authority, source-gen to make it all convenient to use, basic spawning/replication, basic scene management. Technically you can replace most of those with your own if you need.
source-gen?
Yes, required to make an RPC by just sticking an attribute on a method
you can send messages manually, write your own serialization and register your own callbacks if you don’t like rpcs
The headless dedicated server export you mentioned earlier
Does it bundle a ton of unnecessary game files along with it? Including client source?
Thanks for all the info so far btw
You can strip client code with #if IS_CLIENT #endif
like any build it bundles everything that is referenced by a scene
Makes sense... mostly normal build just with a different starting point
Same starting point
Just no graphics/window/renderer is being initialized
for a typical small game, this makes it much easier to reason about stuff and to find bugs
you can externalize large assets easily with addressables if you need to remove certain large assets from the server build
@solar zephyr also keep in mind that NGO is still very new. It only went 1.0 a few months ago. So there are few tutorials out there if you are learning from zero. Fortunately most of the major frameworks are designed very similarly and the basic concepts like RPCs and network variables are the same.
Does someone know how much the UTP header size is in bytes ?
Looks like you can get it from NetworkDriver.GetMaxHeaderSize() and pass in whatever pipeline you are using
is there a way to create a network dictionary?
ik they got removed
but i still wish to use one for data transfer
hello guys, is there anyone who could consult me regarding using Unity Relay with a non-Unity engine?
You could start by consulting the documentation
https://docs.unity.com/relay/limitations.html
I have read it many times! I do get a successful Join Relay Server response but it gives me 3 different ports and I'm not sure how to actually connect to that IP and port. The Unity example uses additional Singleton/Unity Transport technology that connects players automatically. It's unclear what would be the flow for another engine like Unreal.
Singletons aren't a Unity thing. As for the Unity Transport you would use whatever your Networking Solution allows
I imagine all their examples are Unity based, you may have to butcher them
that's fine and thank you so much for responding but in principle, I create a remote server allocation, so I should just be able to connect to it via IP address? I thought it would work similarly to how a service like Hamachi allows you to create a VPN and make a p2p connection. I'm applying the same logic with Unity Relay but that IP just won't open the level, it says
"LogNet: UNetConnection::Close: [UNetConnection] RemoteAddr: 35.232.227.170:7777, Name: IpConnection_11, Driver: PendingNetDriver IpNetDriver_13, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID, "
I've never used Relay and obviously if you're using Unreal the docs might not be the most helpful. You might be better off asking in the Unity Multiplayer Networking Discord pinned to this channel, they have channels for Unity Relay and Lobby etc
Many thanks for referring me to that group, I'll ask there, too!
#archived-unity-gaming-services might be able to help out as well. But I am curious why you're using Unity Relay as opposed to Epic's relay
I wish I could use it but I for the world cannot understand their documentation. I don't see any evidence of such service in the EOS dashboard, either. Unity has everything clearly described, and I just need that final step of connecting to the IP sorted.
nvm i came up with a decent system
thx anyways tho
I'm having an issue with grabbing Instantiated prefabs (Using OpenXR, and Normcore)
When I instantiate a prefab, Player 2 is unable to grab it, but can physically interact with it.
If its already In the hierarchy, then player 2 can Grab and interact with it.
I checked the prefab in the Resource folder and its exactly the same as the one in the hierarchy
If I remember correctly in normcore, you have to request ownership before you can grab something
Yup, thats right.
I have a script that does exactly that, when you grab the object with the XRGrab interactable. Which is why Player 2 can grab it, and so can I.
This isn't working with prefabs for me though.
Because of your comment Im going to try requesting ownership if the players hand touches the object or something similar. so thanks for the comment!
I also discovered this during some testing.
For some reason if you Instantiate a Prefab with RealtimeView during runtime, its UUID and Advanced settings are missing. I dont know why this is happening.
i have created a multiplayer game, and i'm facing alot of laggs, i want an expert in game networking to test it and review it for me
if anyone is willing it will be much appreciated
[Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main ]:
Error when executing git command. fatal: invalid refspec 'main '
[NotFound].
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
Getting this error when trying to import the package
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop#main
Hi guys, I've trying to verify if has any servers active before StartClient, I tested a lot of things that I see in forums, but nothing was what I need. Basically this verification will be used for a branch of things, and I really need this verification to the progress of my project. Anyone knows how should I do this?
Use only one Instance of NetworkManager with DontDestroyOnLoad to navigate throughout scenes with it
if(Instance != null) Destroy(this.gameObject); else Instance = this on this object
There is no way to tell if a remote server is active before connecting to it. I suppose that you could try to ping the address. You could also use the Lobby service if you need a list of active servers.
ello
have a question
are the names of player objects on the server in sync with the names of player objects on the client?
I haven’t been able to find information on how exactly Relay and Lobby work together s2s. Any details to direct me?
There are a couple blurbs in the docs that vaguely elude to some connection between them but I’m looking for specifics
They spawn with the same name. If you change it later, you'll need an RPC to sync the names
this is basically it.
https://docs.unity.com/lobby/relay-integration.html
The relay service will disconnect the player from the Lobby when they leave. It can also be used for host migration
I have 2 versions of my game right now. One with networking using Photon Fusion, and another with networking using Netcode for GameObjects.
I originally went with Photon Fusion but I wanted to deploy a UWP game on Xbox. I then learn that Photon Fusion does not support UWP. I then decided to rewrite in Netcode for GameObjects, however, I am now running into many issues with UWP on Xbox only with Netcode for GameObjects that I outline here: https://forum.unity.com/threads/issues-with-netcode-for-gameobjects-in-uwp-xbox-only.1381587/
and here: https://github.com/johnpwrs/netcode_for_gameobjects_xbox
So I have 2 questions:
-
Is a multiplayer UWP game on Xbox a lost cause? It seems to get any real support I need a real developer account able to do native builds for the Xbox.
-
Considering I can't get either versions to work on UWP for Xbox, I am left with a choice on which branch to continue with. Looking for any insight from anyone with experience with Netcode for GameObjects vs Photon Fusion in production. The game can have up to 10 players in a 5v5 PVP match. No physics. 2d isometric game.
I'm running my game in client/host mode. The game works fine in UWP desktop as client or host, but on xbox the game freezes and the xbox just...
will setting requireownership to false on a serverrpc make the clients unsafe?
i have a function that directly sends input to the server
but it throws this error:
"Only the owner can invoke a ServerRpc that requires ownership!"
What Websocket Client should I use in Unity C# ?
I read about SignalIR and SocketIO from the Asset Store
Coming from Java/Kotlin I have no idea what's a good thing in C#
Is there any good resources for the new netcode framework?
It's either that or you can change the ownership of that object to the one calling it
Code Monkey and Tarodev have some good videos on it. The official docs are really good too
hey i got a quick question. right now im trying to parent a weapon to my players hand over the network. if i understand the docs correctly, i can only parent a network object to another network object that was already spawned on the network. the problem is that my player is made up of lots of parented bones and theyre not network objects that were spawned on the network, only the parent player gameobject is. so is it not possible to do this?
it looks like this
Parenting network objects is messy right now. I've been sticking to using physics fixed joints if I need something attached to another object
Does anyone know how to use flat buffer with unity to serialize data ???
Or protocol buffer ?
THANK YOU VERY MUCH
Looks like unity themselves forked this
https://github.com/UnityTechnologies/flatbuffers-unity
Though I'm not sure of the benefits of this over the built in bitpackers
Object picking up is working host side but not client side they have client network transforms but still wont work this is one of the main scripts
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
public class ClickManager : NetworkBehaviour
{
public delegate void MouseClick();
public static event MouseClick OnMouseClick;
public static Vector3 mousePosition;
public static GameObject selectedObject;
Vector3 offset;
void Update()
{
if (!IsOwner) return;
mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
if(OnMouseClick != null)
{
OnMouseClick();
if (selectedObject)
{
offset = selectedObject.transform.position - mousePosition;
}
}
}
if (selectedObject)
{
selectedObject.transform.position = mousePosition + offset;
}
if (Input.GetMouseButtonUp(0) && selectedObject)
{
selectedObject = null;
}
}
}
Client Network Transform is owner based. You'll need to change the ownership of whatever it is you are trying to pick up
does anyone here have great knowledge about game servers?
You should ask the actual question
How much wood could a woodchuck chuck?
Depends on the game, the networking solution, the hardware
does OnNetworkSpawn() get invoked on both server and client side when an object spawns?
Yes
is there a way to start a server that is on Multiplay from unity with code or request a list of server and if there are non running start one with custom parametars that arent the same as in build config
That's what the Matchmaking Service is for. I think Cloud Code might be able to allocate Multiplay servers as well
Thx il look it up. Spent 2 days on getting photon fusion dedicated server and client to connect when one is on the cloud
Now works fine with an error here and there but for starts it works
I'm trying to get the networking to work so I can make everything else with no thinking of does it connect
hi guys, not sure how to structure my game/custom models (using Normcore) with logic in the scene. Basically doing a cooking game and i'm not sure how the logic should be, i have all the logic setup on for single player i.e day start, customers coming in and placing orders, but how or who should be calling this logic, i don't want all users having random customers entering with different orders. Any help would be appreciated.
Idk if this Is useful ut codemoneky is doing a tutorial or a course on a multiplayer cooking game mby take a look there for some inspiration or how things go
But from me it's have a server side Object that has all the logic for game contoll and just have players make the foor od tasks then when task is finished tell the server side manager smth like that
awsome cheers dude will look into it
do the UNet buttons still work?
I am trying to just do this again and it is not working when I do one as "LAN Server Only" and another as the IP Address to connect to. I am wondering if there was some update or deprecated that caused this to change?
It works when I type in "localhost" but everything else like with actual IP Address of my laptop does not seem to work.
I guess I should start over and try to do this some more supported way? Is there a way to do this in a very simple intuitive method?
Am sort of worried if is something deprecated again?
I would have some cloud service like Vultr and run the Unity game that I built from there, clicking on that Virtual Machine Cloud Server the "LAN Server Only" and then type in the IP Address of the Virtual Machine on my actual laptop?
This is how to testing the across the internet connections?
UNet is deprecated
It has been replaced by a new official solution, Netcode for GameObjects
So like, it just does not work anymore and won't work? I am just wondering if I had a game built like this what happens?
I do not fully understand Unity and how its networking works. I may try to figure out if I can just do a version myself that won't be deprecated in the future.
So the reason it is not working anymore is because it is deprecated? Or should a game built with UNet still work over internet?
It would work in whatever state it worked in before it was deprecated, I heard it wasn't very good
Should you use it to make a game now? Absolutely not
And of course it will still work over the internet, you are hosting the game not any Unity servers. If you are trying to connect to a device on a different network chances are you'll need to open the right ports in the router's firewall
Ok, I probably should figure out how to do this then. I guess I need to open the ports on the Virtual Machine.
What do you mean here by 'router'? What is needed for it to work. I am just trying to host the game on a Virtual Machine and then connect to that Virtual Machine's IP with my Laptop
I guess it could also be the Virtual Machine being too slow, but the issue occurs if I try typing in my own IP Address on two instances on my computer.
Assuming it's not on a different network, the router's firewall will be irrelevant
That used to work a while ago, but does not seem to now when I swap localhost with my laptop's IP and run the server from my laptop
Only thing still working is Localhost.
I may just consider starting from scratch again if there are any good tutorials on what is up-to-date and may not be deprecated? Currently the game is not much of a game anyways
Right now my goal is sort of just to make a "Valorant Clone" that is not really a Valorant Clone. Like legit, my old game was a networked roll-a-ball.
Netcode for GameObjects is Unity's new solution. There are many good community multiplayer solutions like Mirror and Photon
This is like code wise? Like the [Command] and [ClientRPC] stuff?
I am more just wondering about stuff like the NetworkManager and IP Addresses and just getting stuff connected
Right? All these solutions use some form of network manager and messaging systems
Ok. Is there any tutorial that goes over the IP Addresses and uses some sort of Virtual Machine or Server like vultr?
(Or what virtual machine to host server is recommended?) Or even using Unity's Relay or other stuff?
I have no idea if such tutorials exist because I've never looked
I found one from Code Monkey, will just be try it
Am a bit worried as it is mainly the IP Address stuff that seems finnicky.
I'm networking a competitive (< 20 people/match) building game. If I go ahead with NGO, how do I run multiple matches/instances with a matchmaking system later?
You can use Unity's Server Hosting and Matchmaking Service
would that instantiate a bunch of my match servers for me like in a cluster?
spin up more as it needs them?
That's exactly what it's for
how do you do something like that?
Just assign the connected body
https://docs.unity3d.com/Manual/class-FixedJoint.html
ah ok, thank you
Anyone familiar with Playfab integration? The LocalMultiplayerAgent works fine for me when I test locally but when I use my container in a build on playfab I get stuck with "Unhealthy" build status, and it just says "pending heartbeat" for my server. When running the LocalMultiplayerAgent I see the "ProcessHeartbeat" going every second and I can connect with my client build.
How do I do that?
Netcode for Gameobjects' high level components, the RPC system, object spawning, and NetworkVariables all rely on there being at least two netcode components added to a GameObject:
hey so i tried using fixed joints but it doesnt seem to work well with what im trying to do, is there any other workaround?
You can do network objects parenting but it's a pain. You have to handle it through a separate manager class.
how so?
right now the only way I see to do it is by manually spawning in and parenting each bone so that way I can parent my weapon to the hand bone 😭😭
which seems impossible
how do set only one camera acting for each player separately instead of using multiple cameras in netcode?
bump!🙂
anyone know how I can improve the NGO network transform interpolation to be more precise?
I use cinemachine. Have the main camera and virtual camera in the scene. When the local player spawns have it assign itself as the virtual camera follow target
Im trying to port forward with mirror to another pc but it wont work
Your only control there is lowering the thresholds
I'll try but the position threshold is already at 0.001
Would me using the clientNetworkTransform be making any difference or would the server authoritative network transform just have the same interpolation amount
It would be the same. If you are seeing lag then threshold is not gonna help that. You would have write your own client prediction/reconciliation
ok so running without interpolation is perfect as far as how responsive it is but obviously it's very choppy so I want to know if I can bridge that gap by changing values or if I need to use a different interpolation algorithm or some other solution
Basically this is your starting point for a solution
https://youtu.be/3SILT4-vZWE
In this video, we take a look into implementing client reconciliation so that the client can correct themselves if they predicted the wrong position.
This is part of a series so make sure you follow the rest before looking at this one if you want to follow along.
If you want to talk more or get some help, join our Discord server! Links is in t...
hey how can I go about doing this?
Read through the docs here for an idea
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.
I did already 😭😭
oof does that mean that using the rigging and animator in that way is not going to work?
can i get some recommendations on matchmaker tutorials for unity gaming services
i kinda need to use it but just cant find any tutorials on it
and the doc arent that helpful
For me, I just have characters+guns animated from Blender, and so using them in Unity is not painful at all, but I understand not everyone can do this
(you might have a gun pickup system)
yeah 🥲
damn rip
Unity has tutorials on that on youtube, weren't those helpful?
i spent a hot minute working on some animation stuff
might have to go back to the drawing board if i can't use the rigging
😭
the problem is parenting rather than rigging itself
dynamically re-parenting stuff is painful
nope they just show the web dashboard setup not the c# code that request the ticket
I'm using animation rigging for my VR avatar
i added the sample to my project and it makes a ticket but throw an error timeout. What i need is if there are no server running start one.
You have to set that up in the Dashboard
This?
What is the easiest way to check if two IP Addresses are connecting to each other properly?
This is mainly to figure out if the issue is something Unity related or if it is router/firewall stuff.
quickest way is to run ping from the cmd line
I think I just figured out it is something related to the router. My game works at school but not at home?
I just swapped localhost with my IP Address when I was at school and it ran with the IP Address
I guess next test would be to have some friend enter the IP Address on their laptop
Or something related to network settings. Entering IP Address at home does not work, but it works at school.
Maybe has to do with Windows Settings related to the wifi networks or something?
Nevermind, it is still not working. I have a Virtual Machine running and then am trying to type in the IP Address of the Virtual Machine. Having Virtual Machine run one copy and my laptop run another. Goal is to eventually have the Virtual Machine permanently running it 24/7
Only difference today is that running two copies on my laptop with one having 'localhost' swapped for my actual IP seems to work now but did not a day ago.
I guess I should try to ping the virtual machine from my laptop.
If that works it can be assumed the Unity UNet entering IP Address to there should also work.
This used to be 'localhost'. Changing it to my actual IP Address for my laptop is now working. But now am trying to do it across different Wifi Networks. Like to a Virtual Machine.
thanks
Does anyone here have a game launched with Unity Multiplay? I wanted to know if it is session based, and the pricing page (https://unity.com/solutions/gaming-services/pricing) says $800 credit for 6 months, meaning services cost (800/6) about $130/per month. Is that the average cost for devs per month after the $800 credit is finished? Thanks.
pricing examples here are a good guideline
https://docs.unity.com/game-server-hosting/concepts/pricing.html#pricing-examples
Thanks for the reply. I actually have that tab already opened. Now I need to know if its session based, meaning a server will stay on for a limited amount of time. Nevermind, I found it https://docs.unity.com/game-server-hosting/concepts/ecosystem.html. Thanks again mate.
thats crazy that unitys NGO complicates parenting so much, making stuff like this impossible. im too deep into my project at this point so im gonna have to look for workarounds, ill lyk if it ends up working 😭
Hello, I have attached a callback to NetworkSceneManager and my callback is notified twice.
NetworkManager.SceneManager.OnLoadEventCompleted += OnSceneLoadEventCompletedEvent;
NetworkManager.SceneManager.LoadScene("MyScene", LoadSceneMode.Single);
private void OnSceneLoadEventCompletedEvent(string sceneName, LoadSceneMode loadSceneMode, List<ulong> clientsCompleted, List<ulong> clientsTimedOut) {
Debug.Log("I'm called twice");
}
I suppose that this is because i'm on "Host" so I'm client and server, so I get 2 notifications
But how to handle that ? I have to ignore one event and I don't know which criteria use to ignore one of the calls.
Yeah, my game seems to work for entering the IP Address manually if you are on school wifi, but it does not work for the wifi at my home, I am not sure why. Also am wondering about why at the school wifi it did not work across different networks. (Actually, I think I know -- my school wifi has odd security requiring some VPN so I guess it shouldn't work unless that VPN is installed)
I think my game is actually working correctly, it is just wifi security and stuff to deal with. The fact that I can enter IP at school on another school computer, but can't do it at home probably has something to do with some setting with the home wifi.
Is there any Windows Setting I need to check on or off? Or anything related to router or ISP ?
anyone here tried to build custom implementation for player position syncing?
For RPCs, is there a performance difference or recommendation between passing NetworkObjectReference vs networkObjectId and using TryGetValue in the RPC?
i've been using NetworkObjectReference but don't see it getting used in Boss Room
NetworkObjectReference is literally just a wrapper for NetworkObjectId. Its actually the only property in the struct
perfect! thank you!
from what i was reading it seemed like it was more of an issue if you were messing with the scale of objects?
i wasnt scaling anything. i did find a fix tho so its all good
good rule of thumb to keep the majority of parents at 1,1,1 localscale if you plan to modify the transform of its children
Hi! Trying to build dedicated server from DOTS Network Sample and have an error:
Error when processing 'AsyncLoadSceneJob: Cannot find TypeIndex for type hash 5845711394967877851.
has anyone had a similar problem?
Does anyone know how to make some sort of lobby system with netcode WITHOUT using UGC (Gaming Services)?
Or generally dedicated servers
You'll need a master server running somewhere to host the lobbies. There is no real way around that.
Can't I say, that you host the game and other players will then automatically join the game. So if you press join and a hosted server is full, then the player automatically is host and other players do join.
Something will have to keep track of all the servers running and if they are full or not
What can I do then (even when not using netcode). I really want to program an online multiplayer game, simple one and wanna expand it. Is there a good, "simple" alternate way?
There are other services out there you can use like Azure Playfab. UGS is framework agnostic as well, it will work with anything
Playflow can also work
@stray moth @sharp axle Do you know if I could make a multiplayer with a lobby and dedicated server with them? (Without paying). I mean I could even host the server on my Raspberry pi (at home).
Eventually, all things cost money
They don't. I've done fullstack web dev with only free open source npm packages and hosted the server and db on my Raspberry pi.
And even that, does in fact cost you money
Or is your internet and electricity free?
Dude, do you even understand? Those things are things that I currently own and paid for. I just don't want to add another stuff to pay for, if you understand?
I used the specs I got for it, just as I want for unity
Obviously I understand, I;m not as thick as pig shit
Please stop trash talking, it's the wrong channel for that.
I imagine all those services mentioned have free tiers, but they will have limits
You can of course research them
PlayFab might be an option too
Might have a look into it.
I mean, I am just confused by how databases would work for unity?
CloudCode+CloudSave?
Sure you can code it all from scratch and host it yourself. You can access DBs through C#. But none of that is going to be simple or easy
That's why: "simple".
I really love networking, and just wanted to know some features or programs that would make it "simpler".
Not really. It most often boils down to: Simple or Cheap, Choose One
Hey, has anyone got experience using netcode for GO and/or unity transport with an external non-unity server?
As I am not really wanting a released online multiplayer but just a learning ressource for me. I want to dive deeper into unity servers and c#
Ein i know there are some alternatives to NFGO that also uses unity services
If its not a Unity server, you'll need to use the low level Transport API
UTP / com.unity.transport?
Yea. its basically writing in raw sockets
That's what I suspected 😞 Oh well
Do you know some? And how can I do that with databases?
Photon, Mirror, and Fishnet will all work. You can use System.Data.SqlClient in C# to connect to a SQL database
Okay, I will have a look
Been using fishnet,not very complex but very flexible
Okay, is it still good for like use cases when not wanting coop, but like pvp when you don't trust the clients?
Have you ever built a webserver?
- create a simple one (many frameworks for websocket connections etc. out there)
- create a managment class that holds player queues in memory
- resolve those queues into match instances as soon as the match starts
Host the stuff on GCP or AWS or whatever. Dockerize the Server and done
what was the fix?
Yes, you would need to inherit from NetworkVariableBase
I think you can change the debug level on the network manager
thanks!
forgive me as i realize this isn't the best question, but i'm new to building multiplayer games. in my game i run a lot of character actions using coroutines. spell casting effects, mana regen, hp regen, damage over time, projectiles, etc. while looking at the boss room demo, i notice these actions get queued up and advanced in the update loop.
in the context of multiplayer games (or even non-multiplayer games), is there any reason why coroutines might be a bad choice here? is this a style choice?
I think its ultimately personal preference. Personally, I've been trying to move away from them in favor of async Tasks. But, if designing with with coroutines help you better reason about things, then go for it. I'm sure if you dig far enough into the profiler you'll find a mathematically optimized solution to use one or the other. Use whatever is easiest for your future self to understand
Is it safe to assume that if something works on LAN then once internet is properly set up it should also work over Internet? (Currently the Unity game works connecting 10 laptops all on the same Wifi Network, but does not seem to work with dedicated server still because of weird RDP and "Port" shenanigans along with the IP Address not being trusted by router security or something)
The game mechanics and code wise, like if it works on LAN it should work on "WAN" or over internet? Only thing that needs to be solved is the actual ports and security and stuff? The code of the game for LAN is same as for over Internet? (LAN has to do like Client to Server and Server to Client stuff anyways because one laptop turns into the hosting server in LAN)
That's right. Unity can't tell the difference between lan and internet. Bits are bits
Is WebRTC the best way to do multiplayer games for web browsers? For example, games like 2D football.
i want to know what is the better way (in terms of speed) to setup multiplayer game server , i planned to make it for smartphones/PC platform.
Currently another project in my team use redis with nodejs , so the whole coding on server side will be mostly nodejs
i had also heard firebase on google can do that? and ofc traditional php server with sql to retrieve data
let me know if u have better idea , im doing this for my own personal project👍
plz give me relatively cheap services or ways to do it lol, i cant afford high end servers that make me bankrupt after few months
in netcode for gameobjects, does networkvariable on value changed give the last known position to the client or the server as the first value?
Have you looked at Network Transform ?
yes, have to look further though. To rephrase my question, does networkvariable on value change give the last known Value to the client or the server as first value?
i think i solved my question with some testing though, first value is last known value to client since it's the one detecting the change. I was wondering if it worked as some sort of rpc that the server sent with the last value over there but doesn't look like it
Does anyone understand how to handle a LoadComplete on the client side only? I’m trying to ensure my scene has loaded before I link the MainCamera up to the player prefab.
If you have not already read the Using NetworkSceneManager section, it is highly recommended to do so before proceeding.
ps: I’m using the 3rd Person template which sets a m_mainCamera var to get the direction to move towards.
I have a networkmanager that’s created in a Title scene and buttons to start a Client or a Host.
The networkmanager spawns the player prefab before the scene is loaded só Awake etc doesn’t get a reference to the main camera because it does t yet exist?
Ok I got around this problem, if anyone is ever stuck trying to do the same thing lemme know.
I believe its UDP backing would be beneficial, but IIRC the tooling is so poor that the vast majority of projects are still shipping with WebSockets.
Im using Unity Multiplay to host my game server. How would i go about making a ucstom configuration Variable. Like serverID. Im using Phoon Fusion and i need to automatily assign a lobby name based on queue from matchmaker
honest question, how do you guys feel about netcode for game objects vs fishnetworking?
Fishnet seems fine. I'm just not a fan of locking features behind a paywall
wondering how much easier its would be using netcode to integrate things from UGS
UGS is agnostic. Doesn't matter which framework you use. Most if not all of them have a rest API that you use even offline. Well, outside of a game server.
Netcode is nice but still very new
Honest answer, it's hard to trust discussion around FishNet when the author has been banned in several places for astroturfing. I feel like someone willing to do that has no problems fostering a toxic fan base or rug pulling the library under people.
hey, i wanna make a game manager object that is the same for every client, how do i do that?
this made me stay away from fish. all the rave reviews i read about it in comments end up being the author himself. he seems to be busy on multiple forums, always commenting on it. i find it hard to trust all the great info i read about it
I knew the Dev was pretty outspoken. I did not know about the astroturfing
Hey, is it possible to add a network object component to an object and then spawn it in the network, at runtime?
im trying to do that but the network manager NetworkPrefabs list is getting in the way
You might be able to if you add those objects to the list with NetworkManager.PrefabHandler.AddHandler()
oh okay. in that method whats that interface that is required for the 2nd parameter?
Oops. Hang on. I was wrong its just NetworkManager.AddNetworkPrefab()
https://docs-multiplayer.unity3d.com/netcode/current/api/Unity.Netcode.NetworkManager#addnetworkprefabgameobject
The main component of the library
ahh okay, thank you
another quick thing, right now im trying to spawn something server side using ServerRpc and it works fine on the host, but ofc it doesnt on the client and im not sure why. when it comes to spawning stuff on the server is it automatically synced to clients or do I have to do some ClientRpc for it as well?
this is the only spawn logic im using
I am not sure if that's how AddNetworkPrefab is supposed to be used
you typically want to be using it on an actual prefab before the game starts
I have no idea if what you are doing would cause issues or not but it very well might
And if that's only running on the server, the client won't have the prefab added to its own NetworkManager
yea this is a weird workaround im trying and so far its working ok
You'll need to AddNetworkPrefab() on each client as well. But yea. This is very weird hack you have going on
this has to do with that armature parenting problem i had earlier. because i need to parent stuff to my right hand bone, i need to make that bone a spawned network object, meaning i have to do that to all the parents before the right hand bone as well (right arm, spine, hips, etc). so right now i iterate through the children and find ones with a tag (the ones that lead to the right hand) and add a network object, spawn it, and reparent it so the player skeleton doesnt break
somehow this is actually working so far
as hacky as it is
i tried all other solutions but this seems to be the only one that works, especially with my setup
right now the only thing not working is that the clients dont get the NetworkObject component added to them, i tried a ClientRpc but it didnt work :/
hi, newbie question, i was wondering if it would be possible to use netcode between a VR and a non-VR game? the non-VR application would be some sort of spectator, as the VR one is on an AIO headset
Yea. NGO is cross platform.
Good to know, thank you
Hello I'm creating a multiplayer car game with Photon PUN2 but getting this error when character creates in server. Its caused by joystick and I can't add canvas to prefab how can I fix this problem?
Is there an code that attaches canvas to character when user joins server?
okay i added canvas as a prefab too and now i can add controller to car
but car doesn't go for some reason
solved the problem by myself
Typically you have to program in a more explicit way when you are networking. Something as simple as "parenting an object to another" usually involves multiple clones of the object, disabling the real one, enabling a fake one, etc. It is an unfortunate limitation of most network libraries, and trying to work around it can result in strange behavior that is impossible to fix.
Also, you don't a actually have to parent things to achieve the parenting behavior. The animation rigging package can emulate parenting via components like the multi-parent constraint.
Hey guys, I'm having some issues getting my multiplayer movemet set up. I've got a scene where if I'm playing as the host, everything works normally and the player character moves like I would expect, but if I join as a client then the client's movement is really sluggish and jittery. I've figured it's got to do with using Time.deltaTime when updating the position, since removing that makes the client move at "normal" speed and the host instantly zoom off the screen. I don't know how to fix it though so every player would be moving at the same speed. Here's the code, it's really basic:
EDIT: fixed by using a combination of FixedUpdate and fixedDeltaTime and lerping
void Update()
{
if (!IsOwner)
{
return;
}
else
{
Vector3 moveDir = new Vector3(0, 0, 0);
if (Input.GetKey(KeyCode.D))
{
Debug.Log("Moving!");
moveDir.x = +1f;
}
if (Input.GetKey(KeyCode.A))
{
Debug.Log("Moving!");
moveDir.x = -1f;
}
UpdatePositionServerRpc(moveDir, moveSpeed);
}
}
[ServerRpc]
private void UpdatePositionServerRpc(Vector3 moveDir, float moveSpeed) {
transform.position += moveDir * moveSpeed * Time.deltaTime;
}
The easiest way to deal with this is to use client network transform. The hard way is to use client prediction/reconciliation
When I test the movement with the local server everything is working smoothly and there are no issues. But when I run it on an actual server there is at least a 5 second delay between input and seeing a player move even though the ping with the server is only 12ms. I am using the TCP protocol right now and planning to add the UDP protocol to the networking tool because movement doesn't have to be reliable, but I doubt it would solve the problem.
Does anyone know some things I can try to resolve this issue?
A 5 second delay is way more than any networking issues. Something else is going on there
What would be the best multiplayer api that allows players to host servers in games? Unity's, Riptide, or Steams API?
Is there a way of manually deallocate server when last player leaves, through code. Unity multiplay DGS and Photon Fusion
I think you are looking for a Relay service. Unity, Steam, and Epic's are all viable solutions. I've not hear of Riptide but I'm sure its fine as well
Riptide is a pretty low level networking library isn't it?
I believe it will automatically deallocate when the last player leaves. There is a rest api call you can make as well.
https://services.docs.unity.com/multiplay-gameserver/v1/index.html#tag/Allocations/operation/ProcessDeallocation
hmm okay thank you for letting me know. i have tried to "emulate" parenting by having an empty gameobject follow the right hands movements and then parenting it to that, or even using physics based joints to "follow" the right hand, but those break my entire character. what i have going on now may not be conventional or even scalable, but its enough for the small project i have going on and its so close to working. the only thing is that client side bug, and it seems to happen because im not adding the component to the clients
You make it sound like it's not a big deal?
Or that it is "simply a bug"... but I am saying that there might—quite literally, be no way to fix it with your current setup
any other example of implementing/using backfill that isnt the BR200 template
do i still need to search for backfill ticket after getting it from Multiplay Payload
Hello here, just started to try and implement unity netcode in my tiny game but I'm encountering an issue.
When I start the client (after I started the host in another editor), this error pops up in my console:
Exception: Scene '' couldn't be loaded because it has not been added to the build settings scenes in build list.
I have both pf my scenes in the build settings and in the right order, here is the code for my main menu script, could someone point me in the right direction please ? what's weird is that in the error message, the scene name is empty
private void OnEnable() {
//...
playBtn.clickable.clicked += () =>
{
LoadScene("Playground");
};
exitBtn.clickable.clicked += () =>
{
Application.Quit();
};
hostBtn.clickable.clicked += () =>
{
NetworkManager.Singleton.StartHost();
LoadScene("Playground");
};
joinBtn.clickable.clicked += () =>
{
NetworkManager.Singleton.StartClient();
LoadScene("Playground");
};
}
private void LoadScene(string sceneName) {
UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
}
example of implementing/using backfill
I would guess that something is calling LoadScene with an null string somewhere
Oh god ok now I see why, so in my Playground scene i'm actually creating another scene dynamically for prediction purposes. Is there a way to tell the NetworkManager not to sync this scene ?
Here is the code in my PredictionManager singleton attached to an empty in the Playground scene btw:
void Start()
{
Physics2D.simulationMode = SimulationMode2D.Script;
currentScene = SceneManager.GetActiveScene();
currentPhysicsScene = currentScene.GetPhysicsScene2D();
CreateSceneParameters parameters = new CreateSceneParameters(LocalPhysicsMode.Physics2D);
predictionScene = SceneManager.CreateScene("Prediction", parameters);
predictionPhysicsScene = predictionScene.GetPhysicsScene2D();
copyAllObstacles();
}
i'm following https://docs-multiplayer.unity3d.com/netcode/current/tutorials/helloworld/index.html
and only Start Host spawns a Player prefab, but Start Server and Start Client do not spawn anything?
Tutorial that explains creating a project, installing the Netcode for GameObjects package, and creating the basic components for your first networked game.
Well StartServer is just a server, and StartClient is just a client
If there's no server for the client to join, you get no prefab
I guess I'll just do a local fix in the NetworkSceneManager.cs so that is does not try to sync a scene that doesn't have a path
Hello. When I add a NetworkRigidbody to my object, I cannot move it anymore. To move it I add a Force to the rigidbody. Could you please tell me what is wrong ?
Server or host/ what networking??
Netcode, currently I try the code in single player so "host"
If you have a Network Transform on it then you'll need to send a serverRPC to move the object. Use client network transform if you want to move locally
... ok but I thought that add a network transform managed everything for me. (I mean transform replicated/synchronized on all clients...)
So @sharp axle the code that sets a force on the rigidbody must be located in a ServerRpc ? is it ok ?
But currently I'm a Host so my client is also my server
So @sharp axle currently I test my code without any client. Only the Host. So do you know why my object doesn't move anymore if I add a NetworkRigidbody on it ?
Post you code in the thread above. And we can have a look at it.
What code ? The code that add the Force to the rigidbody ?
public void StartMove(Vector3 velocity) {
moving = true;
magnitudeThresholdExceeded = false;
body.constraints = RigidbodyConstraints.None;
body.AddForce(velocity, ForceMode.VelocityChange);
}
It is in a script attached to the gameObject. This script inherits from MonoBehaviour and not NetworkBehaviour
well my current setup isnt even that odd, its just a basic unity armature rig. so then how should i go about parenting something to the hand over the network? its a really basic idea, and it being this complicated is surprising. the workaround im using right now, though hacky, still works. its just the adding the network object to the clients thats stopping it from working entirely
I wouldn't consider it to be working then. But the answer to your original question is that you don't parent network objects to the hand. Not in the literal sense at least. I would consider a dropped item and a held item to be completely different things. A dropped item would be synced, a held item would not. A held item is just a graphical representation of some data, for example.
The data is synced, but not the graphical representation.
I ran into all kinds of issues when I first started out. I was trying to create a submarine that would parent players to it when they entered. All hell broke loose. You have to take a different approach
right but that graphical representation, how do you get that to follow the hand as if it were being held
The graphical representation can be parented, because it's not a network object.
You simply tell all the clients to instantiate a client-side prefab as a child of the hand. You then disable / destroy the "dropped item" object.
ohh i see, that makes sense. gonna require lots of rewriting code but yea
You can call RPC functions if the functions reside on a networked object (in a NetworkBehaviour). You can't put RPCs functions onto a normal MonoBehaviour though
so when the player picks up a gun for example, they instantiate the gun to their hand. but how is that synced across the server?
server rpc to client rpc and then spawn it there?
Client sends an rpc to the server to request a gun pick up. The server verifies it and sends an rpc to all clients telling them to despawn the dropped gun object, then spawn in a client-side version on the player who picked it up.
Some games also just have all the guns as disabled gameobjects under the hand.
They then just enable / disable them when needed.
hahah i was thinking of doing that but it seemed crazy
I do not know, I don't think I have ever done it. It probably gives you warnings and things break.
ok last thing, im a bit confused on how you would implement the last part of what you said. the whole clients despawning the dropped gun, and spawning it in a specific player. how would you specify the specific player to spawn it under?
just with a clientId?
Sure, that's what I use
I think NetworkObjects can be serialized over the network, meaning they can be passed as parameters through RPCs
so you might be able to use that too
yeah with NetworkObjectReference
so id use that to despawn the dropped gun on the server, since its a network object. and then instantiate the gun on all clients using a ClientRpc
but how would i find the reference of the exact player, using the clientId? theres like a PlayerObject field right? that part im not sure on
You can't. Network objects have to be spawned from the server
You should probably spawn the gun with ownership.
has anyone followed this tutorial https://docs-multiplayer.unity3d.com/netcode/current/tutorials/goldenpath_series/goldenpath_one/index.html
?
i'm having a hard time understanding it...
Tutorial that explains adding scripts to objects, editor modes (Host Server and Client), basic player movement and basic RPC use.
Then it can't be a network behavior
Ok even NetworkTransform doesn't synchronize the position of my player. Any idea of what can be wrong ?
The player transform is updated from another gameObject.
My player has a networkobject component, and also a networktransform component
the player is created using SpawnWithOwnership from the server
Can I activate some log or any info to understand what is wrong ? My NetworkManager LogLevel is already at Developer. But I don't have any idea if the networktransform is known by the network manager, if the transform is sent to the client or not, ...
From tutorial it is like there is nothing to do "put networkobject and networktransform to your gameobject and it is synchronized" but not in my case 😦
If its not even moving then its not sync problem. Something is reset its position.
@sharp axle In fact at start, the server create all the players and then "give" them to the clients using SpawnWithOwnership
Then these players create another gameObject (a ball). This is this ball that I want to move.
When players create their ball I think that "Instantiate(ballprefab)" is not enough. Probably a network spawn or something like that is required.
Network objects have to be spawned from the server. Network transforms have to be moved from the server. Use client network transforms if you want clients to move them directly
Ok thanks for the info
Im a total Unity noob so take this with a grain of salt:
I think you're talking about having all clients share a common state is that correct? In other words: a game object that has the same "values for things" for all clients.
Example: All clients show the same score for a particular player. Or all Clients know that it just started raining in the world?
Be careful using Client Network Transform as that means that your server will trust the clients with regards to movement. In other words: players can cheat.
Yes, which part are you having trouble with?
Hi everyone, if anyone is having trouble with:
- Using the 3rd person template
- Adding a new "menu scene" to select host / server / client
- Loading the template's "Playground" scene
- Getting movement to work properly
Please let me know
Thanks, this is why I wanted to do it through RPCs and found a way to make it work!
Hmm ok kind of a really noob question here:
I have a script called CharacterSpawner that is attached on an empty object in my second scene. From my first scene, I either start a client or a host and load the second one.
How do I make it so when the second scene is loaded, my script can be executed and run functions like OnClientConnected , OnNetworkSpawn etc.. ?
I believe your CharacterSpawner needs to have a NetworkObject component
Aaaah just got It, I should have used NetworkManager.Singleton.SceneManager.LoadScene rather than UnityEngine.SceneManagement.SceneManager.LoadScene
And also inherit from NetworkBehaviour instead of MonoBehaviour
Yes, NetworkManager.SceneManager will trigger the events you want
Do you know in which function I should register my callbacks ? Currently I have ```cs
private void Start()
{
if (!IsServer)
{
Destroy(this);
return;
}
NetworkManager.OnClientConnectedCallback += OnClientConnected;
NetworkManager.OnServerStarted += OnServerStarted;
}
public override void OnNetworkSpawn()
{
Debug.Log("OnNetworkSpawn");
if (IsServer)
{
}
base.OnNetworkSpawn();
}
private void OnServerStarted()
{
Debug.Log("!!! Server started !!!");
}
private void OnClientConnected(ulong clientId)
{
Debug.Log("!!! Client connected !!!");
}
But when the host start I only see the `OnNetworkSpawn` debug log
netcode question, anyone know if there is a way to have an RPC in a non-networkbehaviour class?
try replacing your start() lines to NetworkManager.Singleton
oh god thanks, I think I should probably wake up before trying to start coding
it may help if you have some intellisense or autocomplete enabled, it would suggest what I suggested and make you suspicious if its not autocompleting what you intended 😛
I do have ahah but somehow it did not trigger any warning
Any idea why OnServerStarted is never triggered ? maybe because the event is fired before my scene loaded ?
No RPCs need to be in a network behavior and on a network object. They can be called from wherever though.
It's probably being destroyed. IsServer can't be set before the server has even started.
i sat down again and it made sense @primal timber it helped to build and run it and see what the different Server modes did
does anyone here know something or two about sockets?????
I know enough to know that I don't want to deal with them, lol
i developed a multiplayer game that uses socket ( i'm using nakama), everything works fine on a fast internet, but when it comes to a bit slow internet the socket terminates or disconnects the user and it can't neither send data nor recive it
basically i mean i'm facing a lot of lag, packet loss and disconnections
and i want someone to help me design the socket buffer read and write size, the number of bytes and outgoing queues
lol, yep. thats why I don't deal with them
If you have to ask it's probably not a good idea to write this stuff yourself
i'm so stuck with it, i asked the nakama team and they say go and write it yourself
Usually there is some sort of system that tracks how often packets are lost, and if it exceeds a certain threshold the user is just disconnected. That and/or a heartbeat. Maybe you need to implement that if the connection is too bad
can you give an example of that system please?
Lol no
Like I said, you should be able to write this yourself
You set up a base socket, you should be able to set up a simple heartbeat
oops
does ClientNetworkTransform make speed hacking possible?
someone said this on Dec 9 2022
"About this, ClientNetworkTransform is now an utility class listed in the documentation, but it's still not part of Netcode For GameObjects as client-authoritative movement is (in general) an unsafe practice that exposes your game to some types of cheats (I.E: movement hacks)
yes. its client authoritative.
do you know the solution to making inputs on client instant (for FPS game)?
Welcome to this Unity Tutorial where we go over Determinism, Fixed Tick Rate, Client Prediction, and Server Reconciliation. Deterministic Programs and Fixed Tick Rate are more theory but really important to understand in order to implement Client Prediction & Server Reconciliation. I then go into how to code Client Prediction & Server Reconcilia...
how do you get clientids when a client connects
using netcode
is it normal that the server list in unity Multiplay gets deleated if there are no servers started for a day
is there a method that is auto-called by unity when a player joins?
i read Valorant netcode tick rate is 128.. how is that possible if some people are only at 60fps?
thats how fast the server calculates the info and physcs. I think thats what that meand your 60fps is images rendered per second
i read client and server have to use the same tick rate for things to be deterministic
this is fusion
so how many times a second the server try's to update its self in turn sending all the data to connected players
You're confusing tick rate and fps. For example when you throw a nade, its a physics update is applied 128 times per second to calculate its trajectory. Then it is rendered on the client at whatever the fps happens to be. This is also why 128 tick and 64 tick servers behave differently - if you calculate the physics half as often, the difference between the tickrates will compound over larger movements like a nade toss or a bullet drop
the fps are Frames per second. How many images your computer can render in one second
i thought frames per second is both visual FPS and how often Update() was called
Correct, Update is called every frame so it's tied to your FPS. For physics calculations you'd want to use FixedUpdate instead, which is called 50 times per second by default and doesn't depend on your FPS.
ok i didn't know about FixedUpdate thanks
so my statement "i read client and server have to use the same tick rate for things to be deterministic"
is wrong?
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/networktime-ticks
This should clarify things
LocalTime and ServerTime
thanks
yea Network tick rate is different from frame rate
heya
so basically
i have a movementscript
for netcode players
and it works with just 1
but when multiple players are online the sytem freezes the players
it seems like they try to move but get repeatedly warped back to start position
Are you using a network Transform or client network transform?
welll
its complicated
basically
i don't want cheaters
so i hav eit so the client sends input to the server
through an rpc and a networkvar
just the input
soooooooo i can't really use those
In that case then you should be using a network transform. It's server authoritative. Just make sure it's only moving from the server.
oh kek fr?
damn thanks aight
ur the network channel's gigachad lmao
you dropped this 👑
which would you guys say is better
netcode or steamworks
idk which to use
i'm a bit into netcode, but nowhere near far enough that quitting would be a massive loss of progress
Steamworks is a suite of services. You can use both
i mean, which should I use for networking
i don't want to be bound to valve
buuuuut it is more financially sound for the time being
Steamworks is not a networking framework. even if you want to use it, You'll still need Mirror, NGO, or Fishnet or whatever
whats going on in networkbehaviour.onnetworkspawn and onnetworkdespawn? Docs seem to make sure to call base.onnetworkdespawn when overriding it but not onnetworkspawn and i cant figure out whats going on in those methods in the base class
(using netcode)
@sharp axle can i use matchmaker teams to dynamicly change collor of player
hello
fixed the movement of the player and npc system in my game
currently its sending the position every frame
we send position every second
its sends it every server tick
60 times a seconds or something like that
depends on current server performance
for every player & npc
When you see 10 NPC or Player you will get like 500 networkmessages per second
foreach player
10 players
5000k per second
how can I fix this so that there is no load on the server
Yes, it's part of the Match Properties in the Matchmaking Results
https://services.docs.unity.com/matchmaker/v2/index.html#tag/matchmaking_results_model
Those are just empty virtual functions in NetworkBehaviour. calling the base literally does nothing. I'm not sure why the docs do that.
There is no real reason to be sending position every frame. Objects just don't move that fast. You should not be sending RPCs every tick either. Try using client prediction and updating less frequently
how can i exclude a certain client from a client rpc?
A ClientRpc can be invoked by the server to be executed on a client.
so would i send a ServerRpc, then a ClientRpc with the senderId as a parameter, and then in the client rpc return if the senderId equals owner client id?
ok i just checked isowner and returned and that worked for what i had to do
how do i differentiate player objects?
they all have the same name
and idk how to get client id from just the player object
nvm i found smthn
I'm having this weird issue where I can't call a ServerRpc from OnCollisionEnter, but the same Rpc works just fine if I call it from Update or whatever. Am I missing something? Should I handle collisions another way?
I know that the OnCollisionEnter() itself triggers just fine, it just won't execute any ServerRpcs inside it
Physics should be handled by the server. But serverRPCs can only be called from clients.
Hello. I have a server that spawns a NetworkObject "A" and a NetworkObject "B". When A is enabled it must enable "B" and when "A" is disabled it must disable "B". ("A" is not a parent of "B"). What is a correct way to initialize a scene with this feature working on all clients ?
Somewhere, on client side, there must be a mechanism to tell A what is the B object that it should "manage"
I'm not sure that I explained correctly my problem.
In fact when A and B spawned by the server, appear on a client side, there are not "linked", A doesn't know that B is the object that it should enable/disable.
Additionally the server can spawn several couples "A"/"B"
You'll need some kind of manager class that keeps tracks of those pairs. Network Visibility is one way to handle it but they can't be hidden on the host(I don't think) the other way would be through RPCs.
@sharp axle thanks for the answer, I will handle this use case using a manager class and RPCs 🙂
Another question. When the server spawn an NetworkObject containing a NetworkVariable.
- If I set the NetworkVariable value and then I call spawn I get a warning: "NetworkVariable is written to, but doesn't know its NetworkBehaviour yet. Are you modifying a NetworkVariable before the NetworkObject is spawned?" but the variable got the correct value on client side.
- If I set the NetworkVariable value just after spawn call, I don't have the warning but the variable it is not updated with the correct value on client side.
So what is the correct way to do that ?
I've just been ignoring that warning. It wants to do it after spawning and then just wait a frame for the OnValueChanged to trigger.
Hi I just implemented a basic movement system to my netcode multiplayer game and used Server RPCs for that and when I test it I have an huge input delay. Any ideas where that came from and how to fix that?
How huge? ping time delay is to be expected unless you implement some kind of client prediction
anyone?
Ooop just found this channel- I haven’t used Unity in like a decade what updates/packs do they have to do like a small server? Ie i put up a server and a few friends can have logins to the game?
Can someone help me when I click on the room it wont join it here is my scripts
https://pastebin.com/5vAdtgxX this one is the one im pretty sure wont work
https://pastebin.com/QhdiG44p
https://hastebin.com/meqiqokaju.csharp
can someone help me im making a multiplayer prop hunt game, and i made this script to copy a object u click on and instantiate it at the player and set parent yadeedoo, but theres a problem when theres more then just the host in the server,
for every client that joins another object spawns but without the parenting or size changes the rest of the script makes, and im very confused any ideas? heres image:
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hello, is there anyone who can help my problem with Photon Network ?
[PunRPC]
public void SpawnTelli()
{
PhotonNetwork.Instantiate("MIRANA", spawnPoints[spawnBolgesi].position, Quaternion.identity, 0, null);
}
It's good that you posted in the appropriate channel, but people that monitor it, don't know that you posted in other places, so you should describe your problem properly.
OK, thanks for the advice
can someone help with my problem been up for 9 hours trying to fix it
How are you syncing the parenting and size changes?
at the bottom of the hastebin is the size and position but the parenting i was leaving to being local because the player has the transforms so once its a child wont it work?
@wide girder
Things that are not synced over the network, are not synced over the network. If the object position in the hierarchy is not synced in some way, then it's not synced.
in the game it works though, the player has the gameobject moving with them without networking the parenting
everything but it making a second object when instantiating the object
and only when theres a 2nd client connected
and it will make 3 extra ones if theres 3 people in the server
ive tried many ways different instantiating methods, networking the parent etc. i have no clue why its running the script over each client and spawning the object
You're probably broadcasting an RPC to all the connected clients and instantiating objects for each of them.
Unless you make checks or specify what client should receive the RPC, all of them would and execute the code.
You must understand that Photon instantiate already instantiates an object that is synced between the clients. Basically it calls instantiation on each of the clients. If you call it on each client, each one would create a new object for all the clients.
how would make it instantiate only on the main client but still get updated by the others?
because if i add the photonView.IsMine it messes up other networking things and just doesnt show up on the other clients
It should probably be instantiated on the client that it belongs to or on the server if it doesn't belong to any player. In the first case, checking IsMine is the correct thing to do. If it messes up other things, it just means that you have problems with the other things as well.
one thing ive never tried is checking if its mine before instantiatiing and networking the parenting too
I'm not sure what "networking the parent" means, but yeah IsMine can be used assuming the script is on an object that belongs to the client that needs to own the new instantiated object.
putting the parenting code into a rpc
yes it does need to own it
so what should i do to make it work properly because only putting the ismine makes it not show up on any client
For starters, maybe try to explain what you want to achieve step by step, because it's not entirely clear to me.
when you click on a object it check the tag and if its correct it will make a copy and instantiate it, and turn off the player model, basically turning the player into the same object they clicked, so prop hunt
Okay. So something like this?
- destroy the player object
- transfer ownership of the clicked object to the player
more like disable it because i need it to be reenabled whenever
and make a copy of the object and make the player that.
so you walk up to a cube and click it and u become a cube too
Okay, I see.
and every client should see it but it dont
closest i got was it makes a instantiation on every client but it does work mostly
So first, you should be using Photon.Instantiate to spawn the cube. It should be called only on the client that clicked the object.
okok
when i do that it spawns the object on the other players screens too but it doesnt parent to the player i think i tried it before
started learning photon like 2 days ago so im a little bad at it
Then after instantiating it, you can call an RPC that would parent the newly instantiated object to the corresponding player. That RPC needs to be called on all the clients
okay and the position change and scale change should be called with a rpc still?
https://hastebin.com/anedehitom.csharp
so like this?
obvously theres more but with the syncing of the parent
nvm that just made a object reference not set and the players turned invisible
It feels like around half a secound. This is all my code which uses netcode:
https://pastebin.com/RGwJcCUi
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Input lag
heya
so i was experimenting with basic server-side movement and noticed that, even though the objects (are supposed to) move at a constant speed, they appear floaty and on ice as if i'm using physics objects or velocity (which im not). However, this only applies to clients other than the localclient, which is odd since i haven't implemented client-side prediction
is there any reason for why such floaty movement would occur?
That's probably Network Transform interpolation
is there any way to fix this?
nvm figured it out, just toggle the interpolate setting on the networktransform component of the player prefab
Hope everyone is having a great day
What’s the best place to get started with building a player lobby/local network that friends can login to?
The Lobby and Relay Services are the places I would start. As well as going through the docs if you are starting from zero.
Code Monkey on YouTube has an excellent beginner's guide posted not too long ago.
Fantastic that’s what I was looking for
why do i get this
Don't crosspost.
Does anyone has this problem with unity transport?
it is using .Count() as a method
i already have the com.unity.collections installed on the right version
maybe this is the problem?
https://github.com/needle-mirror/com.unity.transport/blob/master/package.json
here it say 2.0.0-pre.6
sorry
Im guessing that matchmaker is broken currently. on the fact i cant join a game and there is a red warning in the dashboard;