#archived-networking
1 messages · Page 118 of 1
It should be that you spawn a camera once only, then the camera follows the local player
If you spawn a camera separately you can put a script on it that finds the local player and sets the target
only one camera but what about the new player prefabs that spawn in
just by putting in the camera as a child of the player prefab?
If the camera is on the player prefab you can either have the camera off by default and turn it on for the local player or have it on by default and turn it off for remote players.
In that case the camera spawns with the player automatically
alr
Hi, all! I'm trying to use MLAPI to create a separate project in which I can send a message to a client (one of multiple) to execute a specific function. Most of the MLAPI examples I've found go into how to create a connection between two instances of the same project, does anyone know a good example of creating a separate host project?
Also open to alternatives, as long as they work for Unity 2019 and cross platform (Android VR headsets, with the messages being sent from a Windows laptop)
Hey guys, new to multiplayer.
I was wondering if anyone had a good tutorial to start with. I'm making a 4vs1 player game and I was wondering what the best workflow would be. First make the 5 players with each there scripts, models, animations,... and then script multiplayer
or first script multiplayer and then make the 5 players?
I was thinking of using steamwork.net since I want to put the game on steam.
It’s better to start with the multiplayer functionality versus trying to add it in later
Ok thanks, do you know of a good tutorial for someone new to multiplayer who wants to build a game for steam? One that explains it step by step?
Or one of which you think gives a good workflow/is a good way of making multiplayer happen within steam
Not off the top of my head. I don’t think you need to worry too much about the steam aspect ( I could be wrong ). You can use whatever networking solution and still sell it on steam. You will need to add all the steam backend stuff in, but I think they have documentation for that once you purchase the steam page
I thought you could use steamworks.net for a p2p multiplayer but when I search tutorials for that, everyone uses a different way, or something else...
I’ve never used steamworks so I’m not 100% sure on that. Most people use Mirror, Photon or MLAPI
yeah i've seen the Mirror one, which would you recommend?
I like the simplicity of photon, both have their pros and cons. There are a few videos that’ll show you the difference between them
Oké, thanks man
No problem.
Hello. I'm making my own game server and the way movement works is: client sends which direction its moving towards and then server calculates where the player moved. How could I handle server-side wall collisions with this method?
when i join in the game on a second tab i somehow control the other tabs character instead of the character on the current tab
Make sure that you check in your input script if its the local player and if not then dont apply input
u mean like if(view.ismine) under camera script too or just in input
Mirror supports steamwork p2p multiplayer btw. Steamworks is only sending messages from A to B, nothing else, so to use it for multiplayer you need a higher layer like mirror on top of it.
NGO also supports steamworks multiplayer.
Mirror and NGO are both good options if you release on steam. Photon works great, but you pay for the relay vs paying nothing if you use steamworks.
Everywhere where you have input
You can have a collider on the server for the player, then if the player moves into a wall the physics engine would resolve the collision for you and move the player out of the wall.
So... I was following a tutorial for Mirror with fizzysteamworks and accidentally installed both v4.4.1 and v5.0.1 from fizzysteamworks in my unity project. I also installed the regular steamworks.net in it...
Did I screw up already?
Because I'm already getting an error and not the same steps as the one in the tutorial
Its fine, just go into Mirror/Runtime/Transport and delete fizzy steamworks and reinstall it.
Installing steamwork.net separately is required in newer versions of fizzy steamworks
Probably because you installed 2 fizzy steamworks versions
If you update an asset always delete the old version first as unity is really bad with updating
For example if the new version deleted a file then when you update the file will not be deleted from the old version
I deleted it, but still get a different network manager script then the one in the tutorial. I also get the error "the type or namespace name 'ESteamInputActionEventType' could not be foud
I was following this one
In this video I will be showing you how to get your unity project set up. How to host lobbies and how other people can join them. In the next episodes I will be going over how to display users, sync movement, create character cosmetics and much more. So make sure your subscribed to not miss out. :)
------Tutorial Links------
Mirror: https://ass...
What is different?
The error might indicate either a forgotten using statement or a problem with asmdef files
So yeah, first of all the error, and second: the first thing he/she checks on is "persist Network manager To other scenes"
I don't have that one in my network manager
a few other things that are different also
Oh
transport needs to be Mirror tho
That was removed, you dont need it
it doesnt work tho i put it under inputs. also which photon components does my camera need under the char prefab? like photon view. etc or does my camera folllow script need any photon codes or smt?
Its been years since I used photon, I would recommend you to join the photon discord, the link is pinned in this channel and ask there.
Oh so instead of the Mirror networkmanager KCP transport she uses fizzy steamworks script as transport. I tried to add that component but my unity can't find it for some reason
Thats included in fizzy steamworks
yeah I can find it myself in transport -> fizzysteamworks, but it gives me another error
the class cannot be found
"make sure there are no compile errors"
Unity will only compile the class after you cleared all errors, it never compiled it before so it cant find it
I think I'm going to delete everything again, even steamworks.net
and then start the tutorial step by step again
Ok
no more errors
now let's try this again xD
what method i must override in netcode that i can spawn custom objects , server and client side
Do you guys recommend using mirror + steamworks?
Hello guys Im making a multiplayer game. Does someone know why an RPC function is not getting called on the master client and only on the other clients. Im using Photon Network for multiplayer and i cant really understand why because the rest works fine.
Hello everyone, Im working on designing a course for networking from scratch (TCP,UDP,Steamworks)
I'm looking for 20 or so people to do some market research with , Around 15-20 minutes, Over the phone or discord.
If you're willing to get on the line with me to do some quick market research please PM me.
Much appreciated in advance.
why not have a google form or something? I bet you'd get many more response
Im trying to find the best things to put in the course and its best to do a 2 way communication , I can ask more clarifying questions if need be.
something that I've been curious about with steamsockets is if you use their protocol and their physical transport for routing since its free, is there a risk that steam might stop free access to their backbone?
does Unity Netcode have a way to talk to web servers?
I need to send information to my Apache server to get stuff from a DB
or do I need to use UnityEngine.Networking for that? I'd rather just use Netcode if it's easy
I mean in theory that could happen, but they wont do it, imagine them killing the multiplayer in thousands of steam games, that would be such a bad decision for them.
That has nothing to do with netcode, just make an HTTP request with unity's UnityWebRequest class
is there a way to see all online players name in photon, and when someone disconnect that online players list updates too
If you are still using UNet we just released a post which thoroughly explains how we are going to sunset UNet going forward. Starting from 2022 LTS UNet LLAPI will no longer be part of the editor. For more information you can checkout the official post:
https://forum.unity.com/threads/unet-including-low-level-api-now-removed-from-unity-2022-2-find-links-to-alternatives-here.1263392/
I've been playing around with Netcode for Gameobjects using UTP transport. I did the HelloWorld example. Everything is very much understandable and I'm loving the documentation. I later added a coroutine that pings the server using a RPC method and then server pings back - to measure the RTT. And I am getting around 40ms latency on a **locally **connected client, 3ms on host. (Server tick rate is 60hz)
This seems a bit high to me
Anyone have any ideas on why is it so high?
Hello guys
a follow this tutorial
Xsolla: https://xsolla.pro/Blackthornprod_PN
PART 1 (Multiplayer lobby tutorial): https://www.youtube.com/watch?v=y69wBS13wwA
In this unity tutorial we will use Photon 2 and the C# programming language to create a multiplayer lobby system!
This is a fundamental part of any multiplayer gam...
but i need help for create the select player box
i try since 3 days
and i dont I'm not advancing
i have created the same script like him
but i dont kknow what he used for do his menu
he say horizontal layout
but when i put it
is that
and him
I need help :ccc
How do I make a game object that connects between 2 game instances through the photon network
Unity uses C# and C# supports that easily
Any reason you wouldn’t just use Microsoft’s client instead?
I don’t know a lot about Unity’s and I’m a C# guy
If you mean HttpClient, I think it doesn't work on WebGL, while UnityWebRequest works. And UnityWebRequest is more optimized for unity (for use with coroutines, or downloading assets, converting data to unity resources easily...) - HttpClient is usually used in async/await workloads which is not really optimal for Unity. Then again - it's been a long time since I used this in Unity, so things might have changed.
Came here to report back on this.
I built a dedicated server and put it on one of my servers that is around 26ms away from my PC in terms of latency. Ran the game again and connected to it - clients again had around 40ms RTT - same as I had locally. Even though this time there was around 26ms extra overhead.
My guess is the buffering/batching going on in the background of Netcode, but how can I modify this? I tried changing buffer sizes but seemingly had no effect on latency.
Thanks for the info!
Ok, I'm confused about Netcode's RPC. I'm calling ServerRpc from the Client and get this error:
"ServerRpc calls are only allowed to be invoked by the owner of the Network Object".
I'm assuming this means only the Server is allowed to call ServerRpc functions. But, aren't ServerRpc functions supposed to be invoked by clients? What's the point of forcing me to specify "RequireOwnership=false" on ServerRpc?
A ServerRpc can be invoked by a client to be executed on the server.
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
Because the client can own the object
In that case you don't need the flag
It's safer to require ownershio by default
So you're saying the ServerRpc functions can only be called by the owner (default would be Server as owner of ServerRpc). But I can also specify different Clients to be owners of the ServerRpc?
So essentially, I am able to make a whitelist of who is allowed to invoke ServerRpc?
Yes, a client can be the owner of an network object
Then that client can call the serverrpc without the flag
But as I understand there can only be one owner
Got it, thanks a lot! So kind of like.... a built in firewall, only realllly limited 😄
If a Client owns the ServerRpc, would the Server still have access over the ServerRpc?
I don't think it would make sense to call a server rpc from a server?
Oh, sorry. I mean, would the server be able to change the owner of the ServerRpc
Anyways, you can't own an rpc, you can own the object
I think the server always has the authority to change ownership but idk
Ok thanks. I'll have to learn what an Object is 😄
It's the class on which you put an rpc
The rpc is the function
You call that function on an object
Hello someone can help me to implement a multiplayer menu for select the car ?
@weak plinth It's an incomplete question that no one can answer, not a request.
i want to have a menu with pun2
who i can choose the car befor the game
four player
and all player choose the car what he want to play
Don't tag people not in conversation with you.
And this would depend on how you are implementing multiplayer. There are tutorials which can help you with that.
How complex is it to setup GitHub to build new server (I use Mirror) at end of every commit? does it need any special effort and day of work or can I get it done with github actions (never used before)
I have VPS with Ubuntu
Ah Unity cloud costs money
I have a VR game running on an Android device (VIVE Focus 3) and want to share a screen to a tablet, as well as have the option to trigger certain functions on the headset (like resetting a level, skipping certain objectives, etc.). I asked an intern of mine to research this and he came up with Mirror, but it seems like his implementation causes a lot of lag on the tablet, since it seems like it's running the actual game instead of just being a separate project that shows a screenshare
Does anyone have any tips on how to achieve this functionality by communicating between two separate projects?
Can be done with github actions, just google on how to build a unity project with github actions, but it might still be a few hours of setting it up
Oh cool
Correct, mirror would just run the same game, in fact you dont even need unity on the tablet to make this work. You can just make it a small native app which would run really well, then in the game and app you open a socket to connect to each other. To send the screen you would want to use some existing video encoding technique to reduce the bandwidth required for streaming the video. Then on the tablet you can just take that stream and display it. For the functions simply open a second socket on a different port and connect it too, then just communicate over this one, easiest way (not the most performant, but in your case thats totally fine as your events you send are not sent frequently) is to send json objects as strings, and then just deserialize them on the other end. Then depending on what data is in the object you do something.
Sounds like a plan! Awesome, thank you
Anyone have this issue before when Host/Join (doing local testing and it worked fine a couple days ago)
KeyNotFoundException: The given key '60' was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <6073cf49ed704e958b8a66d540dea948>:0)
Unity.Netcode.NetworkManager.TransportIdToClientId (System.UInt64 transportId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.6/Runtime/Core/NetworkManager.cs:1340)
Update: It appears this is an issue when too many NetworkObjects are created and I found a post here: https://forum.unity.com/threads/netcode-for-gameobjects-keynotfoundexception-in-client-for-non-player-networkobjects.1217268/
I would like to implement a trading system on my game, but i dont have any idea how to do it, and i didnt find any tutorials about, could someone help me?
If it's just trading you need you might be able to use http.
For example i want to trade items from my inventory but no documentation founded
@humble crow Looks like playfab has a trade system
If you have all your inventory managed in playfab
yea i saw but supports only item to item,only doesnt support item for curency or anything like that
or something like a in game market like an auction system
Check out all the info linked on this page https://docs.microsoft.com/en-us/gaming/playfab/features/commerce/economy/
what are good general ideas to synchronize server and client?
Depends on what you want to synchronize
are NetworkManager.Singleton.LocalClientId's "secure" enough to identify who I should send data to?
I'm Debug.Logging the values, and I expected a long number since it's type ulong, but it's literally just 1,2,3,4,5, etc depending on how many test clients I have connected.
Wouldn't it be easy for someone to memory-edit their ClientID and receive someone else's data?
they can't edit the servers exe, it doesnt matter what they change it to on the client
ie. changing your id on your machine will not propogate that change to the server
Ok, thanks. I didn't know the ClientID/connection info was stored server-side. I thought the Server just asked each Client whether or not their ClientID was "this number" and trusted it based on the response.
the server is the one who controls all of that data
Gotcha, thanks. It's all handled under the hood 🙂
yes, it is all handled in MLAPI/Netcode transport layer
Anione that know how to use Scoreboard with photon can help me?
Im trying to apply this tutorial but i found some difficulties
Download SnakeCubed here
Android: https://play.google.com/store/apps/details?id=com.InfoGamer.SnakeCubed
iOS: https://itunes.apple.com/us/app/snake-3/id1408921148?ls=1&mt=8
For this lesson, we will teach you how to create a scoreboard that can be synchronized across the network in your Unity, Photon games. This scoreboard has a resort function ...
at point 6.26 for example i don know what means the .PS.
in the script
Hey there, I'm using Photon 2.0 to create a game and the RoomListUpdate() callback isn't working when a room is deleted (All players left the room.) Anybody know what the issue is?
😭
<@&502884371011731486> Phishing?
sorry my id got hacked
just shut up dude.
no fr ,
either way, your account needs to go.
Are there any real benefits in containerization the game server instead of just virtualization (kvm)?
Containerization has lower operational costs and usually scales faster, KVM has a longer setup time for each new instance. Thats why I would use containerization.
so lets say I have a ServerRpc that takes some info, then responds a result back to the ClientID that invoked it.
From what I'm reading, there's no way for the ServerRpc itself to obtain the ClientID from the Client that invoked it; the Client must pass its own ClientID to the ServerRpc. So the only way for a ServerRpc to respond is to use the ClientID sent by the Client.
Couldn't the Client just falsify its own ClientID, and the ServerRpc would send a potentially bad response to that wrong ClientID?
For example, Client 1 sends ServerRpc a command to log out, and that he is Client 10 (but he is actually client 1). ServerRpc trusts this, and tells Client10 to disconnect.
Is there any way for ServerRpc to detect and prevent this?
@pliant sundial But what about security? Is not easier to jailbreak from container(cgroup/namespace) than kernel instance handled by native hypervisor?
KVM is more secure, but you dont run user code I assume, so that shouldnt matter.
yeah, you are right about this one
We dont have access to youre game there’s no way to answer that question with the given information. https://medium.com/@gordon_zhu/how-to-be-great-at-asking-questions-e37be04d0603
Print this out and read it now. Then post it on your wall. Each time you have a question, read this again until it becomes second nature.
Hello all.... I have a question. So, I have netcode working with basic movement. but I need to use NavMeshAgent for movement. What is best way to do that? I have the NetworkVariable for position defined and is updating from Host to client but client position isn't updating from client to host/server. How do I go about updating NavMeshAgent on server? Or should I just send the click position to the server and then sync it back to client and let client do navmesh work? Well client not allowed to write network variable.
Maybe I should set the code for agent.SetDestination() as ClientRPC call, send click to server and then server can call the clientRpc for setdestination? But if I do that, I have to set the NetworkVariable position in client code in Update() and that removes the anti-cheat reason for running on server
?
Good afternoon! I’m trying put the photon engine in my game and I would like to have a camera follow the players. I have an idea of try to put a script attached in my player prefab, but I don’t know how I can do that. If someone can help me out I appreciate.
Actually
Just reread that. I'll try again when I get home lol
Ok, so I don't think you mean one camera to view all the players at once and zoom in/out (have done this before). I think I read too much in second time I read this. I'm not familiar with Photon but it's based on Unities networking and should still be pretty simple. Main Camera for each networked instance would be independant should can simply done like I first mentioned (at least it should work).
YOu could have a cameracontroller script like this attached to the camera
public Transform target = null;
[SerializeField] private Vector3 m_Offset = new Vector3();
[SerializeField] private float m_Pitch = 0.75f;
private void LateUpdate()
{
transform.position = target.position - m_Offset;
transform.LookAt(target.position + Vector3.up * m_Pitch);
Then in your script on the player, when the player is instantiated and enabled, in OnAwake you should be able to do something like this
If only someone could help me lol
lol I just realised this group is full questions and no answers.
That's because networking isn't really an easy thing, and the latest camera follow question probably could have gone in another code channel
guys, let say I just split my build
headless linux and the webgl client
you think it's possible to host it through cpanel ?
sorry for a 5 grade question T_T
Anione can help me how to instantiate a gameObject using photon but just for the master client?
I mean just one object for the room not one for each player
can someone help im trying to instantiate this using photon its part of a list
but i end up with this error
what framework you using ?
Could someone give a brief explanation of the difference of:
Listen Endpoint
vs.
Server Endpoint
Trying to figure out why clients cannot connect to host when using this:
GetComponent<UnityTransport>().ConnectionData.Address = ipAddress;
There isn't really documentation explaining variables and their uses. Should the client be using *.Address or *.ServerListenAddress to connect to the servers address?(Yes ports are forwarded)
@zealous vapor framework?
im using photon 2 free
asset
photon free version
here my script for the object instantiation
but its not working
its instantiating for all the players and not just for the room
What exactly do you mean by "just for the room"?
Photon has a unique (or weird) architecture. It needs a server to work but you don't code the server. The server is for authentication, matchmaking and other stuff.
So basically there's no object that's "just for the room"
Each object is associated with some client in that room, and instantiated for all users. The controller of it is responsible for updating its data.
If you use InstantiateRoomObject it simply means the object's lifetime is associated with the room (i.e. it doesn't have a player as its owner and won't be destroyed when any player leaves the room). What doesn't change is that there will still be a client (by default the master) that controls this object, and it will be instantiated for all players.
@manic jay got it
Man, 5 hours and nothin...
if I want my game to work over the internet It will have to be portforwarded right?
It depends if you’re p2p, or server hosted
Among other things
I'm using p2p
There is some information on port forwarding here and other places online https://mirror-networking.gitbook.io/docs/faq
I use dedicated servers so idk
In that case just use a relay, then your users dont need to forward any ports
He probably means player hosted instead of real peer to peer networking
Yes
Hi! Maybe someone could help, I'll first explain what I'm trying to achieve:
- I have multiple iPads running my Unity app
- imagine the app as a Canvas with a bunch of UI elements (text, images, pinch zoom images, nested scrollviews, videos, audios, etc.)
- I need to implement a "Teacher – Student" concept ("Host/Client" for networking)
- the app view should be identical on Host & Client
- host interacts with any of the UI elements — Clients see the changes reflected on their iPads. Clients do not have any controls, so it's basically a situation of the Host mirroring the screen to all Clients
i need help finding a way to get input from a client effecting one pefabe and not all using facepunch
at this point why reflect all the stuff? why not just stream it as a screen capture
and here are the ways I thought to implement it:
- some external software like TeamViewer, but there probably isn't such a solution to scale to 20-40 iPads reliably enough, with reliable graphics quality
- implement each Client's UI element's controller via commands from Host (e.g. scroll to x,y; pinch-zoom to pos, zoomLevel), which is sadly a ton of work
- some kind of nested networked object structure, which would "just" synchronise the whole UI hierarchy from Host to Clients — this would be nice, but it seems netcode/mirror/others(?) don't support nested network objects
have you tried Zoom?
have you tried Zoom?
tbh did not think about it till lately, I just assumed it's a major network/battery killer for the iPads
but realistically, compared to the difficulty of implementing other options — I will look into it more
you can also look at how people stream ipads on twitch
thanks, I'll try it. The whole thing is LAN only, but might be a plus, if I can host some local Zoom/Jitsi Server for it
sometimes an external point of view helps 🙂
Do you guys have any idea on how to fix RPC method not found error?
show code
Trying to figure out why clients cannot connect to host when using this:
GetComponent<UnityTransport>().ConnectionData.Address = ipAddress;
GetComponent<UnityTransport>().ConnectionData.ServerListenAddress= ipAddress;
There isn't really documentation explaining variables and their uses. Should the client be using *.Address or *.ServerListenAddress to connect to the servers address?(Yes ports are forwarded)
where si that
address is probably for client and server address for server
si?
Makes sense but why would the Unity Transport require the client to know its own address? Shouldn't it run a callback loop and store the data on its own and not complicate it by adding a variable to ConnectionData[] ?
no
the opposite
.Addrss is the address of the server, you set it on the clients
.ServerListenAddress is also the address of the server but you set it on the server
So technically leave it alone on the server as it should be, but set the ipv4 for the server in .address?
If this is the case, I tried that and could not connect using that either
That's what sent me down a rabbit hole trying to figure out how this new UnityTransport works
client uses adresss. serverlistenaddress is for the server, it sets what endpoint to bind to (but for most people you dont need to mess with this)
In this case refer to message above 😮
.address is the address you want to connect to as the client
Ok, which makes it function just like the old NetworkManager. The issue is it didn't work that way either. I triple checked that the port was forwarded and all.
So strange /: Well thanks @mortal horizon I will take another whack at it tonight after work.
yeah i cant imagine whats going wrong for you, setting .address to the servers ip for client works for me
Oh side note, should ServerListenAddress be blank or callbackloop 127.0.0.1?
Ok, I just remember reading somebodys bug report on an older version of UnityTransport stating it wasn't working correctly, but it probably has been fixed
Idk anything about that, i'm using the latest release, i never messed with older versions
@green reef are both devices on the same local network?
Ahh, ok just gotta mess with it, thank you very much, I might message you tonight when I get a chance to mess with it
Yes, but this was never a problem in Unity 5.x networking
are you using local or public ip?
if they are on the same local network, you need to use private ip
public ipv4
public ip will probably not work from local network
yeah that's probably your issue
Weird...worked back on 5.x, why does this netcode feel worse than the old one xD
it depends on your network setup, but in most case it won't work
it has nothing to do with the netcode
it depends on the way your network is configured
you must be mistaken, this is just how networks work
My old project had no problems connecting with public ip4 while on same network as the computer hosting, but I will try private just in case
Doubt lmfao
fact
well like I said, this is completely unrelated to the netcode
Gotta get the Unity Netcode API on a wikipedia style format so we can get documentation xD
Yeah, in any case, it doesnt matter what networking you are using, if there is some weird network setup that allows for what you described, its unrelated to netcode
they are redoing the docs i heard, so maybe it will be easier to find these things out, i was only able to answer your question because i have looked through unity transport source code
You rock! haha
can someone help me with this?
is
what's that?
where is that code?
it does, it has the playermovement + the photon view on it
ohhhh, it doesn't because I made it destroys itself if the photon view isn't mine
I'm such an idiot
Hello all.... I have a question. So, I have netcode working with basic movement. but I need to use NavMeshAgent for movement. What is best way to do that? I have the NetworkVariable for position defined and is updating from Host to client but client position isn't updating from client to host/server. How do I go about updating NavMeshAgent on server? Or should I just send the click position to the server and then sync it back to client and let client do navmesh work? Well client not allowed to write network variable.
Maybe I should set the code for agent.SetDestination() as ClientRPC call, send click to server and then server can call the clientRpc for setdestination? But if I do that, I have to set the NetworkVariable position in client code in Update() and that removes the anti-cheat reason for running on server
I would have something like a function "RequestMovement" or something like that that you call on the server from the client
and you pass where you'd want the thing to go
and the server would check if it's valid, etc
then you can compute the path and send it to the client(s)
Hello, I'm trying to use the Netcode for GameObjetcs package but when I add it the following error appears: Library\Package\com.unity.netcode.gameobjects@1.0.0-pre7\Runtime\NetworkVariable\Collections\NetworkList.cs(357,47): error CS0117: 'NativeArrayExtensions' does not contain a definition for 'IndexOf'. Already have Collections package installed but doesn't seem to fix it and haven't found that error googling, any ideas?
you have a typo, IndefOf -> IndexOf
the typo is because I have unity on other pc and copied the error by hand, the code itself is all from the unity github
unity version is 2020.3.24 and installed it via git URL
got to install it successfully on other project, so maybe is any kind of conflict with other packages?
just send the click position to the server and then sync it back to client and let client do navmesh work
Hmm... OK, I need to look at that again. But the problem is, if I let Client do navmesh work, Position doesn't sync to server and other clients
Its it solely dependant on navmesh or is it situational?
Also in theory the map should be the same and thus the navmesh logic should be similar soo it should only desync a by latency + how long it takes each clients cpu to process the nav path
Top down arpg style so mostly navmexh
so worst case is up to 1 second of desync is my rough estimate
It really doesn't take long, right now everything is just simple capsule and flat plane. Problem is, you can't sync client position to server, only from server to client
Even if i try to set the Network Sync variable in the client code, it throws error that it's not allowed
if it is action rpg you can write a custom movement that
if(raycast path to click point has nothing in the way)
then walk there while syncing position over net.
else
turn off position sync while navigating to position and send click position over net
which really is kind of what I want, I just can't figure out how to either tell server to run navmesh or allow it to get sync from client
Oh wait, yeah I could sent ServerRpc function call to server telling the server what the clients current pos should be based on clients navmesh
during update and server can update the position networkvar
so it's updated on server and other clients
I do sent the PointClicked destination to the server
so I could use that to do any verification
THe server calls ClientRPC now to send the click dest and run navmesh
bam
pretty much sending the pointclicked over server would be the lightest on netcode and just use logic on client side to make up the difference
Dang, thanks that helps!
Haha good luck!
I hope so. Every single result on google leads to a broken page on Unity. You need to use Google Cache to actually view it..
@mortal horizon I finally got a chance to try what you said and I am having no luck
I've tried both public ip with portforward, I've tried private ip. I've tried setting the address via .connectiondata.address, Ive tried .setconnectiondata(address,port), nothing connects, nothing gives an error message.
Does this: https://docs-multiplayer.unity3d.com/transport/current/minimal-workflow replace NetworkManager or do I use that instead of NetworkManager.Singleton.StartHost/StartClient?
This Transport workflow covers all aspects of the Unity.Networking.Transport package and helps you create a sample project that highlights how to use the com.unity.transport API to:
Port forwarding didnt work? Did you make sure to forward the correct protocol (udp vs tcp)?
hello! just getting into networking using Photon,
i set up a room create/join join system with a room list and all and it was working fine yesterday, now however for some reason the roomlist is not getting updated when someone creates/removes a room and i have no idea why
nvm, figured it out. i was clearing the roomlist accidentally
https://forum.unity.com/threads/photon-pun-how-to-handle-onroomlistupdate-function.1145306/
^^ what helped me if your wondering
Ok, weird issue. Using netcode. I setup basic plan, and capsule for player with navmesh and such. Everything works fine networked, using host and client over two+ instances. I have a biped character I put in and setup exactly like the capsule. MOved to prefabs in networkmanager. I start host and it works and animates. However, when client connects, the players ARE there, but you can't see them. You can see yourself on the host instance, but not the other player. On the client instance, you can't see either model. It has to be something with the character. I tried another biped character and minus the fact that the mats are all purple, the character shows up on both and moves but no animations (haven't rigged any animation stuff on it yet). What would cause a networked character to be invisible
At first I had the port forward set to TCP/UDP, but after a few videos of them all saying use UDP I changed it over and that still had no effect.
Is the networked object in the spawnable prefabs AND player prefab position on NetworkManager?
I have a small question, Im quite new to Netcode
How do I sync spawned objects when a player joins?
I have a script that check if i am the host, and then instantiates objects, also every prefab has a network transform and network object
Yes, I even created a new lowpoly char real quick, tired and setup idle and run anim. Imported and setup and I can see the char on both ends server/host and client
I'm convinced it's somethign with that particular model, but what and why only networked? lol
only things I don't have working with the new lowpoly model is animations syncing
Double check that you have a Network Object component attached?
If you see host and client I think its more of a animator/script references issue
.
Does this: https://docs-multiplayer.unity3d.com/transport/current/minimal-workflow replace NetworkManager or do I use that instead of NetworkManager.Singleton.StartHost/StartClient?
This Transport workflow covers all aspects of the Unity.Networking.Transport package and helps you create a sample project that highlights how to use the com.unity.transport API to:
Yeah I do. it's weird. I'm going to delete that char and maybe recreate/export. hopefully the issue doesn't come back. I'll just work with this new char and get animations synching for now
and that was an easy fix. Forgot to inherit networkbehaviour on my animation controller script.
Why does this not work to connect?
Something in the ConnectionApproval?
I have not touched ConnectionApproval, it should be as it came
What ip is in the Workaround script?
could have a typo like comma instead of period or space in it (i.e., 127.0,0.1)
Workaround script is just a side component because for some reason NetworkManager cannot store reference to a TMP_InputText
@restive mesa have you managed to connect two seperate computers using the new Unity Netcode. Not just locally via 127.0.0.1
Because 127.0.0.1 works fine, but as soon as you try to use the netcode in a way the users will, the connection just gets lost in space
how do i sync a function for say health using photon
Yes, this is entirely possible
Yeah, I just tested it. Working fine across two pcs. If you're using two separate devices, make sure your firewall allows incoming on the open ports on the server/host side.
I have the ports forwarded, I do not understand why it does not connect then...
also, if they are not on the same network (home-wifi for example) make sure the ips are routable, try to ping one device from the other and vice versa
same network?
I will try a ping test...it just sucks because I only get 2 hours a night to troubleshoot this then have to wait until day to talk to you guys
Even if you have windows firewall turned off, you still may have to go into Advanced Firewall Settings and add an allow for the open ports
yeah I know how that goes.... finally these days I get more time but... yeah I totally understand
My issue is that I did all of this and it works on my old unity project 5.x, but does not work here.
5.x had an older netcode, not the same as now. So its frustrating to see this "new" code not work
i think it's the UNet and the new netcode is part of the DOTS system
it doesn't but I am saying its not on the firewall or port forwarding side
you build the project and copy files to other pc?
yep
I ask that because I used to code server on one pc and clients on another... PITA
which version of Unity are you on now?
2021.2.19f1
ok, that's next up from me, I'm about to upgrade to that I think this weekend. How did you install the netcode?
the github repo?
man... that wouldn't work for me lol... probably because I'm on crappy inet
inet?
internet
Oh, you couldn't import it through git?
no I tried a couple times and said fine, I'll just download from github
Have you tried a "Clean" Build?
This IS a clean build lol
well sorry, what i mean is, when you Build the project in Unity, there's an option to "Clean" build it
What I would do if it was me as next step, download this
o
But if I was in your place, I would download this and try one of the projects in it, just see if it works by default and connects
Just open the testproject inside there and build it and see if it connects between the two pcs
testproject?
Add that testproject folder to your UnityHub projects and if that works, then something weird in your project. if it doesn't, then something with the computers network wise
@restive mesa if by some chance this is still not working by this weekend, could I bother you and share my screen for a troubleshoot session?
We can probably also figure out your character network code/animation problem
Besides the fact that client cannot connect to host on my project, everything works
Like a perfect house, with the door welded shut
Awesome! Rare to see anyone else who does netcode and actually helps lol usually it falls on dead ears in chats like these
got my animations syncing now, realized I needed to set animation state using NetworkVariable enum
lol
yeah, it's sad most of the "Discord" helps for a lot of channels I"m in are dead.
it's usually the Cryptos that are active but are infested with scammer
lmfao yea I stopped messing with crypto last year when I realized the only ones into it were the same friends that would always go scamming in runescape as kids
I loaded up testproject, and it uses Unet Transport instead of Unity Transport, could the issue lay in the transport I am using?
I can't REALLY test it until I get home, currently on a secured network with no access to port forwarding xD
Could be
lol yeah some of the crypto is sketchy, it's a lot researching what is good and what isn't and knowing to ignore all the scammers lol
Is a nat punch through or relay better for a p2p server
A nat punchthrough requires a relay to coordinate the punchthrough
If you know the dynamics behind it then nat punchthroughs are nice, but it seems easier to just explain to people how to port forward
NAT punch-through doesn't succeed for all users, so you need a relay fallback anyway.
guys noob question but is PUN 2 still the easiest for multiplayer stuff rn?
idk much about PUN or mirror or others, but I will say the netcode that unity has is nice. If you want something easy you can use Riptide but if you want someone else to host and manage your lobbies, matchmaking, etc, there's a few options but to me pun looks better
say if i want only for the player to move around and sync their character properties (name, level, etc) is netcode enough?
why doesn't NAT punch-through workfor all clients
Yes, I don't like how Unity separated the docs so just in case it's hard to find, here
Learn more about the available APIs for Unity Multiplayer Networking, including Netcode for GameObjects and Transport.
Firewall rules and/or anti hacking mechanisms on firewalls
so i should just use a relay instead
It's best unless you put in something require some changes. Just notify the user if you want to not worry about relays
Like Minecraft, until recently, was difficult to get working to some because of different network/firewall configs so there were instructions on how to get it to work
And actually, Unity's Relay is in Beta at least through december and is free until then
thanks!
I recommend going with a NetworkVariable because it will automatically sync the value when someone connects late
You're welcome!
@restive mesa I think I may have found the issue, check your project... are you using Unet Transport OR Unity Transport?
A NAT translates your public IP:Port to a private IP:Port. Most consumer NATs will assign for each private IP:Port the same public IP:Port, this is what at least one of the 2 people that want to connect needs to have. This is because a STUN server will first find both public IP's that correspond to the players with the games port, then a TURN server (relay) is used to tell each person the other persons public IP's. Players then connect to each other at the same time.
NAT will never let packets through it doesnt have a route for, but if a player sends a packet out it will create a NAT route, so if both players connect out it will open their NATs and they will be able to connect which is called NAT punch through. Full cone NATs, Restricted cone NATs and Port restricted NATs all fulfill this basic requirement.
Industry grade NATs and some customer NATs use symmetric NATs which will choose different public IP's for the same private IP if the destination is different. So when the STUN server checks the public IP it sees IP A, but when the other person wants to connect the NAT will use public IP B for him and will fail. If both persons have such a NAT they wont be able to connect, when one of them has a more open NAT then a connection can still be made. Also all mobile networks use such a NAT, which means if you plan on making a mobile game NAT punch will always fail.
Ultimately there is no way around needing relay OR you can do what I do and slave an old gaming pc as a Dedicated Server
Relay is the best option, if its a pc game then relay with nat punch is nice as it saves bandwidth, sucks that unity relay doesnt support nat punch though
Also sometimes you dont want nat punch since it leaks IPs. So in competitive games you want to avoid it, but then most competitive games use dedicated servers anyway
Unity Relay doesn't support it because it is 100% gauged to be a service they can sell the developers
I think they would succeed more if they spent less time trying to come up with ways to squeeze new developers and spent more time building those developers up so they have more people reaching that $100k mark and they can start collecting their 10%...That was the original draw to this game engine for me, all the other headaches it brings makes me sometimes regret not picking UE. But it is spilled milk and I do not have enough time to learn a new engine so its basically do this until I can't then quit for me xD
Been trying to get into bigger companies that hire Unity game devs but apparently 6 years of experience still ain't enough to get that callback hahahah
Who know great PUN2 ?
Oh my animation works now. I was using UNet but I've moved to unity for relay. Pretty cool, top down click to move using navmesh. Client handles the move but server calls set destination . Will work on server side prediction to restrict movement to prevent cheating
I just totally ditched that character model. I think something went wrong on the import or export. I was just trying to use one I had so I can have visual biped animation to make sure that was working multiplayer
Hello, I heard that it is possible to visualize .GEXF files using unity for data visualization. Does anyone have experience with this?
@restive mesa So the issue with my project is that <UnityTransport> DOES NOT WORK. I swapped back to <UNetTransport> and it works again, multiplayer between computers works good again. I found it because the testproject worked and I tried swapping testproject to Unity Transport and it stopped working.
Ok, and I think that's because the UnityTransport is for relay only
Just realized that last night when I implemented unity relay service
lol... yeah docs are lacking. I've seen worse though LOL
Dumb question. With Netcode and a NetworkManager in the scene with NetworkManager script attached, how do I specify spawn location of the player?
Hmm, theres a couple ways
first way is to just let them spawn and immediately move them to where you want them via script
the second is to override onserveraddplayer or whatever the function is called
but the second method may or may not work depending on how much changed since 5.x
I imagine it still works though
No its not, you can use unity transport standalone. just make sure you have the protocol set to unity transport and not relay
Ah yes, I see that now
Yeah, was thinking I"m probably going to have to override something likely in NetworkManager but, that script beefy. But I could do it 1st method I think probably more easily. Problem is, with NavMeshAgent, navmesh doesn't work if it doesn't spawn on the navpath. I currently and moving and then disable/re-enable navmeshagent but it's hokey
I think I just need to bite the bullet and extend networkmanager or something
WEll.... not every player will use same prefab anyways so I will have to manually spawn regardless
Hello guys how much does multiplayer feature cost in unity?
your soul
haha jokes aside, it's typically free for most people. There are 3rd parties who charge for using their api like photon https://www.photonengine.com/en/server/pricing
Redistributable cross platform multiplayer game backend for realtime games and applications. Develop authoritative logic with SDKs for android, iOS, .NET., Mac OS, Unity 3D, Windows, Unreal Engine, HTML5 and others.
Yes, this is a good solution, every project I write I make a Custom Net Manager. It is especially useful for saving data and such when players DC
If you are learning development, stick to hosting it yourself until you have some SOLID
or else you are throwing money in the wind
like if I have 1000 players would I have to pay anything?
I was doing some reasearch apparently there was something called HLAPI but its dead now in unity it used to be free, but now no longer exists?
Trying out Netcode for gameobjects, but hitting a hiccup immediately:
IsLocalPlayer
is returning false on the local player object that spawns when a client connects to the server
That object is in the Player Prefab slot in Network Manager AND has network object attached?
Try that and make sure the script calling IsLocalPlayer has using Unity.netcode
AND it needs to be a :NetworkBehavior script
unless you are doing GetComponent<NetworkObject>().IsLocalPlayer
another way to verify is while it runs in editor, click the object and look through the network object component in the inspector
So I looked and the object does have the network object component and is in the player prefab spot, but when it's spawned it's not the local player
@green reef any ideas?
@unique current Brief explanation of player connection script
any ties that might be interupting?
This is the connection script, start client is called when I click a ui button
This is the player connection script
I should be able to see Hi when it spawns
Change NetworkManager.Singleton.StartServer() to NetworkManager.Singleton.StartHost()
Is that all localplayer is for?
Does it not work for the player object of a client connected to a server?
No, but startserver will start as a server but not spawn that instance a player character
Oh yeah, I'm starting a server and connecting to it
if you starthost then it will start the server and spawn you a character on that instance
The player object is spawning
is the editor the server or the client?
The editor is the client
is the player in the spawnable prefabs list as well?
On older versions no, but this one has given me some grief xD give that a quick try
lets see your network manager in the inspector
thats super weird, ok well try to change it to starthost then examin both characters that are made in the editor
see if one suddenly becomes islocalplayer or not
MY GOD
I found the issue
delete the conversation
hide the evidence
I labeled the buttons wrong
How was a player being made at all then?
was that just a prefab sitting in the scene?
Well the server still spawns the player prefabs
You generally can't send references over the network. You can refer to networked objects by their PhotonView view ID, which you can convert to a reference with PhotonView.Find.
I'm trying to call this rpc function but it gives me that error, is it because that I'm referencing something that has photonview? and I should reference it with PhotonView.Find instead is that it?
Yea that gameobject parameter in the RPC just isn't valid. Alternative to sending gameobjects is to send the photonview viewid and use PhotonView.Find to convert it back to photonview, which being a component can then easily be converted to a gameobject.
got it. last question if you don't mind, everything that may be connected to players like gameobjects in the scene or even something that the player is interacting with that thing should have photonview?
Pretty much, but you don't need to unless they actually need to be referred over the network (or use photonview centric networking features, like RPCs)
alright. thank you
Hey! How would I sync a script/variables in the script to all players in a game? sort of make a server script if its possible, dont know exactly how this all works tho.
Hello everybody. I've been seeking an Artist that is capable of creating characters in Lowpoly/Polygon style, If you are able to refer me to one, or you are one, please shoot me a DM on twitter, or ping me in the chat, DMs and friendrequests are disabled since hackers are on the rise, my apologies.
Anyone knows how to connect to mysql in unity and use it?
Who know great PUN2 ?
Photon
i need help
For do a multiplayer selection of player
Dang it... anyone with Netcode instantiate the Client's Player PRefab manually?
Using the SpawnAsPlayerObject instead of Spawn and I've tried so many combos
I have the prefab in the gamemanager script which inherits from NetworkBehaviour. I've tied to the NetworkManager.Singleton.OnClientConnected and the Prefab is also listed in the NetworkManager
But I keep getting this error
KeyNotFoundException: The given key 'male_c1nc (UnityEngine.GameObject)' was not present in the dictionary.
I have tried just running with no tags. I've set it as ClientRpc and I've set it as ServerRpc and it either doesn't do anything or I get the error
nm
Figured that part out, but it doesn't spawn my playerprefab
Bro
This Chanel dont work
I have a problem since one month no people reply
Who know great PUN2 ?
Photon
i need help
For do a multiplayer selection of player
add this to network manager spawnable prefab list
Then to have a player put into a specific object, spawn them in as a generic object and have the server spawn the object you really want them using. From there re-assign them to that object
I dont remember the function off the top of my head, but there is a function that will move the players control from the generic object to the new object.
I typically use the generic object as a character select screen then delete it once player has selected
hey devs! what's the best way to sync physics using Mirror? I'm making a coop game for 2 players, so it's just host lobby & join lobby. Do I need to make physics calc on server only, like dedicated server thing? Is it even possible in Mirror? What's the best way to sync physics?
also, I have a few physics objects that players can interact with. So, 2 players can interact with a single object.
Guys do you know how can i créate a lobby for sélection player with PUN2 ?
Where i can choose a car
sorry, don't know PUN2
I have the prefab there, and the docs said if I use that, it will replace what they spawn with. I like the idea of maybe a capsule or something (or even empty object) then replace. Just need to figure out how to get the replace to work. It seems (according to Unity Docs) that the SpawnAsPlayerObject is supposed to remove the initial object and transfer control to the new object, but it doesn't so something is missing
Netcode
Ok top of the fact it doesn't spawn. And weird thing is, I built it and ran separate instance just to see what would happen. When player 2 connects, unity gives error that object had already been spawned, even though there were NONE of them in hierarchy
If I hook up a button in gui to spawn, it spawns the object but original stays and both are controlled.
I'm trying to instantiate and spawn in OnClientConnectedCallback and didn't spawn
I have an idea how to get around it but what does unity expect of us? Where and when SHOULD I spawn manually? Nothing in docs I've found.
Idk what the problem is, but these days, companies absolutely suck at documenting
Boil it down for me, what are you trying to accomplish?
Or show the current code that doesn’t work
To manually spawn player prefab
I think what I'll have to do is spawn an empty GO initially, then SpawnAsPlayerObject. Nothing else seems to work well
According to Unity docs, when I call SpawnAsPlayerObject with a button press, it supposed to "replace" the original playergo with the new one. But original stays and can control both. Not bothered too much about that as I can probably just destroy that original but I'm confused as to what Unity is expecting us to do, it's not clear.
is that how I SHOULD do it? Is there more to it than the "Just call SpawnAsPlayerObject instead of Spawn" that is in the docs?
MLAPI isn’t complete which is why I use mirror
I can’t find documentation on SpawnAsPlayerObject so it’s hard to help
But I don’t believe SpawnAsPlayerObject replaces the old one
Yeah, I'm lucky to have found it
Netcode for Gameobjects' high level components, the RPC system and the Object Spawning System, rely on two concepts: NetworkObjects and NetworkBehaviours.
I do see now a note below that that original will still exist
If it’s similar to mirror there’s a method called ReplacePlayerForConnection?
It's probably similar to that
Check what methods start with Replace
in fact since Mirror is built off of unity's code, it probably implements something like that
First off though, can I see you’re code and the error you get in the console if any?
You are using parrelsync to test?
Well originally, I gues s I should say, I was trying to call in OnClientConnectedCallback which would not spawn anything
Are you using parrel sync?
which is why I was posting to begin with, but it looks like even in their BossRoom sample, they are creating an Empty GO and then spawning new.
Sorry, not sure what that is
Trying to figure out waht all they are doing to spawn (and how) in boss room... just a lot of f'n crap to go through as usual with Unity. Put out "Sample" project with 5,000,000,000 lines of code scattered across 2,000 files
lol
Get it asap
asset store?
Also, sounds like you should just switch to mirror
Github
I don't want to use mirror as I will have servers setup not just for games but other stuff not to mention blockchain integration. It's a bit comlex and I've tried to use mirror once before and just wasn't robust enough. I dont' want to try to hack around their code
parrel sync? or parallel sync?
Yes
You’re crazy if you think Unet will solve any of the problems you had with mirror
Ok, that looks pretty cool
You can’t even spawn a player… Fishnet has a lower level networking solution if you need that but I don’t think MLAPI is for you
Netcode, not focusing on MLAPI
I thought mlapi was going away anyways? or maybe just beta, I can't remember
yeah it's crazy
I don’t see any issues you could run into with integrating the stuff you want
What exactly are you worried about that mirror won’t be able to handle?
Maybe I could let you know if it would actually be a hinderance
I don't want to be paying for a service if I have servers already in place I'm paying for.
Netcode for GameObjects is the new name for MLAPI, UNet is the name of a transport for NGO and also is the name of the old multiplayer HLAPI which is deprecated
Mirror is free…
I would recommend mirror. everything you are having trouble with NGO, mirror can do pretty easily. also like apex mentioned, theres no pricing model, its the same as NGO
While I do appreciate the direction ngo is headed, I'm not sure that it's ready to be used
(If you are planning on releasing a game soon)
Anyone know photon please
I am one of the devs at Photon. @weak plinth Though for photon questions you may want to hop on the Photon discord.
can you send me on mp ?
yeah, discord links in this channel are blocked. PM'd you the link.
Discord links are also pinned in this channel.
Ah yeah, Photon's link is in the pins. Thanks @oak flower
Maybe I’m just being a snob but I wish it was an enforced rule that Photon questions are rerouted to the Photon discord…
This channel has no actual networking talk, just questions about premade assets. 🥺
Erick and I used to frequent this channel quite a bit and answer Photon related questions here, but we got pretty busied up getting Fusion out of Beta - so we try to encourage any Photon users to hit the Photon discord (since everyone there is using the libraries in question). Now that Fusion is out, we might check here more often.
The talks were not specific to photon products, but more just general networking concepts.
Most talk though is typically related to a specific product, be in NGO (MLAPI), Pun, Fusion, or Mirror related. Not sure that is avoidable.
hey! is anyone here familiar with the normcore multiplayer stuff, theres an issue where when the first player joins they get there view for there person, but when a second player joins, the first player is forced to see through the second players view
**(1) Using Netcode for GameObjects, is there a way to add/register Network Prefabs to the Network Manager from a script?
(2) Also, is there a way to reference Network Manager's Network Prefab list?**
I'm trying to create a general spawn function to spawn any Network Prefab, and I thought it would be easier if I created my own list of Network Prefabs, or at least was able to reference Network Manager's list.
guys, I made an RPC function in the player himself which allows him to get inside of a something that has a Photonview but it seems that when another client join the game I cannot call that rpc function no more. Do you guys have any idea how to solve this?
Anyone got a video or blog post that goes over multiplayer game administration? More specifically, what kind of features you'd need on an administration panel (i.e., managing players and inventories, game events, etc.) and how to go about implementing them. Doesn't necessarily have to be made with Unity, I'm assuming a lot of them would be web-based from what I've seen in other games.
photon pun player disconnects when the mobile screen turn off ??
how can i fix that??
you can set screen timeout to never timeout
do you know any reference code for that ?
I've switched to using sending inputs to server instead of position but i have a problem because on the server the position doesnt match clientside then
it gets more and more off
using charactercontroller.move on both ends
what i send is :
w a s d : bool for each
camera y rotation : float
What am i missing? D:
oh maybe because the packet when i change inputs arrives late.. :|
MIRROR 66.0.9 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
nice
Send key to server and sync position from server to client ?
yea but its getting off very quickly
also how do i send keys only if my walking depends on camera forward and right vectors
Anyone have any tips on substepping multiplayer networked physics in Unity? So far the best solution I’ve implemented is putting each player in their own physics scene, but that requires a lot of weird workarounds for collision detection.
Unity is using floats which are non deterministic, that means you will get different results on different devices.
if i send the move vector instead like the dir in controller.Move(dir)
i get more close results but still kind of off, dont floats work same under the hood on the server and client? why would it have a different result?
Floats can't represent all values, you can read about it here:
https://www.geeksforgeeks.org/why-floating-point-values-do-not-represent-exact-value/#:~:text=The floating-point numbers serve,with a minimum tolerance value.
Since they cant represent all values it sometimes has to round to the closest value it can represent. This rounding is not standardized on different CPU's. So the result is different between x86 and x64, it will be different between Intel and AMD chips, it can even give different results between 2 cpu generations.
Also I'm running it on the same machine in the same unity version
server and client i mean
wow ok but still on same pc running side by side?
Editor might compile your game as a debug build while the actual build is compiled as release build. In release builds the compiler will do some optimizations, e.g. it could reorder math code, reordering floating point math can mean that it will also give a different rounding result.
im running both in the editor tho 🥴
If you want it to be deterministic you would need to use fixed points representing positions and then recreate all unity systems from scratch using fixed points instead of floats. But instead of that it would probably best to use Quantum https://www.photonengine.com/quantum
In Quantum they already replaced all unity systems like physics with their own implementation that uses fixed points.
Do you think spending a year of fulltime work on recreating it would be cheaper?
Quantum is getting a free tier soon that everyone can use
and what about this case
My guess is your timing is off. You need to turn off the physics simulation and then you can simulate on the physics engine manually in fixed time steps. Now you need to apply each clients inputs in the exact same simulation tick in all game builds. So if client sends input for tick 60 then on the server you need to also run it on tick 60. And if you figured all that out then you still cant use physics because PhysX will return different results each time you run it, even on the same device in the same build.
oh wow
how does that happen tho i wonder
physx doing some randomisation on floats? 😂
Some physics engines use random number generators
So its not only a rounding problem
ok thanks so i think i will use this and just correct the clientside if it gets far off
i dont need deterministic i guess
also how did they solve the issue with the floats and physx stuff? they use integers and their own physics? talking about quantum
Thats how most games do it, its called CSP (client side prediction). Client sends input to server, server has full authority over the clients position and sends the current position to the client. To hide the lag the client predicts its position, so after sending input it will move according to the input. Then when the server sends the position it will correct its position if it was wrong.
They use fixed point math, basically created their own deterministic floats and they also wrote their own physics engine.
should the server send back to the client his position every time the player did an input?
oh cool
but i think quantum is overkill for my project
Yes, you should still base it on a tick system that runs in fixed intervals. So that client send input for tick 60 then the server will answer with the position for tick 60. That way you know on the client which position is for which tick
so i need like an id for each input?
im talking about wasd movement in a third person game btw
Yes
the thing is, movement is based on the camera's forward and right vectors, so i would have to send the players camera rotation as well? or just the player moving his mouse aka camera rotation as inputs, but then wouldnt it be different for every player depending on their mouse how much their camera moves?
What CSP usually does is that the position it receives is in the past, so resetting would teleport the player back, so it will save its last positions, when servers position for tick 10 arrived it will look in its past positions for position at tick 10. If its different then it will reset to the servers position, but then also rerun the next few ticks inside a single frame to catch up again so that you dont show the client past positions.
I suggest you to read up on how csp is usually done
https://gafferongames.com/post/networked_physics_2004/
yea i kind of understand csp
thanks for the link
but i dont see it talk about rotations
in there it assumes you can only do wasd and jump inputs but what about turning the camera to aim... its a fps as he says and thats what ppl do..
move camera and thus wasd needs to be interpreted accordingly
You just want the player to decide their own camera aim. It would feel awful if your camera aim would move a little all the time when the server sends a different position.
so i send to the server the camera y rotation every input frame as well?
public class Input{
public bool w,a,s,d;
public float cameraY;
}
kinda like that?
im gonna use this instead for now
public class MoveDir{
public Vector2 dir;
}
If you wanna save some bandwidth you can keep your bool inputs in an enumerated array and then compress that array into a single int representing the whole keyboard state
I spent weeks reading Gaffer on Games’ articles on this stuff and they are amazing. Also highly recommend Gabriel Gambatta’s short series: https://www.gabrielgambetta.com/client-server-game-architecture.html
what about mouse/camera
more precisely mouse movement as in turning camera
You still need to send a float for your rotation, but your serialized user input class could contain these compressed representations of input
Advantage here being you can unpack the individual key binds on the server, which you might need depending on the complexity of your gameplay
you wanna use structs, allocating a class every frame for input will bog down your game
Photon Fusion also handles client prediction while being a lot more accessible
Assets/Plugins/Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs
help please
All Unity projects must use ExitGames.Client.Photon.Hashtable!
This provides compatibility across all exports.
Add this to your code (at the beginning), to resolve the "ambiguous Hashtable" declaration:
using Hashtable = ExitGames.Client.Photon.Hashtable;
I'm trying to build boss rooms on unity 2021.3.0f1 ('couse i want to start my next project on that unity version and want to test everything there), getting error - error CS0012: The type 'NativeHashMap<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Unity.Collections, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
tried to solve it with installing package unity.collections with 2 methods, with this link - https://github.com/needle-mirror/com.unity.collections and writing com.unity.cellections in add package with name..., both of them installed package, but game still cant be built, is there anything i can do about it, or i just have to download unity version game is made for?
Ehhhh resyncing the state fixes that tho
It’s absolutely doable.
State rollback and resync
Hey guys. I am having issues with building my game. This issue keeps popping up, and wouldn't build my game
how do i give the object athority?
yea i did that but after that i got a lotta errors then my game became anusable
hey, i'm using photon pun and i'm looking for a way to make the last person in the room the winner
i tried if(photonnetwork.playerlist.length==1) then make that player the winner
but it doesnt work since if a player joins the room for the first time it will also becoms the winner
i want a way to make sure more than one player joined the room then if from that list they leave and one left they become the winner ??
anyone know how ca i achive that
What networking solution is peer to peer other than the depricated built in one?
PUN is peer to peer over relay, which I imagine the built-in was too.
Thank you! I'll look into it.
How so? Let us know the errors.
:d
Hi there, I'm using Photon 2 and my OnRoomListUpdate is receiving a list with count 0, anyone have an idea why? Thanks!
hey i tried using lan hosting. it says client connected but i cannot see any players. why could this be
Can you be more specific? Networking solution, any errors, player prefab
Make sure you have joined the lobby
Try using the onPlayerLeftRoom callback in the callback method check of the playerlist length is then equal to one in the current room
here is what i did , i added a bool to check for player joining, in the onjoing method i added a condistion if list of players joined the game > 1 then make this condition true ( it basically means more than one player joined this room)
so this condition will become true as long as two player joined even if one of them leaves
then in my winner method i said if the condition is true and if the player list= 1 ( means players have left or died) then make that last player the winner
but i have a problem
if the last person who is left is the master server then nothing happen, i have no idea why
the other player can become the winner perfectly but it never happens for the master, very strange
im making an online fps game, but cant find a networking solution, if u have any ideas pls inform me
Strange. could you share your code
it is very very strange, because when i print the player list it tells me there is only one player in the room, but the condition for having two players in the room also becomes true
In my years of coding this is my first time to face something like that
anyone has an opinion on which networking i should use?
You can visit their discords and ask around first hand what are their strong points. Links are pinned here top right.
👍
Check your dm
Hello. how to deserialize json array in unity? I tried wrapper class but it didnt work. Now Im trying with NewtonSoft, help, please? Im getting error when trying this
@solemn haven it probably doesn't match the format
Try with something simpler
Or even better
Serialize the ShrineLvlData[]
See the format
Might spot some mistakes
Hmm looks allright
There are some fields that don't match but that should be find, they just wouldn't be mapped
@solemn haven Try doing List<ShrineLvlData>
instead of ShrineLvlData[]
Hey guys 🙂 So I want to start making some kind of multiplayer game where you can send stuff like trains, planes and ships to eachother, have a guild, etc. but I don't know if I should go with the Unity Networking System or PUN2 or even something else I haven't heard of
Oh I also have to say I'd like to have it working with WebGL
@uneven hawk So it's like travian?
No realtime interaction between players?
If that's the case you probably wouldn't wanna have a realtime server
Which also means no unity in the server
Yeah kinda. You can send a train to someone which has a time until it comes back and at around half that time it arrives at the player you send it to and can be served
That's it
Wanna have a chat tho
If that changes anything
So you need a database
You need requests
And you need some scheduled events like trains arriving
You can use a managed third party service for chatting
I think you could find and adapt a chat api
I don't know how hard that would be but probably much easier than creating or hosting it on your own
So I know that PUN2 i.e. has a method kind that is used to synch a method in a room
rpcs and commands you mean
Yes
Well pun is for realtime stuff
You don't need all the complexity that pun and unity brings here imo
I wouldn't say Unity and pun are a good option for the type of game you wanna build
Well at some point I want to have events, quests, etc.
You can use unity in client though
Thats totally fine
But I'd like to say that the server doesn't need unity for these types of stuff
You can implement them in your backend and game logic
In server
You'd want everything to happen on serverside
Client would just query the quests and their state
Just for displaying
There are also ways for a http backend to send events to the client
For the event stuff you want
The thing is that I don't own a server nor can get one currently and so I have to stick with client based stuff (for now it's just for me and friends so no cheating)
So everything would be saved on PC or maybe even cloud if I do that and just want the players to communicate
You could find a managed database server
And a function app
function apps have free tiers
What's a function app?
Yeah maybe
Azure cloud functions
They just process requests
You should also have some stuff for authentication
We let the playfab handle authentiation
Every request passes through playfab and its guarantied to be coming from an authorized client
I just haven't used a database yet
But I'm sure there are free tiers for managed database servers
In some cloud or some third party api
I am rly thankful for your help but that's a lot you throw at me there 😅 For the beginning I just want to connect the players and save stuff locally
Since I never rly worked with something else than PUN2 and I only did it once for a chess study project
Also what about privacy policy if I use stuff like AWS, Playfab and managed databases?
privacy policy? hm
well you just pay money to azure/aws
if you pass some quatas
which are kinda hard to fill
what are quatas
you gotta check them out
I don't think it'll ever be of an issue
It will be free for your needs
If you surpass those quatas money wont be an issue for you anyways
Cloud functions are very cheap because no resource is allocated for you that you aren't actively using @uneven hawk
Its not like a virtual machine or anything
How do cloud functions work exactly? I mean I know that it is code run on a cloud but I don't understand more of it haha
you have connection string
a long string thats supposed to be secret
you use that to call the function
its an http call
somewhere far away a supercomputer allocates an instance of your app
or picks one in the pool
the instance runs your code and responds to your request
more people you have requesting, more instances get allocated
and you get paid per request after the free quota is surpassed
ah yes:D
Just quick: Are you german?
nope why
Would make things easier haha
ah
ok nvm
I mean my english isn't that bad but that stuff is completely new to me and hard to understand
im turkish
Okay and how exactly would I use those cloud functions?
Like for sending trains or something
I use them through playfab
playfab knows the secret connection strings
calls them for the behalf of users
You could probably also look for an authentication service
You need some sort of a gateway like that
But from there on though,
Behind the gateway, all your services can communicate via secret connection strings
So let's say P1 wants to send a train to P2.
- P1 selects P2 in a list (let's say it's a Friendlist)
- P1 selects the train he wants to send and clicks send
- Now P1 as client connects via auth gateway and is fine to proceed
How would it go any further? If I understand you correctly now a cloud function could be called but to do what? How does it tell P2 "Hey you got a train on your map that's arriving in X minutes"?
Btw. could I use Unity Authentication (currently in beta) for auth? @high night
Can have that info in your data
You should be able to query trains arriving to your town etc
I don't really know, I am new with these stuff as well
Ah ok. Might just check it out then
The auth service is just to make sure you're a real user who is making the call, right?
And to identify you so the functions can tell who is sending the train
yes
yeah and that function would do some database queries
Hm~ I thought that there is no need to save the incoming stuff for a player in a DB but I just noticed that I have to because otherwise they would be gone after disconnecting lol
Yeah
@uneven hawk Cloud functions dont store any data
Not like your realtime game
You follow some constraints like this, you might as well have made an infinitely scalable game in the end
What you mean?
If you do things right, your game will be able to server infinite customers
Because everything is on cloud
Yeah I know. In the beginning I thought to just tell a player via RPC "hey you got a train incoming" and let it save the incoming list locally but that's stupid
And assuming you are not creating any chokepoints
What you mean by chokepoints?
Like if there's one row of data
That all the players need to read/write
That'd be a chokepoint
Hm~ A friend just told me about UGS right now which has Authentication and even Cloud Code
And Cloudsaves
This sounds like what I need
That could do I'd think
sounds like playfab
might still need another database though
their userdata might not be enough for some stuff
Well that shouldn't be the problem in the end
But could be enough for now to playtest since I just wanna play with some friends at the start to test things out before going live
@high night So just make sure I understand the concept:
- Sending a train to a player ads it to your "Sent trains" data and to their "Arriving trains" data in the database
How to tell a player to update their list now if I don't want to do it every few seconds? You said something about an event or something but how would I send this event to only a single player and how to even send it if they're not connected in realtime?
@uneven hawk Try to avoid updates
keep a sent time
check current time and do logic when client polls
keeping the data in two places is also not very nice
but i dont know how you'd avoid that without a real database
there are probably some ways to avoid it, i'd try to think a bit further
to avoid data duplication
Would you instead have a list of all active trains with "sent from" and "sent to"?
And how would a player receive updates of their incoming trains list if they shouldn't do updates?
I mean.. if they stay at the list the list HAS to update once in a while
And since some trains might have an arriving time of lets say 2min they at least should update once in a minute
clients can poll once a minute
@uneven hawk
while they poll maybe you could do the logic
letting that process start the control flow
or there can be an event system
and scheduled events
for when trains arrive
your backend could invoke something on client side
but thats some advanced stuff
I don't know much on these topics yet
Things can be made millions of different ways really
true
Why again would I use Cloud Code? Can't I just do Reads and Writes clientside?
At least for the sending and checking for new planes part
@high night
Or would you put that into cloud code as well and just use HUD stuff clientside?
you shouldn't access database directly on client @uneven hawk
that'd be a security problem
Oh okay
and it'd make things hard for you
Why?
you'd want you business logic to be seperated from database access anyways
you should have one function to send a train
from baseA, to baseB, with supplies[]
one function to get all "train"s coming towards given base
one function to get trains going outwards from given base
that'd just be for data access
nothing else
just to read and write some records
and then you'll have the functions that do business
both the data access and business should be at server side
What you mean buy business
client should only have access to this:
SendTrain(target player)
PollOutgoingTrains()
PollIncomingTrains()
Or just SendTrain and PollTrains
Business logic is how your trains operate
They should drop off resources etc
business layer access database through data access layer
Which only send a request to the cloud code and show visual stuff?
Poll train is for recieving the data on trains
then client can update visuals with the recieved data
SendTrain wouldn't return anything
just a success or error msg
@uneven hawk you can check out some on layered architecture
view -> controller -> service -> dao -> database
So on client side would be a method ServeTrain() which calls the corresponding cloud method and receives the data and then update visuals?
ServeTrain sounds like it wants to do some business
You cant depend on client to do business
if i get it correctly
Client should not be responsible of the state of the game
It only does rendering and sends commands
Well it works like this:
- P1 sends train to P2
- P2 sees incoming trains in a list
- P2 can now tell a train that is arriving to drive into the station
- P2 can click on a button on the train to tell it it's being served
- Serving means it adds stuff to the inventory and shows some animation
- Train now automatically drives away and is not longer listed
- If a train isn't served in time it gets deleted from the list that shows trains for P2
@high night ❤️ 🙂
Kinda busy right now @uneven hawk
You look like you got a plan
Just keep the clients access simple
no probs good luck
thanks
Hey folks, I am making an ASP.Net API to work with Unity and wanted to know what datatype I should have my API return. Is there a specific one like JSON or Ok results or is it dealer's choice and you have to adjust your code on the Unity end. (I'm hoping this is the right channel for this question haha) Thanks in advance!
I plan on using UnityWebRequest to communicate with my API
Dealer's choice, pretty much. JSON'll be a little bloaty, perhaps, depending on what your game looks like, but it has the advantage of being easy to read (for humans). You could pack it with something like protobuf or MessagePack (which is what I use), which has the advantage of being agnostic of Unity and extremely small - I have some pretty large data models with a complex data hierarchy, and they pack down pretty nicely. But, obviously, in doing that you're not going to be able to read your messages, so you'll have to unpack them and explore them either using reconstituting the objects and using a debugger or converting them to JSON anyway.
Thanks for the response! That makes a lot of sense from what I currently know of Unity. This is a small project with small models, so it seems like JSON won't cause too many headaches then. For context, I'm making an API to do a dark souls message system in a simple Unity3d app that is just a space to put them in and a camera. Unless there is something more to the bloat of JSON it seems like my best bet.
when you say "message system", what do you mean?
The only reason I ask is if you're thinking about messages as "aim my character to orientation 15,15,15" or "start moving forward" or "end moving forward" then those messages are going to be really large
(like if the client needs to send them 30 times per second)
Oh man, that would be a lot of data haha. I meant the Dark Souls text messages that players leave for one another. My Unity app will be a 3d space with a cube where each message is at that, when hovered over with mouse, shows the message. A persistent message than can be seen on multiple computers at once. So the data the client is grabbing and sending would be tracking the message, user, and coordinates of the cube.
Thanks! I can't say it's entirely mine. Someone from another developer discord helped me out with it. I'm in a full stack bootcamp and wanted to have a personal back-end project I could do as a game dev oriented portfolio piece.
Cool, best of luck. The part part for projects like these honestly is the .. knowledge and configuration.. once you sorta figure it out, the implementation is often the easy part
(he says as he randomly smashes microsoft azure portal buttons frustratedly)
XD
Thanks! Funnily enough it's going to be the unity stuff that will probably give me the most trouble at first because I'm coming in hot from Game Maker haha.
heh, yup, well, all those kinds of questions are pretty well answered in the code-XX channels
I used GMS back in the day.. whew can't believe how far I got with that software
It's honestly a really strong engine. It is capable of a loooot of stuff. Really tragic that it hasn't gotten as much traction as Unity because I think they both have a place and are good for development.
Yeah.. I mean, I like it too but I can't help but feel the scripting environment is really too simple.. I was just banging my head on trying to do stuff and in retrospect (after like 3 years in unity) GMMS looks like visual basic to me now
Won't disagree with that, but I think the simplicity is a strength even if it is definitely not for everyone (or every project). That said, the documentation is insanely good.
Once again, thanks for the help! Spent a looot of time last night digging around online.
Yup the lobby is joined!
The room also has IsVisible set to true
I also made sure that the OnRoomListUpdate is being called
do you guys know what kind of rpc that fires in a specific client between the others? like adding listener to a specific clients but not to the others
Don't know if this is still relevant...
There is a Matchmaking Checklist in our doc pages. Could be some user is in another region or using a different Game Version.
Check out this list:
https://doc.photonengine.com/en-us/pun/current/lobby-and-matchmaking/matchmaking-and-lobby#matchmaking_checklist
TargetRpc
which one of them? because I think that none of them could only be sent to a specific player only
I don’t know which networking solution you use
If it’s Mirror, there’s only one TargetRpc and it takes a parameter of type NetworkConnection which specifies which client receives the message
I'm talking about photon pun
It's just in Unity, so it's using the Photon network settings. The version and region should be the same on all, but is there a way to check to make sure?
here I have the gameversion set
In the PhotonServerSettings I have the app version and region set
I figured it out
It was indeed connecting me to a different region on the Quest 2 Build
Thank you for the help!
Guys who have ever used PUN: please tell me, in the simplest possible language, what does the [PunRPC] attribute mean? I can't find anything understandable on the Internet