#archived-networking
1 messages · Page 88 of 1
why this line returns an error? sound = DownloadHandlerAudioClip.GetContent(url);
url is public UnityWebRequest url;
and sound in AudioClip
the webrequest is null, thats what it says
Hey, I'm using photon for networking and everything works fine. But for some reason, I have 2 players on 1 client. Can someone please help
hey folks
if i just want to make a chatroom, like discord but with 3d avatar moving around in my game.
before diving into network scripts, i want to know how costly it is and which service to use for a simple chat. firebase ?
there's plenty of services for this task and i'm just confused
simply free chat + avatar movement? photon
@keen laurel
ccu (connected players at once) limit is 20 in the free tier though, mirror is another option (no ccu cap) but requires more knowledge for setting up a server, port forwarding etc
photon though I must say, you will get up and running the quickest comes with it's own chat / voice, players won't have to setup port forwarding they are simply connected + huge amount of resources available
reasonably priced for what it provides once you leave free imo.
@weak plinth check if local player before doing local player input
https://forum.unity.com/threads/photon-2-if-local-player.866071/
^ guy had the same problem
@keen laurel no worries :)
search for the mirror discord (not sure I can post here), lots of friendly people who know their stuff can help you get setup 🙂
Good Morning, I already had a good discussion with user here that helped me a lot, but I am still lost about porting my local "pass the screen" 2player game into PUN2.....
i started testing stuff (after tutorials) using RPCs that hide/show UI panels from the players, depending if it's their turn or not. and evidently it's the wrong way to do things.
but I'd love to have someone point me in the right direction, logic wise: the main gameloop.... so far, for my local 2p version, I have coroutines that go one after another and switch from player1 to player2 ....
I feel that for the online version I will do something like : a gameManager that deals with going from Turn to Turn, knowing whose turn it is...and sending an RPC (or a RaiseEvents?) to each Players telling them : it's your turn (you can show your UI / allow actions) or it's not your turn (hide your UI, block actions)....
should this be in the Update function of the gameManager? will this be run only in MasterClient ?
thks for your guidance !
Hello, im trying to make speedhack anticheat but can't really figure out how to get the time between sent commands. Any ideas how to do it properly?
Here's my code
[Command]
void CmdSendPosition(Vector3 _position, float _playerAngle, float _cameraAngle, double sendTime)
{
double _timeDelta = sendTime - lastSendTime;
Debug.Log(_timeDelta);
if(Vector2.Distance(new Vector2(posDestination.x, posDestination.z), new Vector2(_position.x, _position.z)) > (movement.runSpeed + 0.5f) * _timeDelta)
{
ReturnPlayer(connectionToClient, posDestination);
}
sendTime is player's NetworkTime.Time
you mean owned?
local can mean a lot of things, so you might need to be a little more specific @short mortar
How can I get unity to connect to a nodejs server using websocket and send and receive packets?
firt of all do know photon BOLT?
I would join the Bolt discord for any Bolt specific questions first. Going to find a LOT more bolt users there.
Bruh trust me the server is so inactive
I asked there
no one is replying
I don't know Bolt well enough to give you a good answer. Just helping you clarify your question for others.
if they are familiar with bolt or networking in general they'll understand what I mean
wait I think I found a solution
thank u for helping tho
really appreciate it
hey guys! I'm trying to spawn dynamically generated objects the same way on all clients (Mirror Networking) and could use a hint!
I found out that I should use ClientScene.RegisterSpawnHandler() for that, but I don't know how to link the asset id to the NetworkIdentity...
_currentPiece = child.gameObject;
NetworkIdentity nwid = _currentPiece.AddComponent<NetworkIdentity>();
Guid pieceAssetId = Guid.NewGuid();
ClientScene.RegisterSpawnHandler(pieceAssetId, SpawnPiece, UnspawnPiece);
NetworkServer.Spawn(_currentPiece);
as you see, the pieceAssetId is newly generated, and has no connection to the NetworkIdentity
the Mirror docs don't explain this any further
You'll likely get better help in the Mirror discord
I am using the Asset Store Mirror package on Linux. I am trying to make a linux build, but I am getting an error saying that it
Failed running /home/thewhiterice200/UnityEditor/2019.4.4f1/Editor/Data/il2cpp/build/deploy/net471/il2cpp.exe
what is wrong here?
how do i check what my actor number is on photon
If I remember correctly there is a LocalPlayer property in the PhotonNetwork class that has a ActorNumber property
i am new to unity what is networking about?
~~Hey everyone :)
Working on a new multiplayer game and I am trying to find a fitting networking library. Here are a few things I am looking for:
- Reliable and Unreliable UDP channels
- Ability to do all functionality via scripts, potentially optional component usage
- Ability to encrypt messages for things like authentication (no, I don't want to setup HTTPS servers and ping around messages on a backend that doesn't exist yet)
- Self hosted, so no requirements on a third party service to run servers
- Preferably open source, but I can let this one slide
Any options any of you know of that would support a lot of the above functions or requirements?~~
Answered
Socket Send/Receive in Unity do not work with Spans yet
Is there any way to work with unmanaged memory with these at all?
Is there any Socket.IO library/package that is still being worked on?
A thin native socket wrapper is all you need, https://github.com/nxrighthere/NanoSockets I use this, a friend of mine made it
Good morning,
About CUSTOM PROPERTIES in Photon PUN2
- do custom properties attached to players keep their data when changing scenes (photonnetwork.loadlevel) ? (players are already entered a room)
- when I enter my new scene, i try to retrieve my CP and i get a nullreference .... (in the previous scene, i attached my CP like _myCP["tag"] to the 2 players (LocalPlayers[0].CustomProperties = _myCP; and same for player 1)
but in next scene, i cant get to them... - should i maybe use Room CP ?
thanks a lot !
In a nutshell... Allows you to make multiplayer games
do you guys think that tcp is save enough to transfer sensitive things like passwords or login tokens?
@trim monolith TCP by itself is entirely unsafe, you will need an encryption layer running on top of it to encrypt and decrypt messages. You could also consider using HTTPS requests instead if you don't want to setup encryption through your TCP connection in order to transfer those to the right places and then have the server check for or be notified of any new logins.
how fast is https compared to tcp? In form of server side deserilisation
can someone explain at the end "Health Checking For Game Over" I think they messed up the tutorial cause unity is giving me an error
https://doc.photonengine.com/zh-tw/pun/current/demos-and-tutorials/pun-basics-tutorial/player-prefab
Photon Unity Networking 架構適合即時多人連線遊戲與應用程式,完全沒有NAT穿透問題。不論有無 Unity 授權都能匯出至所有支援 Unity 的平台!
whats the error
Assets\Scripts\PlayerManager.cs(47,21): error CS0103: The name 'GameManager' does not exist in the current context
Did you create the GameManager from the previous tutorial ?
yeah I added it to the scene
OK. Somehow Unity doesnt find it. If you're sure it spelled correctly and its is where it should be and so on... try to restart Unity ? It might be drunk sometimes
check namespace also ?
Yeah I did that but still has the error
YES its trhe name space
Works now ?
Yess THANK YOU
Alright happy coding !
Hi, i get errors when i try to retrieve customproperties..... after loading scenes....i set the CP to a room ....
in scene 1 : PhotonNetwork.CurrentRoom.SetCustomProperties(_myCAS);
in scene 2 : if ((int)PhotonNetwork.CurrentRoom.CustomProperties["team"] == 0) >>> nullref error ...
in scene 1, i have also : _myCAS["team"] = 0;
@grand skiff There might be some additional operations being done when RPC is received? I would probably peek into the code to see what it is doing
Would also consider if I'm messing with the components or something that trigger that
Also make sure the clients are running on the same version
As in, don't use old builds
By code I meant PUNs code
Are you implementing IPunObservable on Server?
Interface for OnPhotonSerializeView
Well PUN doesn't know either, hence the error 😄
How can I get unity to make a WebSocket Client connection?
dear friends...any help about CustomProperties....
Scene 1 :
public ExitGames.Client.Photon.Hashtable _myCAS = new ExitGames.Client.Photon.Hashtable() { { "team", 0 } };
...
_myCAS["team"] = 1;
PhotonNetwork.CurrentRoom.SetCustomProperties(_myCAS);
scene 2:
if ((int)PhotonNetwork.CurrentRoom.CustomProperties["team"] == 0) >>> NullRef error.... 😦
@grand elm I don't think Unity ships with one out of the box. Unity Transport would probably be the closest official one, but some thirdparty library would also do.
Any WebGL platform supporting network solution should do
I changed the _myCAS["team"]=1 to ..... _myCAS.Add("team",1) ....still no luck 😦
I'm using RPC
i don't know what is onphotonserializeview
even, if i try, right after Add a value to my hashtable, to access _myCAS
-- Debug.Log("cas : "+ (int)PhotonNetwork.CurrentRoom.CustomProperties["team"]); --
i get errors....
i am so lost:/
@graceful zephyr Thanks for the tip
np!
In mirror, My players spawn in and I can see both of them on the host. But on the client, I can only see one of the players. What could cause this?
What does the use local part in the photon transform view
Is it possible in the current state of Unity to create a 100 person battle royal game?
Without building a custom stack
Hey, I'm having a problem, but I don't really know why it's happening. It's not to do with errors, it's just that it isn't working as it should. I've tried a lot of things but I can't seem to make it work. So I'm making a 3d among us game, and I'm writing a script to determine who is the impostor. The script is here: https://hatebin.com/quusqmjmqi
My problem is that it only runs for 1 of the clients, and not the other one. I'm currently using 2 clients for testing (build & editor). If you can help, that would be greatly appreciated. I can explain more if this is confusing, so just let me know if you need a better explanation. (Using Photon PUN2)
so many people asking questions, but no one is answering them
lol
the answer in here is usually the same so it doesnt get much attention
what is usually the answer?
- use mirror or pun
- go to mirror's discord
- multiplayer is too hard go back now
- emotitron or eric helps you with a photon issue
Go back nao! U have wife n kids!
I'm brand new to Photon. Would it be possible (realistically) to create a 100 person battle royale type game with Photon?
Which photon? PUN?
PUN uses the masterClient architecture afaik, so its almost like peer to peer
So.. idk if that's the best way to make 100 players game. Host migrating will be a pain to do
local tells it to use localPosition and localRotation instead of position and rotation. They will tend to be more appropriate choices for child gameobjects. @unreal prairie
how do i send the value of a variable to other clients
definetely not
There's no solution for unity that exists that can do a 100 player battle royale game out of the box.
Hello
What causes this bug?
I cannot understand the problem & fix
it was working recently
The log kind-of tells you what's happening. A method is missing or does not have the correct parameter signature.
Can someone help me with fixing? I got this while everything was working perfectly
and now i cannot RPC
what should i do
Do you have a GameObject with a PhotonView component that contains a "Server" script in the Observed Components list ? If so, your "Server" script should have a method OnPhotonsSerializeView()
so that Photon can sync data
Yes, i have
but before, it didn't have and it was working
why does it give error now?
Dunno blind like this. Maybe you updated something ?
I don't know but i tried something weird, probably it caused
is it like this?
i think i found
Hi!
I'm working on an AR app that uses real time footage from an IP camera. I'm having a hard time in displaying the footage over the mesh renderer (I'm using a quad in my project), it's more of a connection problem. Is it fine if I troubleshoot this on this channel or should I do it in #🤯┃augmented-reality?
can someone give me a good beginner tutorial on PUN2
Yes, the official docs guides you step by step https://doc.photonengine.com/en-us/pun/v2/getting-started/pun-intro
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!
Would Mirror be able to handle a 100 person battle royale game?
@teal hemlock ask in mirror discord, it can but with optimizations
Did that, they said it would be possible, but I understand that they could be a little biased, so I wanted a second opinion.
what would the best/ideal networking package be I'm kind of lost on where to start
@teal hemlock #archived-networking message
So I'm using PUN and for some reason whenever I jump with Player A's game, Player B's game shows Player A jumping but they are really laggy, anyone know why this is? I tested my ping and its around 20 so that shouldnt be the problem
Its a 2D game and my jumping is just adding force to a rigidbody, so I'm not sure why this would be happening.
Ignore the bad art, but this is what it looks like. The player thats moving is from a second instance of the game
@weak plinth increase send rate and serialization rate
@teal hemlock Thelast.io does upto 100 players on the same room IIRC.
wouldn't you be able to get to 100 players on mirror?
I doubled and then tripled the send and serialization rate, doubling basically did nothing and tripling it just seemed the make all the movement smaller (Jumping was lower in height, still moving all over the place like before)
hmm
lerp the movement
Maybe use the NetworkRigidBody component?
nvm thats for mirror
Make your own script that syncs movement
It should queue time stamped positions, and interpolate
Lerp(pos_at_t0, pos_at_t1, (currentTime - averageLatency - t0)/(t1-t0))
Why does dis start function run twice I , I have to instanci from it but I check if you are the masterclient and two people can’t be te master client
Seems like you might be mixing up some concepts. If Start() runs twice, then you have two instances. That is just a Unity thing.
We have no idea what that Start is on without context.
am i able to make a python socket script and connect to it from unity? i'm not that good at c# sockets but i am at python. i'm just looking to make a simple system with chatting, multiplayer, etc.
i don't wanna use anything from the asset store for making multiplayer, such as photon or mirror
also @unreal prairie you made a typo with "ChooseSpanwPoint", it should be "ChooseSpawnPoint", unless it's supposed to be like that.
I keep getting this failed to spawn, but the prefab is in the slots, and the player prefab is a registered spawnable prefab
Any idea why?
ignore all the stuff betoween the players
could this be a problem?
Any tips on making a dash/dodgeroll in multiplayer?
My clients only gets other client's pos and move delta, so if a player does dodgeroll, i guess it's gotta be Rpc'd
And then what do i do? Dodgeroll is a curve lerp? Or a single Cc.Move(dodgeDir*dodgeSpeed) ? and let all clients deal with it? Wouldn't it dampen bcoz it's dragging on the terrain? Or should the dir have a +Y too so it's like a mini hop?
But what if it's dodge rolling against an uphill slope? I'd let the controller handle that, so maybe an overwrite Cc.Move for the duration?
How would i randomly assign a team to each player in photon pun 2? I'm new to multiplayer so I don't know much
PUN ships with a connection based team setup, so all you really have to manage is the method with the team.
Though built-in team utility isn't ideal if you are planning to have NPCs
hi i have a question about photon:
When i try to do Rigidbody.AddForce while using Photon the player moves and instantly gets teleported to his original position. Do i need to use a RPC?
@weak plinth Yes. You need to match protocols, and that's all
If your python and C# socket are both udp or tcp, it's fine
Of course, also make sure they use the same user-defined protocol on top of that
@graceful zephyr I found your UnsafeCollections repository. You can make it accessible within the Unity Packet manager if you add package.json file
Ye I know I never bothered to figure out how they work
I can make you one if you'd like?
Also, I think you need to remove the .asset files and the manifest.json
@spring crane ok, i'm not gonna use any NPCs, so i guess i can use that. any useful videos you could link to?
I would just check the API documentation and the samples PUN ships with
Hello! I'm Dr Melina Vidoni, a researcher at RMIT University in Melbourne, Australia. I research mostly software engineering, but now I am working in a project researching specific challenges in thedev process to help small indie devs to get organised and grow into larger companies.
Who is the target? Small (mostly informal or just starting) studios of less than 6 people, where most of them are not formally employed at the company (i.e. work as a side job) and that hopes to grow in the future. If it is just a hobby to you, then this is not the goal of my study.
The survey is in English and Spanish, and it is long (~40minutes), but valid answers can enter on a giveaway for 10 Steam Codes (open worldwide)!
Survey [EN/ES]: https://tinyurl.com/y3mpkckz
Please, redistribute among your peers -the goal of this project is to help the community!
Researching challenges, problems and game development
So I have this method that i want to call on the whole server
I then call this method through an animation event yet for somereason the ball does not get unparented which i think is because it is not getting unparented across the network
Any fixes for this because the RPC still does not work
?
should i continue using photon or should i switch to mirror?
there are probably going to be more than 20 players playing at once
so
photon
I'm following a networking tutorial by Tom Weilend and I was wondering, I want sounds and animations when the player and enemies shoot, do I put the sounds and animations in the server code or the client code?
Both?
Ok, ill try it
I'm assuming the server is also a person that plays the game
If it's a dedicated server, then only the client of course
the server is a seperate app but yeah im playing and also have the server running
In the firs picture I send an rpc with an int as parameter but the int doesnt change on the other player the called rpc function is in the second picture
bruh
Then it's a dedicated server
Are you guys talking about Photon or Mirror?
Neither
Ah alright
Btw which one is better? photon or Mirror
Heard a lot about Photon but mirror is based on the old Unity multiplayer system
I can only recommend Photon Bolt
Alright I'll look at it
Had some experience with mirror but I'm not feeling very satisfied with it
Also is there a chat for injections?
Photon is made by professionals while mirror is maintained by hobbyists
Is there any reason that Photon is lagging for me?
I didn't know that, if so then I should switch to photon
thank you!
Hopefully the knowledge I gained from Mirror would provide a nice beginning
hi idk if dis is d right place to put it but does unity have a built-in netoworking system? i know dey had smth like UNET but i heard dats ded and der replacing it so is der a new one yet?
so unity isnt gonna make a new UNET?
Unity is working on one, but I wouldn't wait for it to be released.
Right now all you have are 3rd party solutions.
Mirror and Photon PUN are the two main ones that are recommended.
Main difference is that PUN takes care of hosting and the hard stuff, but costs money after 20 CCU.
So, actually just learning mirror now on my end. Weirdly, finding the small stuff harder than the big stuff haha. I have moving players, with physics etc. I have synced button presses. But one thing im kinda struggling with is Synced Vars
I have a kind of 'central point'. As a test, i want to be able to just have it display the id of the last player to interact with it. So, I have a uint 'ownerID' as a SyncVar
Do I modify this with a [Command], or just normally?
The object has a NetworkIdentity
[SyncVar(hook = "OnIDChange")]
public uint ownerID;
public void Own (uint _id)
{
Debug.Log("OWN1:" + _id);
CmdOwn(_id);
}
[Command(ignoreAuthority = true)]
public void CmdOwn (uint _id)
{
Debug.Log("OWN2:" + _id);
ownerID = _id;
}
public void OnIDChange (uint oldValue, uint newValue)
{
Debug.Log("OWN3:" + oldValue + "|" + newValue);
foreach (var t in outputs)
{
t.text = ownerID.ToString();
}
}
This is my current setup, but only Own1 is getting called, and the id is never changing
Theres a mirror discord?!? Awesome haha
Does anyone know a decent serializer that doesn't use runtime il code generation or an additional code generator?
@grizzled narwhal It's either IL, reflection, or writing it yourself
Mhh. I wanted to avoid having a gc leak
What does this have to do with "gc leak" exactly?
Every time I serialize an object using for example JsonUtility it allocates a string which I dont want
I would like to serialize into an existing buffer so I dont allocate garbage
Oh, that's what you mean by "gc leak".
There's probably some serializer out there that lets you use your own buffer, but that doesn't mean it doesn't use reflection
Im fine with reflection but not with runtime il generation because of il2cpp
Hey guys, im using Photon Unity Network for my multiplayer game. I have setup a rejoin system with playerttl set to 30000. However, I want to remove the player from the photon player list if he manually quits the app using a button in the game
how would i go about doing this?
right now if the player quits I get a playerleftroom callback with the same player list
after the playerttl i get another playerleftroom callback with the right amount of player list
The first callback is for the soft disconnect, the second for the hard. Quitting inside the game I would expect to result in a hard disconnect in most cases, so not sure why it is treating it as a timeout.
Hello, i'm using Photon. I want client to send server a data, and i want server save the data, and when player enters again, i want server to send back data from saved data
now my questions are
- i'm using photon cloud, should i use photon server for this?
- how can i add events to server, not client
- how to make server send message to client
you can use photon cloud for that, you need a server, either a web one or one you make yourself, if using a web one (like apache) you can use something like php to received the request and save it to a database that you made (mysql or the like), once your able to send to the server using webrpc you can get a reply back, same thing for when you login, you gotta login on a server with custom authentification, then get whatever data you want back
there alot of stuff behind all this gotta search google on each subject
i think there some third party service that do all this for you but i dont know much about it
thanks!
any tutorials on webrpc?
or any tutorials for server events or database etc.
its all on photonengine website on the tutorial part
except for the server side
that you gotta make it yourself, you can search how to setup apache on a server and code something with php to get the request
thanks again
have a problem for three day and I just can’t fix it I have been asking on discords and searching on the web but I still can’t fix it maybe someone here knows how to fix it.
I have a scrip on my playeravatar wich is an empty gam object just for connection to the server and on on that scrip I instantiate the player I can just instatiate them randomly on the spawn points that I have chosen but then it’s just luck that they don’t have the same spawnpoint. So I wrote also some code to check the master his spawnpoint and then set the client his spawn point to the remaining one so they never have the same but it’s still random, this is my code
the problem is that the values i set in the rpc function only change on the master but not on the other player but the other player does eceive the rpc because the debug log says so and the debug log statement that i have set inside the rpc i also see in the debug from the other player but the values only change on the master side
this is the others player side and in this case the unity editor and the values arend changed
this is the masters player in this case the standalone and the values are changed here, its just null this time but i also is somethimes one, the client spawn doest change on the master because that part of the code is only runt on the client version and the bool is set to false so on this player(the master ) the values do change how they supposed to do
this is my debug from the other player(not the master )and you can see that it says rcp received
here i set the bool from the other player(not master) manuel to false so that the coroutine starts and it does what it needs to do , the int is just lucky that is zero on the masterspawn and that its also default zero so it will spawn the clieng on spawn 1 but i need to do this manuel to work because for som reason the value dont get set on the other player(not master) from te script
and then on the debug logs it just says after i changed the bool on the other player(not master) that it regiserd another photon view, the one of the player that just spawnd
i realy hope someone can help me because i have tried basicly eveything but i just wont set the value on the other client(not master client) while i use an rpc with target all bufferd?
@graceful zephyr I've made a PR for UnsafeCollections so that it can be used with the package manager
Let me take a look in a bit
Sure thing
How to Server RPC in Photon Cloud?
I mean, i want Server to RPC to Client
Should i use WebRPCs?
thanks i will try
Hello, can someone help me with WebRPCs?
I needed server to send messages back, i also want to have a database and i want server to send data from database.
Someone suggested WebRPCs. Now, i'm trying to learn it
But i'm stuck rn
What should i put here?
I've read the doc but i couldn't get it
Hi
I have made some addressables in unity and i am accessing them through google cloud and it is working very in windows
But when i follow the same principle in android build then it doesn't work and it doesn't give out any errors
What's wrong here?
I'm making a multi player game using mirror, networking is all working fine. However when I'm running 2 test build windows my controller inputs are being read on both instances. I've tried disabling "Run In Background" and setting my input script to only read "if Application.isFocused" but it's still not ignoring input on the inactive window. Does anyone have any idea how I can resolve this issue, it's making testing very difficult. It seems to only be an issue with controllers, keyboard and mouse work as expected so it's not an authority issue. Thanks.
I'm using the new input system package. On 2019.4.14f1
Technically, however I figured there was more of a likely hood others working on multilayer projects would have run into the issue, as on single player projects you're unlikely to ever run 2 instances side by side.
If Unity's solution doesnt work, maybe you can disable your input when you get an OnApplicationFocus? https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationFocus.html
have someone a basic tutorial video on PUN 2??
Hi!
I'm working on an AR app that uses real time footage from an IP camera. I'm having a hard time in displaying the footage over the mesh renderer (I'm using a quad in my project), it's more of a connection problem.
Here's the code I currently have: https://pastebin.com/9hb8rhaK
I've tried to retrieve the footage texture from the HTTP url in several methods and reiterations on the script but I keep getting the following errors
Any help is appreciated.
Pastebin
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.
so stream is null right ?
GetVideo is asynchronous
But you try to read from stream immediately (next line)
This is my guess
Hi there, backend engineer looking for insight. Sorry if this is not the proper channel.
I've started a common game backend project that will be used for desktop and mobile games, akin to Nakama, but with a structured plugin ecosystem.
I was looking into OpenAPI code generation for Unity and while there is client code generation for .NET 4.x, I wasn't able find a proper one for Unity.
- How well would .NET 4.x's built in http libraries work with Unity? (I've read about incompatibility with WebGL builds, but I won't be targeting those)
- Do Unity practices favor
UnityWebRequestoverSystem.Net? - How do you manage API calls for your games? Do you simply wrap api endpoints in functions that accept serializables, or do you build a more object oriented system, multiple managers etc.
Bonus question:
- Has anyone succesfully used gRPC for Unity?
Actually it's sync, I assumed it was a couroutine xD
@fair badger stream = resp.GetResponseStream(); but resp is never assigned, only declared ?
Line where it's assigned is commented out
I expect resp to be null, and so does stream
Looks like you tried a bunch of things and mixed them along the way ?
yes, something like that
I commented that line because i couldn't find an identifier that wouldn't cause an error
@gloomy sand this is as good a place as any. Anything that uses threads will be broken in webgl (thats where most of the problems arise)
I haven't gotten far enough for API calls in my project yet but I would try .NET first.
Unity can use native plugins if you wanted to write it in something like C, C++, or GO.
if i was in your position i'd actually try doing it in C# as a .NET plugin. that way you could deploy it on NuGet or something and support your api in any .net project
can you send an rpc inside an if(ismasterclient) because when i do this the rpc only gos to the master and not the other clients
posting this here in case people don't follow the blog or blog channel here: https://blogs.unity3d.com/2020/12/03/accelerating-unitys-new-gameobjects-multiplayer-networking-framework/
Unity Technologies Blog
The open source MLAPI project joins the Unity family. Read on to discover some of the changes you can expect as we build Unity’s first-party GameObjects multiplayer networking (netcode) framework. One of Unity’s top priorities for 2021 is to expand the Unity ecosystem with a first-party multiplayer networking solution for GameObjects that is eas...
They basically are right back to HLAPI.
Hey Emotitron, haven't seen you in a good while
it's nice to see Unity thinking about game object based solutions, but I feel with their resources they could build something that manages the simulation layer to encapsulate the netcode side best as possible, since HLAPI did not do that well
Which many people wanted, for better or worse.
monoB is prolly still heavily the majority of users though, right? I've been on a monoB project for over a year now so not sure if published games are happening with DOTS
Gave this a try. Same issue as Application.isFocused unfortunately. Such a weird quirk of this new input system.
Yeah, monob is not going anywhere
Hello all,
I have been following a Unity +Mirror Networking Tutorials playlist and at one point I am supposed to connect to a AWS Lightsale dedicated server from the Unity Editor and a clone editor via the client connection. However, I am not able to and am receiving an error message and the following results when trying to run the server config. Does anyone have any insight or thoughts?
This is the youtube link to the tutorial series
I have tried adding a firewall rule/exception but still nothing
What the instructor gets vs.
what I get
Additionally, I noticed that TelepathyTransport script is deprecated, but the KCP Transport script isn't helping either
KCP is UDP
So if you only opened TCP that could be it
Ohhh wait I didnt read that right the first time
Ask over at the mirror discord
@gleaming prawn I've seen your talk about deterministic rollback networking. How do you deal with components having reference type fields?
Anyone knows how the FPSsample does Rollback ? i'm trying to do physics based client prediction and it seems that you have to create a physics scene to handle it so i tried to look how the FPSSample did but there is no mention of an additionnal scene created
nvm they use a characterController..
Any help to learn about networking from scratch?
@grizzled narwhal we have our own on-frame reference types
EntityRef, Ptr, etc
Quantum can rollback a full frame consistently
Thanks @severe owl
try these https://gafferongames.com
We just released an alpha of our Unity multiplayer game that uses Photon PUN2, you can play it via a desktop browser
https://out-of-tune-games.itch.io/crooks-like-us
This will be our first major stress test of the network code, hopefully it hold up!
I you send an rpc with targetalbufferd, will te other player than first reveive the rpc or first the start methode
hey dudes, any know any example of game loop for a MMO server? tick rate implementation
Hi, I want to send mobile input to the pc game in Unity(specifically, gyro and accerelometer). What tool should I look into doing this ?
Any example or idea how implement rick rate in loop? i mean 60 ticks per seconds for example
Did you see how Unity did it with the DOTS FPS sample ? It's an old Unity version and not maintained any more, but hopefully can give you ideas
https://github.com/Unity-Technologies/FPSSample/blob/6b8b27aca3690de9e46ca3fe5780af4f0eff5faa/Assets/Scripts/Game/Main/ServerGameLoop.cs
@versed rock
And it's ECS
thanks! amazing
oh geez that thing is awful in every way
@versed rock if you want a headache, look at the DOTS FPS sample.
i think simple loop for a test project for MMO
int tickRate = 30;
int m_ThreadSleep = 1000 / tickRate;
while(!m_Closing)
{
m_world.Tick();
Thread.Sleep(m_ThreadSleep);
Console.WriteLine($"Date TICK {DateTime.UtcNow.ToString("hh.mm.ss.ffffff")}");
}
are you talking inside unity or outside?
outside
Okay, I figured as much with the thread call.
i'm trying to make a test example of loop for MMO and make some test
The general idea is you run the server at a steady tick, whatever you want to be. that code is pretty straight forward.
Simply run physics/steps or w/e every 20ms
(example rate)
the MMO prototype don't have physic engine
the server never deviates from that. and if the tick is marginally off on the server who cares
its same principle though
clients try to send data at the same tick rate but that wont happen irl
so the server will determine based on how much data its getting from the clients if theyre sending too fast or too slow; in return will tell clients to speed or slow down their simulation
clients simulation rate = variable. server = constant
for the client, i'm trying to implement a queue
for now my purpose is
- Simple game loop in server, with 20/40/60 tickRate for manage the items, character and player inputs
- TCP class for connect client and manage message
- Queue for Send/Received
Hi everyone I am using the mirror plugin to make my multiplayer game and I am a bit stuck the problem is when a client with another camera connects to the scene it will display the same camera on both screens this means I cannot go any further with my game I have tried using chinemachene but it still has an answers I would love to know so I can continue with my game thanks!
Attach the camera to the player instance
Ask over at the mirror discord, more mirror specific help there too
Ok thanks
Is there a way to know which player spawns first
when i am using joystick for controller in android in photon bolt, there is the problem that both the joysticks are present at one place and move both the players at the same time
any solution
pls
When they spawn, move them into a list, it'll do it in order
pls help
You can, but without a physics engine, there's a lot of options for cheating
@coarse heart, you mean you got 2 joysticks locally on the machine? Then you need your controller code to react to only specific buttons for each character.
why? the character don't jump, any force is applied to any object
we only value the movement with the speed, direction and the position
What prevents a player from walking through a wall on their screen
And having it synced on everyone else's?
have all this invalid position in the server, like Albion online
Albion Online is a cross-platform sandbox MMO RPG game. David Salz (Sandbox Interactive) takes you behind the (technical) scenes. He takes a look at the structure of the server farm and its inner workings, the databases, the threading and message processing model and many other interesting implementation aspects. On the client side, Albion uses ...
You're going to need exactly this same information on the server, yes
@versed rock Albion uses photon server fwiw
New ECS NetCode question : has anybody information about wether we will be able to control quantization of position and rotation anytime in the future again ? (they removed the possibility to edit those fields in inspector since serialization happens per component and no longer per ghost)
You can do it via code with field attributes
sorry my question wasn't clear, i mean per prefab basis. Let's say I have some ghosts that don't need rotation synchronized, only position. I could save bandwith by untoggling their rotation component. (this was possible with netcode 0.3 if i remember correctly, but isn't anymore) I was wondering wether unity plans to bring that back
Dunno if they plan to bring it back to through the inspector. From now you could be able to mess with it at least from code.
i know this sounds really dumb but does anyone have a working multiplayer system that i can use?
yeah, i know. I think to use photon server for MMO but maybe another open source alternative? Python of C#?
This is apples to oranges, sure you can use any language
Photon server solves a lot of thing for you in terms of scalability and load balancing
yeah, but i ask if any know any BASIC mmo backend like photon but open source
i mean, tick rate, tcp communication implementation and other things
but only the basic
Maybe there is, I’m just not aware
I think it's pretty interesting that Albion is made with Unity/Photon
How many CCU does that game have?
Notice they do not use pun, they run photon server with a custom application (not our default load balancing). Photon server raw sdk is quite flexible and it had an “mmo” base sample that they got inspired by
They also run photon server in their own clusters
So I do not have their ccu numbers per server, not how beefy their servers are
But they are quite happy with their infra afaik
They also have a nice setup for ddos protection (something we also run)
It's always interesting to hear how a company solves some technical challenge for their own requirements.
They use the photon server because it is very stable, jasmine thread safety feature, and handles thousands of@connections from a single machine just fine
I'm glad some of these developers take the time to explain a thing or two about their designs
How many depends a lot on the complexity of the app and the machine specs
But from 4K to 10k client connections is normal
From one machine
That's very impressive
hey guys im having some issues, when i try to test my multiplayer, only one instance runs smoothly
the instance im focused in runs smooth but the background ones lag hard
But, that is normal
Nut
Rendering in background task is pow@priority to the os
Maybe you can change that in the build@config but I’m not@sure
it doesnt happen in the vid im watching
Join our Discord: http://discord.shrinewars.com
Patreon: https://www.patreon.com/shrinewars
In this video, we'll set up everything we need to build a multiplayer game in Unity using Mirror.
GitHub Repo: https://github.com/ShrineGames/NetworkingTutorial
Mirror: https://mirror-networking.com
ParrelSync: https://github.com/VeriorPies/ParrelSync
...
22:45
@weak plinth it is kind of impressive, ye. But for us that is just the normal... server runs io completion ports, which is totally different that regular sockets
So it handles a lot more data than a simple unity instance... this is what it was designed for
And this is why we don’t even bother to answer when someone asks here how to write an mmo with unity servers (one of the reasons)
Só there is probably a way to make builds not get low priority @random matrix but that is not exactly network related
Maybe you should ask at the mirror discord, maybe they can help better
That, and an mmo is one of the most complicated multi-user systems to design
Exactly
The guys at Albion are really nice, also appreciate they share some of their stack design
Shrine Wars youtube channel is great, love how he breaks stuff down
I've build a linux server, then i've uploaded it to a dedicated host(ubuntu bionic) i did the chmod +x thingy then run it and i have this error
it seems my server wants to use the GPU?
that's weird
these are my build settings
i have one scene with just that
maybe i should remove the main camera
anyway it worked when i connected my client so i'm good now 🙂
Is there a way for a dedicated server to get its public IP address? To give to the master server containing a list of all public servers
any bandwith experts out there that know when to use a ghostfield instead of rpcs to sync values ? example : a unit can have 3 items (byte itemSlot01 ,02,03). Items change only rarely (maybe once per minute on one unit, when user is dragging it onto the unit). Would an rpc whenever a user assigns an item beat the itemslots being ghostfields ?
Imagine a game with 10 players, each having 10 units)
What is the netcode sdk you are using?
unity ecs netcode
So you probably better ask at the dots channel, as almost nobody here uses it. I apologise but I’m not familiar how their delta compression works
Because depending on how it works, it should not use any space until things change, but the ecs netcode is far from stable and I do not really know anyone using it
alright, thanks for your answer 🙂
hi gys i.
I could not find anything about SignalR.
I decided to write an API to build multiplayer in Unity with SignalR.
If you know the source code, please send it.
Thank You
How can I create a websocket client in unity?
actually that looks more like you tried to load a windows/osx plugin on linux
Do you guys recommend France or Germany for EU game server location?
Hey everyone :)
I am considering making an MMO. Yes I know, don't make an MMO, whatever, I want to try it out. Here is my general idea:
There are a few core servers for the game, proxies for handling client to server communication (more later on this), instances, worlds, and persistence. These 4 make up the stack of servers.
Proxies can send messages to all of these internal servers, instances for pushing user messages, worlds for getting the initial client state setup, and persistence for things like authentication or loading global data like active events and notifications. Proxies also send messages they get to the client if marked as such.
Instances handle things players can do in the game, like authenticate movement, crafting, combat, rewards, ect. These cover sections of the world, but can read outside those bounds, and ask to write for nearby instances. Instances essentially own whatever they contain, and handle their actions accordingly. They can talk with other instances, the proxy to send updates to clients in their regions, and persistence for when actions need to be saved. On rare occasion they talk to the worlds, the worlds will most likely talk to them though.
Worlds are the global moderator, they handle all instances within their limits. These limits most likely are things like seamless sections of the world, or perhaps mini areas like dungeons. They don't directly know about game state, but will handle ownership between sections, spinning up or fixing sections, and talking to the proxy about who they should talk to for certain information. They will talk to instances about things that are about to happen on global scales like moving instance locations, handing off function to other servers, ect
Persistence is the most important server, as it handles object persistence and current state. High IO, must just go. Everyone talks to this server, but it won't talk to other servers without being asked.
Is this a good setup or should I change the design?
Interesting, unless someone has experience supporting an MMO, it's not wise to vet a design in theory. Have you looked up post mortems from MMO games that have big user bases?
Bake time is very important to vet a design. You can then build off what's true and tried. (IMO)
The design is based on a few architectures I found, just putting a lot more function on the proxy and hiding an entire network behind it instead of exposing the persistent, authentication, and other servers, it just hides it as the proxy functions, creating a clear divide between secure and insecure sections.
I am not even expecting anything that high, 1k concurrent in the entire game would blow my mind, which a beefed up server could probably handle on its own, every single service, entire game. Maybe not the website on top of it all since it might max its networking at that point.
I could honestly get away with just having transition zones and assigning entire regions to individual servers, with a proxy still to handle talking so you aren't switching connections all the time.
Gotcha
I think on a high level, have an authoritative server for each section of the map. I'd keep it simple before I'd start adding proxies. The problem is everytime the source of truth is duplicated you have to deal with syncing and staleness
CAP theorem
you should also have servers be super strict on their scope of authority.
again just from experience buildling servers outside of games for other types of products
the servicing/livesite is a big source of headache if things are unnecessarily complex
@digital urchin doesn’t look bad at first glance. You seem to have made your research.
1k ccu is definitely possible, and it’s good that you are willing to make design decisions (like boundaries) based@on restrictions
I would worry a bit with two aspects:
- what actual tech stack, language to write the server code with, and see how well you can manage developments of all pieces
- as you said, persistence might be your bottleneck (but again this is theory)
@modest anchor I think that would work. The main reason I wanted to put a proxy is to simplify client connection and processing and also make the amount of connections to the actual working servers limited so they wouldn't be completely flooded with incoming connections, and something more specialized could handle it. Granted completely unnecessary to begin with, would make it so I didn't need to identify all of the servers individually.
@gleaming prawn Thanks :)
Ya, actually developing it will be interesting. Things are going to be written in C# simply because writing in another language, even if it increases speed, would end up with worse performance simply because I know the tricks of how to get C# to go, while something like C++ I would end up just making things worse. The entire networking side of things would be UDP, reliable and unreliable using LiteNetLib, that only handles messaging back and fourth though, so guess I would have a lot of pieces to build.
Persistence bottlenecking really comes down to a single feature I am thinking about: If you chop down a tree in the forest, does it simply reappear in the same spot, or do the nearby trees drop seeds and sampling start sprouting and growing? And does it persist across the current server session, or is it something that can impact the server for days or weeks? That would be the main pressure on persistence, actual living breathing environments that persist throughout the life cycle of a "realm" of sorts.
Of course that kind of persistence would probably work better in more of a player plot system, but it is interesting to think about if there is just a forest in the world that everyone could access, what would happen.
I am wondering how I would do server authoritive movement though, PhysX would probably not be very deterministic, inefficient, and would introduce latency due to needing to run on server ticks... So simply doing PhysX simulations is out. I could do a fixed point physics engine, but it is worse in every aspect except deterministic, which would do the job but also burn the poor main thread of the server.
Any tips for actually doing server authoritive movement with either simulation or checks? I would prefer to catch as many potential cheaters without generating false positives very often, and not absolutely murdering server performance.
I think you got the persistence down quite correctly
Balancing what you actually need to PUSH to disk VS what you can afford to keep only in memory is the key
MMOs are such beasts that you start to think about file-system DB-based techniques of pushing command buffers to disk and commiting to single machine later...
I "guess" (because I am not working on one of these beasts) having things only exist in the memory realm is acceptable, like the Tree Lifecycle example
After watching some videos on up and coming MMORPGs, I think I am going to need a combination of in memory and actual disk persistence. I am going to simplify the server architecture while also increase potential things you can do.
The world is predivided into regions, only a single server will own a region at a time. These are geographically divided into roughly equal patches of land which vary in shape, environment, and progress. Progress, or the destruction of, persists permanently. This would be things like a city with different buildings, facilities, citizens, ect. built by players to some degree. Each region can individually be evolved and devolved during in world events of different degrees. This would be constantly streamed as records in a database whenever changes to this major scale happen. This would be write only unless the server is loading. Trees would be a server lifetime system, so they would reset to default unless they are part of something like a dedicated area in which case they persist and are more valuable.
Very fun to think about the hell that will be to try and save and load.
Also, I am creating this in a way which only requires a single Unity editor to test the entire setup, no networking either. Everything sits within a parent named _Client_ or _Server_, with the server sitting below the client, they will operate side by side in the same scene, so I can do things like simulate thousands of servers and run around between them, no support for multiple clients planned since I should probably be running that differently. I am also abstracting things away to use an in memory direct messaging system which still respects a "port" system and hosts, just so I have something reliable to build upon that isn't a bottleneck.
Basically using some thing that I learned from Spatial IO, but less of the pain and works more how I want it to, with the ability to actually know my damn costs and self host.
Hey I have raid that you can’t cross object rpc but when you use an if(potonview.ismine) and send an rpc does it only send to that player because it can’t cross object ?
No, it sends to all clients you assign in the target group (optional param afaik)
Others and All are the options I think
You can’t cross game object, rpc is called in the same corresponding game object on all affected clients (in all behaviours that have the component)
Thiamin gowns remember it works
That is how* (sorry, typing from phone)
Anyone know how I could detect when a player has joined the server?
Im using Mirror and wanna call an RPC when a player joins
but the one function OnPlayerJoined uses some deprecated variables or smthn
and doesnt wanna work
@digital urchin I get you now. I think just have a "front door" type server that will bounce connections to the next server.
This server will also be critical for telemetry, auth etc.
ping me privately if you want more wisdom in this area. They're fed by a many livesites 😅😅
@modest anchor Ya, like a front door. I think I have a rough idea of how to do it, but I will take you up on that offer if I need it.
We need to develop a little unity based ego shooter with multiplayer for our university project. What would you recommend ? I saw Unet is deprecated and the new dots system not production ready yet. So i have found photon... are there better alternatives for such a game ?
@knotty heart I would have a read of the pinned messages, tons of information in there.
Read this @knotty heart https://forum.unity.com/threads/choosing-the-right-netcode-for-your-game.966593/
@white stone Thanks ! But what would you recommend ? ^^ Oh and... the high level api, is that unet ?
Like the blog post mentions its hard to specify something for your needs because the game/software you run compared to what I run is completely different, reading the blog will certainly ask you a ton of questions and probably open your heart to have a real hard think about networking.
The link in the blog about choosing the right netcode has a ton of information and well worth a read, knowledge is power.
Alright, thanks : )
But... that high level api here : https://docs.unity3d.com/Manual/UNetGameObjects.html this is unet, right ? Just want to make sure... because the link says "UnetGameObject", but the doc calls it High level Api... thats a bit confusing
There are many different types of networking we can use and everyone will use something different. Just depends on what your needs are, too many variables come into play, have a read of that, will take you awhile to read.
Haven't used it myself but that sounds like a good use case for photon bolt @knotty heart
Alright, thanks both of you ! 🙂
So i read the article... and for my "case" i could either pick MLAPI or Mirror... The problem here is that both of them are "client-server" based... in an FPS where you select a room to play in, this isnt the best option... so i think im gonna take a look at photon
how many players does your game support
Well we plan to support up to 32 players in a lobby... Probably we go with something like 24 instead. Its a typical ego shooter... so we have two teams fighting against each other on a map ^^ atleast thats what our prof wants
Actually both ideas are cool... cloud based rooms or the ability to host and register servers on our own... so other people could host their own servers. Photon does already includes that room system. Mirror requires some extra work to get that "list-server" working
Ok heres something i dont get... Photon PUN uses some sort of dedicated cloud server... and bolt uses the client itself as a server host... right ? In pun host migration is possible and in bolt it simply disconnects everyone. Why the hell do they say thats perfect for an rts or battle royale ? A battle royale uses dedicated servers and no client hosters xD
Odds are you aren't going to find anything more convenient than PUN when it comes to general purpose networking solutions
Almost too good for learning purposes for that very reason 😄
@spring crane Thanks ^^ i think im really gonna go with PUN... did you get the difference between bolt and pun ? I found a page that lists all differences, but the only major difference is that bolt uses "peer to peer" right ?
Ah... or can it use both ?
Haven't looked too closely into it, but I do know it comes with a lot of the annoying time travel stuff sorted out for you.
Authoritative aspect of the package makes it perfect for these more competitively serious games
@spring crane Thanks ! And do you know if pun is performant enough for up to 24 players fighting against each other and probably some spawnable npc's ? Havent found a benchmark so far
If i remember correctly photon pun has a limit of 16 players (per room)
It's probably fine.
You likely need to start being careful about what you are doing when approaching 24 players + NPCs
Photon also has their own discord server(s) where Photon employees are active.
Same goes for most networking solutions for that matter
That's the benefit of creating your own stack
And I'm sure Bolt doesn't have problems with those numbers
@graceful zephyr Do you think it's possible to create an unmanaged Monitor using Interlocked?
You can send an HTTP GET request to
http://checkip.amazonaws.com
And it will respond with your Public IP
You can also ask your router
I think the safer one is STUNs reflexive address queries...
The amazon thing is an HTTP version of it
Yes, definitely
Hi guys, got a question... How would you handle physics over the Network? we have a building that we want to blow up and come crashing down. Right now the building blows up and falls apart but both clients never see the same outcome.. and I understand the Server should never handle physics on a large scale.. so wondering what the best approach would be.
@wet ingot Handling physics over the network is a ton of hell fun. You can definitely simulate physics on the server, it just makes it more expensive to run said server. The problem you are always going to have, is that PhysX is not going to be deterministic, you can get it to be close, but don't rely on it. You most likely will have to stream some information from the server about that building while it is falling apart.
I am working on a game where everything is synced across the network with complete determinism, so I won't be able to use things like PhysX, and I am going to be doing things like running things in a tick based system, with roll back and resimulation being common. Nothing other than input synced across the network, but everything stays in sync.
It may not be a solution you can choose to use however, so you might want to consider just synchronizing the data from the server instead. You can do some optimizations like compressing the floats down, or only syncing pieces that need to be updated (sleeping rigidbodies don't need to be synced, so you can just say the rigidbody fell asleep and the last state it was in). It will be pretty difficult but if you aren't able to simply move everything to be completely deterministic, it would probably be one of few options you have.
I'm pretty new to networking when it comes to game development, is there some horrific downside to writing your own server? I'm looking to have a server that hosts small lobbies (10 people per) but I keep seeing people talking about Photon and Unity's inbuilt networking
i've written networked applications before, worked with networking through Spigot (i.e. minecraft plugins), and generally have a grasp on the process, so I'm not keen on using out-of-the-box solutions atm
actually, I guess a better question would be: if I were to use something like Photon for simplicity's sake, how easy would it be to port that in the event that I need larger-scale hosting or find something with better rate charges?
you need to research floating point determinism to learn why. it's very complicated. If you're lucky you can get away with using Lookup tables. Otherwise the most common solution is to use software to do the division/trig/sqrt (see fixed point arithmetic)
unity makes it extra difficult because Vector3 does weird things behind the scenes
if you have to deliver something with multiplayer, PUN/BOLT/Quantum are your best bets. You can try making your own if you are confident you have the time to investigate and handle the issues that come with scale but it will take a lot of time and effort.
Thanks @slim ridge and @digital urchin were having a bitch of a time getting out building to sync over clients.
and get somewhat a consistent outcome over clients.
yeah, it's all fine and dandy until you do trig, square root, or division
Right now.. one client will see the whole building down.. and the other will only see half
Which is way to much of a difference to be ok with, lol
so i made a create button with photon and when i create a room it gives this error
https://hatebin.com/omgyeqevoh also this is the code
@orchid pendant, creating rooms is done on the server, so you need to be connected to the correct one. In best case, read and code-along the Basics Tutorial. It will explain the steps to create a room.
oh okay
What's the best networking solution for a small fps game for around 3-6 players per lobby?
if it is competitive, you will likely need to explore Mirror or MLAPI since you will want to get your hands dirty. Pun2 is great for that player count, but it is pure relay, so if you want any kind of server authority you will want to make server plugins for the relay. Upside is hosting is a breeze with relay. Upside of Mirror/MLAPI is your server runs a Unity EXE.
Other option is Photon Bolt if this is a serious FPS, as it is the only full stack library that has an architecture meant for AAA fps games.
warning in unity 2019.3 to upper .
my game cant use the unity web request
Modules/UnityWebRequest/Implementations/TransportCurl.cpp
i used the unity 2019.3 2019.4 2020.1 but this problem not solved
i am sorry take mistake
You can't ping anyone not in the conversation
ok thanks
!warn 688014472408727567 Don't ping staff or people not in the conversation.
CleverWise#0947 has been warned.
What you're error is saying is that your certificate is not trusted and cant be verified while trying to do that secure connection
how i can fix it
fix your certificate
my certificate have not problems . i think problems has another place
it work, thats how i do it too
Hi guys I wrote a tutorial on using Facepunch.Steamworks to implement P2P multiplayer in Unity if anyone interested - https://www.reddit.com/r/Unity2D/comments/kbah63/p2p_multiplayer_tutorial_for_unity_using/
very thanks
i wanna destroy a gameobjects that was instanciated normally with out having to add a photonView
pls help
Is there still some people using Unet?
If yes, I don’t know why but, a Command function that I use with 2 arguments doesn’t work at all...
There isn’t any error in the inspector... Can someone help me?
Any code will be a big help
no
almost no reason to be using unet hlapi still, switch to mirror at least
Unless your supporting an old project, or upgrading to Mirror is that hard (it has an auto conversion tool), you should switch to Mirror.
How would one begin to work on a fully server authoritative game? Thinking of trying something mobile "simple" where values are stored server sided (rather than two people walking on a map) and all logic being done (as in gaining/spending such values) is done by the server then relayed to the client. I've read into databases in storing peoples data, and okay. Cool. But how would one go about doing logic not in the client?
@reef gust Really depends on the game, real time or turn based, if you plan on saving things between sessions (MMORPG), or if it is a session based game (think most FPS games), is it simply for leaderboards? There is a lot you need to know before you can really figure out how to make it multiplayer, let alone server authoritive.
You most likely won't need a database unless you plan on saving information between the shutdown and restart of your server, and this more than likely should be handled by a backend service instead of your game server.
Right. I've used UNET before making a round based fps and a small moba like game with abilities though there was no persistent data in between sessions. The project wouldn't necessarily be turned based, but I would like to learn the logic behind doing turn based mechanics
I know connecting two clients together is a whole different thing, but if I learn the logic behind doing everything on the server with regard to one client, I would imagine that is a nice step to take afterwards
I do want to dive into persistent data, but I don't need to mess with databases now. Keeping everything in a file that the server reads from is just fine
Instead of trying to find the solution, why don't you try and first define what you are wanting to end up with.
What is your goal.
Starting simple, though the solution is going to be complicated.. a game where you can get 1 coin by pressing a button with a 5 second cooldown where nothing is trusted from the client. In this case, the gold received or the cooldown
No, define it from the players perspective. What can the player do, what happens?
That's the simplest case I can think of where I would learn what I need to know. Don't want to connect any two clients together, because thats all I've done so far in the fps and moba
Player can press a button every 5 seconds, and receives one coin from doing so
Yeah, sounds boring, but knowing how to do that could lead to so much more
Idk of any game as an example of what I'm thinking of. Maybe clash of clans? Full server authority over everything. I don't think you connect to other players in live time.
They may have changed that, but thats how it was years ago. haha
Have your client connect to the server, the server responds with how much time is left until they can press the button. On the client side, it starts a countdown from that time, and displays it. Once it is below or at zero, make the button pressable. When the button is pressed, disable it and send a message to the server. The server will check to make sure that its timer is below or at zero, and if so, will tell the client and store it. If it was above, notify the client they were too early. The server can simply store the timer and coin counter in memory, and you can write it out to a file if you would really wish.
what if you have 200 player
You don't make the server "fully authoritive over everything", and you don't "connect to other players", your players connect to the server only. The authoritive part is that the server checks that what the client is doing is either valid, or the amount of information the player can provide is minimal enough that they can't do anything that isn't intended.
@grim violet 200 connections each with their own version of the button, perhaps it tells the other clients about the current coin count of the highest player.
I can understand the logic behind the operations, but getting to the point of connecting to an external server and not one running in unity is where I am a complete noob
Your external server more than likely will be an instance of your game running on your own machine, a VPS, or the cloud.
It may very well just be a build of your client that runs in a server mode, or perhaps it is something custom built in Python. So long as you "host it" somewhere, and make sure people can access it, it should work.
Any resources you know of on this type of stuff
As in not the logic behind very niche operations, but having a unity client connect and read data/sent input from client/server
gotta choose your net library first i think, mirror hlapi and photon arent working the same
This is more than likely handled by your networking solution. So C# sockets, LiteNetLib, Mirror, and many more.
Okay, cool
You will need to find and choose one after making sure it will work for what you are trying to achieve, and then follow their tutorials, guides, and implement it into your game.
Any preference/bias towards one of the other? Are some more suited for live connections of multiple people than others for example? Because I am not really looking for that
Okay
Do you want to host the server yourself, or do you want it to just be a turn key solution? Do you want to have an actual server, or just a master client? You need to define how your game runs before you can really choose one. For self hosted, I would recommend Mirror (server client setup) or a custom solution, and for turn key I would recommend Photon (master client).
Networking is something you need to know a lot about your game before you can actually sit down and get it working, at least well.
So I'm sitting here thinking whether this would be a good approach or not.
I'm currently developing my own network server, and a test client to go with it.
Here are my thoughts.. Each client would obviously want to keep track of all the players that are currently online for various reasons..
Let's pretend that there are currently 10 people on the server in order to work with this theory that I'm about to explain.
I boot up a new client and connect, and going back to what I said earlier about wanting to keep track of the connected players,
I would then ask the server something like.. "Hey, can you please let me know how many players are connected and their corresponding ID"
The server would then send 10 packets (one for every already connected player).
I would then take those packets, parse them into Player objects and chuck them in a collection on the client, for it to keep track of.
And then later down the line just append to that collection when the client gets notified that a new connection has been made.
Is this a good approach?
which one of those networking solutions would be best for clash of clans???
like the master client or actual server or what??
@reef gust
oh and @digital urchin
If you want an actual Clash of Clans setup, the server usually has private sessions with each client, and the game servers are all knowing, so you want an actual server and to separate the clients from each other as much as possible, perhaps into their own rooms, since clients really shouldn't be able to see or talk to each other unless they are spectating.
are there books or videos on creating such a setup
or is this possible through proton or something
Sure, so long as it works with your systems any approach really works. You probably just want to say that a player is connected, and create the corresponding object. Parsing an actual player object might be a bit much since this initial marker for a connection shouldn't create an actual player object, just the network interface.
You won't find a video for creating Clash Of Clans. You will more than likely find a video on an RTS that would be able to be applied. Other than that you will just want to familiarize yourself with networking lingo and concepts.
huh
not a tutorial on making clash of clans, but this "actual server" you talk about. also, in an RTS people connect to each other in live time, but they do not in clash of clans
so I'm wondering if there is a more targeted type of server series regarding this instead of dissecting individual components from an rts series because it is a completetly different type of thing
@azure rock "Connecting to each other live time" is called peer to peer networking. The setup you need is server client. Not all RTS games are peer to peer either, a lot are or should be server client if they are competitive.
The thing about game development is your going to need to research and learn bits and pieces to get what YOU want to make to work. No one is going to make a tutorial on exactly what your doing, but maybe something close enough where you can transfer the concepts.
I say "actual server" but I am more or less referring to a server you setup yourself instead of a solution you simply pay for and everything is setup and all running.
"The setup you need is server client. Not all RTS games are peer to peer either, a lot are or should be server client if they are competitive." oohhh right. of course haha oops
so for making such a thing starting from scratch would be it? that sounds terrifying lol. correct me if I am wrong, but are there not any external server apis out there that can be used to satisfy such needs
I did mention Mirror as one of the options, it is an existing networking solution that you need to pop into your own server and handle yourself. Do more research, there are plenty of options which all depend on what setup you want to go with, or how specialized you need something.
I am personally using LiteNetLib because all I want from my networking solution is a messaging system, the rest I want to handle myself. I am making an MMORPG, so I really want and NEED the fine control I won't get with Mirror or many other solutions.
interesting
If I was making a Clash Of Clans game, I would do something pretty specialized for the sake of making my life easier for other features like replays or spectating.
Clash Of Clans is actually very similar to Clash Royale in terms of networking design if that helps
ty
👍
Guys, In Photon, for doing PhotonNetwork.RaiseEvent, Is there a PhotonView Component is necessary attached in the component where our above script exist
If anyone is bored on ideas I'm working on either a VR or third person story driven content that needs some guides and work... I haven't buddy that writes books and publishes them on Amazon he gave me permission to reroute one of his books into a game
Anyone here having experience with photon ? I just saw that there are "states"... and well... i think its quite a ugly solution to have OOP here, it doesnt feel composite like... each state can only have one other state as a parent... which is quite restrictive... is there an other solution to send transform data etc. over the network ?
Any help here is appreciated 🙂
@knotty heart I had made my own system for whole thing
This is how serialization worked:
I had references of all objects in there in a list and stuff with id's and all
When i want to serialize and get the "state" as ByteStream, i'd create a single ByteStream and i'd iterate this list to serialize each object, in the same stream
One after another
Each object would have its own logic about how the serialization happens
.
You can have the parent method serialize(buffer) and deserialize(buffer)
And just override it
In your objects
Or make like an ISerializable interface for it
@high night Thanks for the insight ! But does this adress the states itself or the behaviours ? ^^ Or didnt you used states at all and just used the lower level api to send the data ?
I wasn't using "states" if its something photon defines
Its just about iterating all of my objects and making it into a flat byte array
And then i'd send that array and read it on the other side
I called this flat byte array, my "state"
@knotty heart
Thanks 🙂 But you still used photon ? Or what network library ?
I would iterate monobehaviours, gameobject by gameobject
I used mirror, but it wouldnt matter what you use if you just call a single rpc to transfer a single byte stream for everything in your game
Thanks ! I really think im gonna quite with photon due to that state stuff... i probably gonna try to implement your solution or search for a network library that is more "composition" pattern like ^^
What kind of networking architecture are you doing?
@knotty heart
Client-Server based, room like... thats why we have choosen photon. But that was before i discovered that state shit ^^ we need to develop a little ego shooter for a university subject.
I hear photon bolt may help you with "states" but i havent used it myself and i might be wrong
Yeah but those states are awfull... they are pure oop and dont use any composition. Lets say you have an inventory and either players or mobs can have one. Then you cant just create one state for inventory, one for player and one for mob. They dont have any composition :/
@knotty heart Why dont you define your own composition patterns without monoB stuff
MyComponent components;
read write from state:
foreach(MyComponent in components):
component.WriteIntoBuffer(buffer)
foreach(MyComponent in components):
component.ReadFromBuffer(buffer)
update logic:
foreach(MyComponent in components):
component.Update(deltaTime)
@knotty heart
Because i was looking for a simple network solution ^^ I honestly dont wanna write that much network code by myself. And bolt is nearly perfect, if the states could get composed it would be perfect.
@high night One more question... you said you used mirror, right ? How does the mirror networking looks like ? Lets say i have a "HealthScript" that contains currentHealth, maxHealth and a few other variables, then i need a NetworkBehaviour, right ? Is it possible for an entity to have multiple of those "NetworkBehaviours" ? Or one "NetworkBehaviour" for each gameobject ?
Anyone here having experience with MLAPI ?
Not sure how its called, but is it possible to host a server in the clients game itself ? So that the client does not need to buy/rent a server and can use his pc as one and other friends can connect ?
@knotty heart it was network identity component i think
i basicly enables you to call rpcs/commands for that object
i had only one object per client and server with network identity
and used that as access point between clients and server
don't know about MLAPI, but this is usually called a listen server (or sometimes "host")
And yes, MLAPI can do that
Guys can you suggest me which software to use in linux cui server to make a tcp server
I don't want to use ngork
as it just have limit of 20 CCU
for free plan
Serveo/localtunnel/any else what can be better
BTW, what are these PUN States? Never heard of em
For those who have done networking, which do you think is better. Photon or Unet?
Depends on the type of game you're making and what fits it
Keylon is right, but the answer is probably Photon.
You'll always at the very least get a really solid transport layer 😄
Is it possible to host your own bolt servers? I always see it being pointed to as the go-to for a competitive shooter but also see its not only p2p it has no host migration?
Can someone help me understand prediction? How does the server know where the client is, in between the update packets? How will it know if it's the wrong ending position?
Do you have to store information about past frames?
Still, how would the server determine if the player is in the wrong position?
@somber drum yes, you can host your own dedicated servers (both with free and pro versions). Or you can have one player be the host (listen server). In this case Bolt runs punch through + keeps the relay connection as a fallback (between the client and the listen-server).
It does not come with host migration (this is a super complex feature, that is not easy to do out of the box on client-server archnitectures)
@slow monolith
How does the server know where the client is
It's proportional to the ping/2. In a tick-based netcode (like photon bolt), the exact tick the server will raycasts against in the past is part of the input struct that is received on server. Server can validate that with the measured-ping, of course + assume a limit (this is another topic)
Do you have to store information about past frames?
Yes, on server. You need a buffer of full states of the colliders you need to raycasts against.
Bolt uses a custom query system for these raycasts (as PhysX is pretty expensive to rollback).
Still, how would the server determine if the player is in the wrong position?
This is another topic... The server has authority over the actual player position, as it is the full simulation authority.
These are separate topics:
- lag-compensated raycasts (this requires a ring-buffer of full collider data on SERVER)
- client side prediction of local character movement with server reconciliation via rollbacks (this requires a ring buffer of inputs on CLIENT to be reaplied when reconciliating a server authoritative position for a specific tick for the local player)
Both are automatically done for you in Bolt (as long as you comply with the authoritative API guidelines)
Hey there!
I am using photon to create a ball type game. I have run into an issue when one player owned ball collides with another "remote" player owned ball, the "local" collision does not register for the remote client, and makes it feel like hitting a brick wall.
Example: Player A runs full force and collides with Player B. Since the collision happened on Player A's instance of the game, Player A's ball flies away (with Physics Material), but Player B's ball remain unchanged.
This creates a feeling of hitting a brick wall rather than the expected outcome of both balls bouncing away in different directions.
It is important to note that both Players have a Physics Material with Bouncy set to 1.
I have a few solutions to this issue:
- Send over collision data from the player where the collision happened, so that the other "remote" player handles the collision accordingly.
- AddForce
I would much rather implement solution 1 as it would create a more realistic and expected collision than addForce would.
My question is does anyone know of a way to implement this feature? Is it even possible?
@sly hare Are you okay with input delay proportional to your latency?
Syncing physics objects is no simple topic
Its rocket league type of stuff
But if you just make everything serversided and dont do predictions on clientside, you will have it easy but at the cost of some input delay
It might be a possibility. Is it common practice to let server handle input on physics dependent games?
It has to be either that
Or a predictive system like rocket league
Or some hybrid its like that but only player movement is predicted
@sly hare
np
You can either do input delay Bargos said above, which will result in the client seeing the results of their actions RTT (round trip time, the ping to server and back) later. Alternatively you predict the entire simulation locally on the client, and when the server sends data about inputs or state, you reset the simulation to the latest server data and resimulate all the predicted frames. This requires your game to be able to rewind the state of the game, and be able to perform correctly when simulating ~10 ticks or so in a single frame. Quantum is an example of an engine that does this
Okay great! I think I am gonna go with prediction 🙂
@sly hare Then you might wanna read about rollback networking, and you need a stateless physics engine to hop between states like that.
.
stateless physics engine:
no more info stored in physics engine other than that velocity,angularvelocity,position,rotation, mass etc etc etc
.
unitys default engine stores some extra data to make objects stable and stuff i think
and you cant access the engine to include this information in your states, and that will cause mispredictions
.
if your physics is not too complicated, make your own simple physics
Okay. Yeah I don't suppose the physics we are using are too complicated. Interesting information.
Would for example mirror networking work better with that type of set up?
none of the networking packages for Unity other than quantum provide any kind of rollback setup (Bolt does do some rewinding stuff for lag compensation hitboxes iirc, but not super knowledgeable about that). Note that while PhysX will not be entirely deterministic when rolled back/resimmed, you could have the server also synchronize the state of the game so that full determinism is not required (the predictions will be pretty accurate short term). Forum thread about this topic: https://forum.unity.com/threads/deterministic-rollback-lockstep.1017223/
...also, since PhysX does not have a built in API to rewind to its previous state, manually rewinding it by setting the state of objects incurs a performance hit (to rebuild internal data structures).
Alright. I'm going to try to wrap my head around this. So in short no other networking solutions other than quantum provide a rollback setup, so unless you are willing to pay for quantum I should be using some other kind of solution? Or try out Bolt.
there are some links in the thread to various github projects that implement things like GGPO, but some work needs to be done to implement rollback/prediction (you need to decouple all your art from your simulation, since for the fast forward phase you don't want to play a billion sound fx at once). I'm not sure if there's a clever setup that avoids prediction to solve the problem you're having, since I'd think most things would require prediction of the opponent's ball's motion on some level.
for doing it deterministically, PhysX is a no go, and floating point arithmetic is not always consistent cross platform
@sly hare If you arent going for full determinsm, you will be more than okay with a physics engine that is "stateless"
floating point determinism helps you sync a game by sending inputs only
I think sending a state every 2 seconds while sending inputs for every tick would be a pretty good solution, but i dont see that being applied often
I mean its deterministic rollback networking but with states being sent every 2 seconds to fight the butterfly effect
Still need a stateless engine though
btw, DOTS physics is stateless
would a stateless physics engine be required if you are syncing state from the authority? It incurs a performance cost to restore the state of an engine like physx, and the predictions will not be identical, but over a short period of time it would be unnoticeable
how you sync the state is just replacing velocity,position,rotation,angVel
let me think about the issue i had with physics for a moment
Oh I didn't know that.
👍
I did a little demo of rollback with physx (no netcode, just locally), and tho there's a big hit to set all the states, no divergence is noticeable. Ofc it needs to first not diverge over the frames you are resimming, and also not diverge frequently enough so that the server doesn't need an insane send rate on the states
I will try to implement to implement DOTS and the input sending. See what it results to.
if you run two simulations on two different pcs it's very likely that they will never diverge depending on the cpu architecture
but if you load different states randomly, it will diverge because you cant restore the internal state of the engine
The main idea of the game is to be cross platform. You mentioned cpu architecture, but what about playing mobile vs computer. Won't that effect the outcome of the simulations?
this is correct, but if the server sends state updates, the divergences could be reconciled without being noticed
re: determinism, you'll be fine on AMD/Intel if you avoid SIMD...probably...maybe. PhysX is not determ across Intel and AMD. Big problem using any black box like Unity is you cannot control the low level stuff
But as soon as a fast collision happens, it will diverge too much
Until a next state comes from server, you see false prediction
Fast collisions are really bad imo if you dont have high state send rate
yeah, I think you would need to be clever about the send rate, prioritizing important objects over unimportant
and interpolate the view of the objects that diverge to avoid too much pop
There's one more thing, i think one can make the physics stateless
By doing SetActive(false) and SetActive(true) on all rigidbodies before each physics update
This seems to delete these internal states i think
I will probably mess with the box stacking abilities of the engine but it might make things more deterministic
ahh that's clever, yeah
maybe threshold it, so that if objects are idle you don't do it? Since they aren't liable to diverge quickly
yea
heads up that determinism is a lot more than just float consistency. Also need to make sure your object lifecycle is determ, random is determ, blah blah blah. Important to build tools ahead of time to catch desyncs...can be a really big task!
@sly hare You use ints for math, and you do all that deterministic stuff Roystan talks about and implement the rollback correctly, you might not even need to send states ever
This is rocket league type of networking btw, theres a 40min+ video in youtube explaining about rollback networking rocket league uses
is rocket deterministic? It's PC only, and I think unreal, so they could control for float arithmetic if needed
It uses bullet engine, its not floating point deterministic
But that vid explains rollback networking well i mean
Maybe it is, i dunno i am not sure if they send states
I think you could eliminate alot of server traffic via checking players if their floating points are deterministic with server and decide not to sync states with them
that would be interesting. Though I think if I had sending states implemented, the temptation to avoid coding determinism would be too strong 😄
Hmm I do not fully understand what all of these things mean. Is there some resources that I can use to read up on this subject?
I am already researching rocket league's networking solution, source's networking solution, etc.. But some specific resources on determinism implementation would be appreciated.
https://www.gamasutra.com/blogs/DanielCollier/20151124/251987/Minimizing_the_Pain_of_Lockstep_Multiplayer.php this article covers a dev who made a determ game. I made a short post in the above thread about it
interesting stack overflow question, Unity burst dev answers about arithmetic stuff: https://stackoverflow.com/questions/53989518/floating-point-determinism-for-gamedev-in-net-core
and a determinstic replay from the game I am working on(the replay system was originally to help capture trailers, made it determ for fun, but only on single cpu vendor (so cannot watch intel on amd)): https://twitter.com/DavigoGame/status/1220738025765965832
VR vs. PC action in fast-forward using our in-game replay system.
#indiedev #vr #gaming #video #madewithunity https://t.co/M5o6JVQSWn
Hello, if anyone here knows how to use the mirror networking plugin, can you help me out? Basically, I wanna know a two things: 1. How/where do you guys host servers? 2. Is it possible to make an among us style server system with Mirror, you know, with players creating their own lobbies?
Great! Thank you so much! I'll take a look through these 🙂
@abstract zinc By default, any player who knows how can host a minecraft server will be able to host the same way
does anyone know if iOS14 broke anything with webrequests or coroutines? an app that worked in iOS13 no longer works in iOS14 at the point it initiates a webrequest to the server to check credentials
@hazy leaf you probably know what you are doing but i'd like to say, try debugging the build on the iOS14 device if you didnt already
trying that, everything goes smoothly until its supposed to send the webrequest, it never triggers the success or failure event, its like its just getting hung up on it
and its not the webrequest itself because the request is fine in editor/pc
it even works on iphone, its just broken in ios14 ipad it seems
I'm not talking about clients hosting their own servers, I'm talking about clients hosting their own lobbies. If you never played among us, which I stated as an example, in that game, the player can create a lobby with a press of a button, make it private/public, and there is a unqiue code for every lobby that allows people to join it if it is set to private
Is something like this possible in mirror?
ah, yea my bad
thats how photon PUN works by default
there might a mirror trasform that does such a thing, i am not sure
@abstract zinc DarkReflective transport for mirror should work like photon PUN i believe
Oh, i think these guys also let you host your own relay servers for free i think
Among Us was made by a Pun2 user who decided to build his/their own version of what Photon stuff does. So it is very similar to Pun2.
What is this error?
Copying assembly from 'Temp/PhotonUnityNetworking.dll' to 'Library/ScriptAssemblies/PhotonUnityNetworking.dll' failed
This is definitely doable in Mirror - jump over to our discord for support and we'll help you work it out. Discord link is in asset store page description.
JustNick you can just use a room and call it a lobby, no one beside you will know, you can set a password and make it private or public etc ;p
i have a scene set up with crewmates (im using mirror) with movement and 1 player just controls all of the spawned players
https://pastebin.com/kJvH8RUx this is my movement code
Pastebin
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.
can someone help me?
Which method would you use if you had to sync 3 transforms from the client (2 hands and a VR headset position / orientation)? Is it RPC Commands every input tick (client side does client's own tracking while sending positions) or NetworkTransform sync (client side does client tracking with full client authority while network syncs the transforms)?
Can you even "rollback" NetworkTransform, though?
Mirror / UNet, I should mention.
I guess is there any downside to sending like 45 RPC per second?
@vivid thistle All of those PlayerMovement script instances seem to be reading input from the local device regardless if the object is owned locally or not.
How can i fix it?
Be sure to ask in the Mirror discord, but in most cases that is about disabling controller code based on hasAuthority and IsLocalPlayer (or whatever the current values are in Mirror for those) @vivid thistle
Websocket connect crashes unity if the connection fails
does anyone have a solution to this?
Are you handling the failed connect attempt?
@slow monolith can you show your code, you are using?
ws.Connect();```
@ornate zinc Both in start()
ignore the url, it came with the example
but yeah totally crashes unity if it fails
Do you handle the error somewhere?
no, a guy in the other chat said it wouldnt do anything
since its outright crashing unity
Hm, the code is not that complex 😄 it should work, what websocket are you using?
websocket sharp
if I remove ws.connect, no crash
I googled the question, apparently common, but nobody else has answers
besides running the websocket in another thread, which I have not tried yet
I am using EasyWS from the asset store, maybe you give that a shot? It works for me
its async
Are you sure it's not throwing exceptions?
Why don't you throw a try-catch around it?
you can just catch them with something like this
public void StartWebSocketClient(){
var ca = "wss://" + _serverAddress + ":" + _serverPort + "/";
SystemExtensions.Log("Connect to " + ca + " (WS Client)", SystemExtensions.MessageType.Network);
wsc = new WebSocket(ca);
wsc.Log.Level = LogLevel.Trace;
wsc.OnMessage += (object sender, MessageEventArgs e) => {
ClientDataBuffer.ReceivedBytes = e.RawData;
string jsonString = System.Text.Encoding.GetEncoding("Shift_JIS").GetString(e.RawData);
ServerCall jsonToCall = JsonUtility.FromJson<ServerCall>(jsonString);
SystemExtensions.Log(DeviceUser.deviceState + " receiving: " + jsonToCall.type + " ( Station: " + jsonToCall.stationNumber + ")", SystemExtensions.MessageType.Network);
};
wsc.OnError += (sender, e) => {
SystemExtensions.Log("WS Err msg : " + e.Message + " (WS Client)" + sender, SystemExtensions.MessageType.Error);
AppManager.instance.SwitchAppState(AppManager.NetworkAppState.Disconnected);
};
wsc.OnOpen += (sender, e) => {
SystemExtensions.Log("Connected to webSocket server (WS Client)", SystemExtensions.MessageType.Network);
ClientDataBuffer.IsConnect = true;
AppManager.instance.SwitchAppState(AppManager.NetworkAppState.Connected);
};
wsc.OnClose += (sender, e) => {
SystemExtensions.Log("Disconnected from WebSocket server (WS Client)", SystemExtensions.MessageType.Network);
ClientDataBuffer.IsConnect = false;
AppManager.instance.SwitchAppState(AppManager.NetworkAppState.Disconnected);
CloseWSClient();
};
wsc.Connect();
}
alright
So maybe it is crashing because you dont have hooked up anything on close, ocnnect, error, just assuming.
@ornate zinc Where do you see that it's async?
The source code doesn't suggest this, provided I'm looking at the correct repo
And if it was, he should be awaiting the Connect
how do I do that
You can't if it's not marked as async
ah
Just try that code above I send, try to hook something up to onmessage error close and open, simple debug, and see if it gives you something or is still crashing
nah the async fixed it entirely
orrrr go with async 🙂
but ill probably add the onclose stuff too
You might want to reconnect and stuff, so yeah, I would check for them 🙂
SimpleWebTransport https://github.com/MirrorNetworking/SimpleWebTransport might be one of more maintained WebSocket transports when it comes to free ones. It was made by one of the Mirror Networking peeps after getting burned by all the other viable WebSocket transports, like websocket-sharp and Ninja.WebSockets.
There doesn't seem to be any documentation beyond the source and a reference implementation in Mirror though.
Does anyone know if MLAPI's "BitStream" would pretty much be kind of like LiteNetLib's normal (low level) features?
Like, are there any advantages of using MLAPI for connecting clients and stuff, and then just doing kind of low level stuff and not using their SyncVars?
MLAPI has a nice discord server btw.
At least it would wrap the transports for you? 🤷♂️
I'm using Photon Pun and I tried to connect using the same device running a built version of the project but it doesnt match up with unity editor scene
using System.Collections;
using Photon.Pun;
using System.Collections.Generic;
using UnityEngine;
using Photon.Realtime;
using UnityEngine.UI;
public class PhotonOnlineServerMaker : MonoBehaviourPunCallbacks
{
[SerializeField] private InputField CreateGameInput;
[SerializeField] private InputField JoinGame;
private void Awake()
{
PhotonNetwork.ConnectUsingSettings();
}
public void JoinGameFunc()
{
RoomOptions roomOpts = new RoomOptions();
roomOpts.MaxPlayers = 3;
PhotonNetwork.JoinOrCreateRoom(JoinGame.text, roomOpts, TypedLobby.Default);
}
private void Start()
{
}
public override void OnJoinedRoom()
{
PhotonNetwork.LoadLevel("a Scene");
}
public override void OnConnectedToMaster()
{
PhotonNetwork.JoinLobby(TypedLobby.Default);
Debug.Log("Connected");
}
They end up in different rooms?
Wdym
void Start() {
ws = new WebSocket("ws://localhost:8765/echo");
ws.ConnectAsync();
ws.OnOpen += (sender, e) =>
{
ws.Send("CONNECTED UNITY");
};
}```
Is this the right way to use events in unity?
Like should the event be in start() or somewhere else?
Yes, this would work, tho I'd add all my event listeners before calling Connect, it's safer, since you can be certain that you won't miss any events.
Unity won't restrict you on these stuff, just follow the intended usage design of the library you're using and you'll be fine
Well ... Actually, there is one restriction I can think of now, all operations on unity objects need to be performed from the Unity Main Thread, but your socket library will most likely invoke its events from a separate thread.
So you'll have to queue those events as Actions and invoke them from the Unity Main Thread, such as in an update loop.
But that's for you to be surprised by later 😉
Ended up just making them into their own methods instead
seems to be a lot cleaner
MIRROR 30.2.2 IS LIVE ON THE ASSET STORE
Download: https://assetstore.unity.com/packages/tools/network/mirror-129321
ChangeLog: https://mirror-networking.com/docs/General/ChangeLog.html
@manic raven That's definitely not a networking question. If you're using rigidbodies, then your problem is that you're rotating the rigidbody. Don't rotate the rigidbody.
I do, however have a networking question for someone in here. When implementing server-side movement in unity, should you use physics.simulate to simulate multiple velocity changes in a single update?
Specifically, trying to build clientside prediction. I think I already know the answer, just want a definitive answer before I waste 3 hours implementing it tomorrow
Second question. If I am, in-fact, supposed to use physics.simulate, and the player bumps into a rigidbody hinged door, for example, would it still work as intended if not doing physics.simulate?
@manic raven That does look not related to networking and lerp
Looks like your camera moves in fixed update
Camera should move/rotate in update and movement delta should be multiplied with Time.deltaTime
Or if you wanna use rigidbody for camera, should have interpolation setting enabled and edit camera transform via rb.position and rb.rotation instead
.
@slow monolith You wanted to predict everything or just the player?
i had network transform working in a 2d top-down space racing game that i was making, i was using the mirror network transform thing, but now i have had a headache for a hour cause i tried improving it, then broke it entirely and now cannot get a backup back or anything, it just does not sync at all between the two instances, and on the client screen both player objects do not even spawn
i have had unity for only two days so i am definetely a beginner and i just dont know what to do now
please someone help me
i can tell you info and screenshots of my settings
heres one of the two players
and here the other
i didnt manage to figure out how to spawn two players with one prefab, dont shame me, i know there are better ways, if there is one that fixes this AND its better, please let me know
You have errors @hexed remnant
Errors stop Unity from running properly
If you have only been using Unity for 2d days DON'T make a multiplayer game
Make a small, simple game. Get used to c# and the unity workflow
now i have another problem
the player keeps disappearing when i hit start
like it gets
disabled
why does it do that
ok fixed it
@weak plinth i cant' merge ur PR
How come? And I've changed a whole lot in my fork in the meantime
wrote this on GH: "I can't accept this PR because you changed the entire project structure, namespacing, tons of changes to method naming, etc... it means i'd have to update all my projects that use this which is too much code to go through and patch by hand."
Ah I see it now.
I was secretly hoping a PR would keep the pointer to the branch when it was made. Instead of including the latest
so this is unusable to me sorry
I'd have to check if I can create a PR from a specific branch, and revert that one to include only the package.json
dont bother
Hmm, alright
@weak plinth https://github.com/DennisCorvers/UnsafeCollections/blob/master/UnsafeCollections/Collections/Unsafe/UnsafeBitSet.cs did you add yourself to the headers of all the code i wrote?
Yes, only in places where I actually edited something
where you changed formatting and renamed methods?
that is NOT how this license works you know that right? you cant just claim EQUAL copyright because you modified some small parts of my code
i still wrote 99% of it
I wasn't aware of some arbitrary percentage that you need to contribute in order to see yourself as a contributer
Dude. WTF.
you are not setting yourself as contributer, you are claiming equal copyrights over another person's work, which is totally different
Hahahahaha
I am using Photon Pun and this code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Realtime;
using Photon.Pun;
public class PhotonOnlineMatchMakingOnePointOne : MonoBehaviour
{
public LoadBalancingClient LBC;
public ExitGames.Client.Photon.ConnectionProtocol ji;
public void QuickMatch()
{
OpJoinRandomRoomParams OPJRRP;
EnterRoomParams ERP;
ERP = new EnterRoomParams();
ERP.ExpectedUsers = new string[2];
OPJRRP = new OpJoinRandomRoomParams();
OPJRRP.ExpectedMaxPlayers = new byte();
OPJRRP.ExpectedMaxPlayers = 2;
PhotonNetwork.JoinLobby();
LBC = new LoadBalancingClient(null, "MyAppId", "0.1", ji);
LBC.OpJoinRandomOrCreateRoom(OPJRRP, ERP);
}
}
I have connected to a lobby and the 'master' from another script but i get this error:
Operation OpJoinRandomOrCreateRoom (225) not called because client is not connected or not ready yet, client state: PeerCreated
this is networking, all of this stuff is async
calling JoinLobby doesn't instantly put you into a lobby. It is the internet, so that just starts the process. You have to use callbacks. Be sure to do the tutorials before trying to guess how to do this.
Couldnt find any effective tutorial on most of it i only found PhotonNetwork.JoinUsingSettings() and PhotonNetwork.JoinLobby(). I just saw LoadBalancingCLient and OpJoinRandomOrCreateRoom in the docs and done the rest on my own
also how is async relavent to any of this. How is it async
you cant join a lobby if you are not connected https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro
{
protected override void OnMessage(MessageEventArgs e)
{
Debug.Log(e.Data);
}
}
// Start is called before the first frame update
void Start()
{
var wssv = new WebSocketServer(8765);
wssv.AddWebSocketService<Echo>("/Echo");
wssv.Start();
}```
The function is called by pressing a button and the buttons script says that it is only able to be clicked(by changing its scale) OnJoinedLobby()
My server doesn't seem to be working
I'm sending him data but he's not receiving it
My client works fine because I already tested with a python server
usually you have to be bind a port and address (unless its taken automatically in websocket, no idea)
the client shouldnt know if its localhost or internet address
server i mean
isnt there any overload on this var wssv = new WebSocketServer(8765);
on WebSocketServer()
I have no clue, this is my second day with websockets
well, check ;p
you just type WebSocketServer( in vs it should point to all method with some arrow to go up and down
sometime it can says if its default local or internet address
i never worked with websocket but most socket api work like this
i cant find anything related to WebSocketServer here, just checked
where did you get that from
package?
protip, you should use photon, take sometime to learn but you will get further and way faster overall.
Okay yeah for some reason nothing in my console is displaying on my server scene :/
so there's that
so the websocket is most likely not broken
oh, I never attached the script to a gameobject, im a fucking retard
That's one way to waste 2 hours
When using PUN(v1) , when setting isMessageQueueRunning to false does it also disable all the PUN Callbacks like OnPhotonPlayerConnected etc? Or only RPCs and OnPhotonSerialize callback is affected?
Hello Everyone !
Christmas is close, and I got a present for you my fellow Unity Developers : 💯
We're over the moon to introduce you Synergiz LightHouse :
https://techcommunity.microsoft.com/t5/mixed-reality-general/introducing-synergiz-lighthouse-integrated-real-time/m-p/1998329#M35
🥳
It's a really powerful multi-user solution, mainly for Mixed Reality HoloLens but works everywhere!
LightHouse is quick and easy to implement at any stage of the development !
TECHCOMMUNITY.MICROSOFT.COM
Hi everyone! Hope you're all doing well! At Synergiz (French Microsoft MRPP company) we've been creating HoloLens content since the release of the first hardware version. We experimented a lot of tools to create HoloLens applications and we're now happy to say that we know what's painful and what'...
anyone know a way to sync animations in socket io?
guys
i have question
when i press key on my keyboard
this info is send to the server
then server calculates the pos
and then send it to client back
but when i testes that on high
ping
when i move my client simulate what server can simulate
and move
but then delayed datda from the server is send to client
and client is teleporting back
and following this path again
how i can fix that
chech last pos and dont teleport?
U send what input the server has seen to the client along with the pos update. Then you reapply all movements the server hasnt seen to the pos
Did you read most of the pinned documents @manic raven
Yes
https://www.twitch.tv/fholm is currently talking about how to make a network transport
@grizzled narwhal 🙂
Streaming again tonight at the same channel https://www.twitch.tv/fholm and same time (9pm CET). Same topic, building a udp transport from scratch.
My next stream is in 1h 15mins (9PM CET) from now, over at https://www.twitch.tv/fholm
live now at @ https://www.twitch.tv/fholm
does anyone know how to impliment rollback networking using PUN?
or at the very least make players keep moving when lagging?
Pun is typically client authority. Rollback doesn't typically come into play in a relay environment.
so I can't do rollback with PUN?
is there any free online thing that I can do rollback with
Rollback for what? Server authority shot rewind?
taking the plunge into bolt from mirror today, seems the necessary step at this point with what I know and what I need to know to get a solid system in place for an fps
any warnings before I do so?
I've heard the workflow is a bit, weird
Rollback like the server assumes youre doing the same thing youve been doing when the client lags and then puts you where youre supposed to be when the client stops lagging
Im very new to networking stuff so i hope that makes sense
what kind of game are you making?
Fighting game
@versed yew other than Photon Quantum, there aren't any full feature rollback solutions out there for Unity really. There's a thread on the topic here: https://forum.unity.com/threads/deterministic-rollback-lockstep.1017223/
here's another discussion on implementing GGPO, a library that helps with rollback for fighting games: https://twitter.com/mauvecow/status/1182084533035757568
Unity Forum
Hi,
I wish I could ask about this rollcode/lockstep solution for netcode. I know it is as complex a solution as it is and it seems that projects or...
Alright. Can actually talk for an extended period again instead of making one-offs, so let's talk a little more about GGPO and rollback netcode implementing.
Retweets
498
Likes
904
thanks
should I still be using PUN or should I drop it
I'm not actually sure what the most common way is to get started fast with fighting games netcode, so I'll see if anyone else has thoughts—for some genres, you can just skip server authority entirely and allow the client to decide where their character is etc. This has the drawback of allowing cheating, but until your game is successful it may not matter
not sure how well client authority would mesh with fighting games
I'll try stuff out, thanks for the advice
If you just want to learn advanced networking, try writing your own. If you intend to get a game to market, go with Quantum.
Many ways to get there too
And you'd be surprised about how little developers care about players cheating
Deep Rock Galactic is a pretty popular 4-player co-op game, where you can just edit your save file and get every item you want
Yes people are way to obsessed about their indie games with a combined player count of 83 people being target of advanced cheat creators from china 😄
So, League of Legends Wild Rift was made with Unity. Any1 knows how they handled their networking part?
Is there any guide how to save playerprefs in any cloud?
playerprefs are saved in the registry of your system, not sure you can really export directly, you rather have to come up with your own savefile or json or what not to store it and shar eit @earnest leaf
What if i release rpg kinda game, with no in game purchases, and free, but with no cloud save, is it "OK"? What do you think?
It would but it is just a pain in the **** to debug... you always have to either build a manager around it to show in inspector or always use the regeditor to check them. You are easier with just writing a custom class that holds your stuff and save that to a file and load it. Therefore you can see everything easily in unity
I have no problem to reset my saves, using playerprefs, im asking if its ok to release the rpg game in playmarket, with no cloud save, just on device save
i'm just curious
Ohh, well, if someone deletes the game, the progress is gone too
I mean i know 90% rpg android games are with cloud save, but..... Looks like my passion ends on cloud save programming difficulty, heh)
Well you can just use a simple CMS like wordpress or so to get a REST API and save load files there. Just for starting, do not worry too much about that. Where you are saving is something you can still think about later
Are you sure you can't just use the Android APK for something like that?
That's what I'd expect, comparing to Xbox and PS at least
Hello does anyone know if i can create multiplayer card game online with p2p networking ?
and if there is an unity asset which can help me doing that, thank you.
Heyho 1 question i currently use Mirror and have everything done networking wise the only thing i miss is a Good Login/register system with a database
is there any out of the box solution for that ? like a service that hosts a Database and has API calls for a login system
i could make that login system by myself but that would be hella insecure
Playfab
What networking does Rust use?
Seems to be modified Raknet. https://garry.tv/rusts-networking
Probably nobody, just curious has anyone heard of the new photon Fusion supposedly replacing bolt/pun? I've just began the process of moving from mirror to bolt, so this is a bit worrying
jump to MLAPI discord
There was a long discussion about it there
But @somber drum, a couple of things:
- Bolt will still receive bug fixes
- If you have enough time, take a look at the new stuff when it comes out (it won't take long)
Awesome will do thanks!
I'm live at https://www.twitch.tv/fholm
Will be streaming again at 9PM (CET) tonight. Same time as before. Same twitch channel https://www.twitch.tv/fholm.
when overriding Photon Pun's OnRoomPropertiesUpdate method in a MonoBehaviourPunCallbacks is there a way to retrieve the previous values of the custom properties?
hey quick question bois, how do I sync the position of a gameobject that isn't the player with other players via photon?
feel like I just need to add something to the gameobject so photon can see the position but not really sure. Noticed that host can pickup a cube and the other players will see it just fine but when non host players grab the cube its just stuck and starts glitching the screen hard if you try to pick it up.
Thanks in advance, new to photon/networking so sorry if dumb question lol
@weak plinth That is most likely due to authority. The one who has authority generally sends stuff for other clients to receive.
@spring crane how would I go about resolving that so everyone sees everyone’s stuff
I'm pretty sure you need to add the photon view component and the transform photon view component to the gameobject
but I'm not 100% sure, I'm not super good with photon yet
That’s my current setup on the gameobject @versed yew
make sure the transform photon view is dragged into observed component in photon view @weak plinth
@weak plinth The simplest solution is to change the owner on the fly
@spring crane change the owner of the room? @frank quiver that is also my current setup, do I need to add a script or anything to the gameobject?
@weak plinth Owner of the object
@shadow stagny
ooops sorry lol
think you might be right gonna dig deeper into that, thanks!
What are people doing these days for networking? All the docs seem to say everything is deprecated, good luck. I'm making a card game, so don't have particularly high needs, but authoritative servers are required. For a new project (Unity 2020) what would the recommendation be to start with?
Mirror is kinda easy mode for that. Its pretty much the use case for mirror.
Cool, thanks!
Is it bad practice to send animator parameters over the network?
My player motor moves my character controller, and I set a Speed property on my animator.
When I just sync transforms, the animation doesn't play on other clients because nothing is setting speed.
I can either have other clients determine speed, or I can sync the animator parameter for speed.
Which approach is generally more recommended? Thanks for any help