#archived-networking
1 messages Β· Page 71 of 1
that says "Player B took 10 damage"
it literally won't work?
or it's a bad idea
If the hit is happening, then yes your previously posted code will work. As long as the health change is coming from the OWNER of the health object
You can do that too sure
if you want to bake in the critical hits and such. Wide open for hacking with all of this, but that is the nature of client auth
right i see
PUN2 without server plugins should only be used for games where you aren't expecting or inviting hackers
okay yeah i was just trying to distinguish the actual mechanics
from like
best practice
for now this is really just a hobby game
so im not too too worried about it
The shooter has authority over its weapon and its own health
ah okay
The person being shot has authority over their health
and i have to design my code around that
so the conversation is A tells B "I hit you"
around what a player can say
B tells all "I took damage"
A telling all that B has a new health value... will be fragile
i was conflating the like actual API with what you were suggesting as structure
because now you have both A and B acting as authority over B's health... so avoid that
Rather than see a weird delay between the shot and the players health dropping on other players, you can have other clients lower the health in expectation that B is going to report that change
As long as if that prediction is wrong it doesn't break anything
and is just cosmetic
so i can pass i hit you here with this weapon
yeah, perfectly valid
I personally pass a list of hit objectIDs along with a mask for HitGroups (head, body, critical etc)
Its all bitpacked for my stuff, so I can get pretty verbose
so
Typically for games you favor the shooter, so recreating the shot on the health owner will lead to annoying results for the shooter.
So best for client auth, to just take the shooter at its word
RPCs generally look like this:
<photonViewToCallMethodOn>.RPC(<method name>, <args>)
or sorry there's another param which is like <which clients>
so when the shooter reports a hti
You are welcome to peek at the SNS code, it handles all of this but in a much more deterministic manner
it calls an RPC on itself?
The demo scene and tutorial has hitscan and projectile weapons and health systems
oh nice
https://assetstore.unity.com/packages/tools/network/simple-network-sync-134256 its based off of this Library I made independently, but for PUN2 I am wiring up Syncvars and a component library for drag and drop of this kind of stuff.
Is Beta, so not pushing it on anyone, but it does exist and it addresses a lot of this kind of stuff.
cool i'll take a look
C# program on server to talk to clients(process/validate user actions), and to talk to SQL also on server (store player-state data). Is there a name for this kind of program (looking for search terms to do additional research)? Follow-up question: can such a c# program access/use the Unity API (like say.. Vector3) if I DONβT build it with Unity, but with visual studio as a system βserviceβ program?
Unity is more of an ABI than API. It's not externally accessible by default, you need code in linked assemblies to be able to access functions and data.
You can of course write your own API in Unity that can talk to external programs
https://gist.github.com/fholm/d1e933136cd51fc3a25e2e0b810781f3 like this
@graceful zephyr Hey man, thanks for sharing this. But how do you dispose the memory allocated with malloc ? I haven't used unsafe code much.
UnsafeUtility.Free
Oh roite. I was looking for a line like that in the code.
this is just a small example
out of a larger thing
it might not have all methods etc
For reference
Or https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/unsafe-code for non-unity specifics ;P
it might not have all methods etc
Yeah this is why I was wondering like "where's IDisposable implementation or something"
I think FSE_Vince has a pretty complete library available
I have a couple as well, if you catch the bitpacking bug @sacred patrol
@prisma girder "you need code in linked assemblies to be able to access functions and data." Right.. so even if I reference these in a non-unity project, I will NOT be able to use them? (this DOES work when I generate DLL's.. course I've only used those dlls in unity so far.)
The unsafe stuff won't get you great gains unless you are doing a a pretty long set of bitpushing wrte/read ops, but if you are doing a lot (like serializing your entire state in one shot) or if you are running IL2CPP - unsafe bitpacking definitely is faster.
I have a couple as well, if you catch the bitpacking bug @sacred patrol
Haha, thanks but I'm not that much into hardcore optimizations yet. Just using a good ol' sloppy [Flags] enum and a built-in Photon serializer got me far enough.
The pinning cost for small writes negates your gains from the testing FSE_Vincenzo and I did on our libraries.
Just ping me in the channel if comes to that, I can look up his libs and link mine
I learned all of this from a lib fholm made public like 4 years ago when I asked him if he knew of any good bitpacking libs. So everything comes back to him π
Some of my code still has has MIT header and credit on it.
Alroite
I'm like doing something very wrong
void Update()
{
if (photonView.IsMine)
{
if (Input.GetButtonDown("Fire1"))
{
Debug.Log("I am shooting");
photonView.RPC("Shoot", RpcTarget.All);
}
}
}
when i have two players
and i click
the other player shoots
Ignoring the wrong part of that being that you are capturing what is a state/simulation operation in Update rather than Fixed, that looks right on the surface.
What object is that one? and in what Class?
this is in a "ShootingController" class attached to the player prefab
[PunRPC]
void Shoot()
{
Debug.Log(transform.name + " is shooting");
AudioSource.PlayClipAtPoint(tempRevolverShot, transform.position);
if (photonView.IsMine)
{
RaycastHit _hit;
if (
Physics.Raycast(
fpsCam.transform.position,
fpsCam.transform.forward,
out _hit,
equippedWeapon.range,
shootableMask
)
)
{
Debug.Log("We hit " + _hit.collider.name);
string hitTag = _hit.collider.tag;
Transform hitTransform = _hit.transform;
bool hitPlayer = hitTag == "PlayerHead" || hitTag == "PlayerBody" || hitTag == "PlayerLegs";
if (hitPlayer)
{
PhotonView photonView = PhotonView.Get(_hit.transform.gameObject);
photonView.RPC("RpcGetHit", RpcTarget.All, equippedWeapon, hitTag);
}
}
}
}
the idea i had here is that
it should tell everyone that it shot
so they can all play the audio
and then in another IsMine block
Very fast glance I see a problem with that IsMine check in your RPC
it'll do the raytrace and potentially sned out the "GetHit" RPC
i'm treting IsMine like isLocalPlayer in UNet which ihad sort of working before switching to proton
Without the wall of code, what are you doing here?
okay so here's what I'm trying to do
i guess i thought that the RPC would execute on every client right?
including the one it orginated on?
That I don't know. I literally don't use RPCs
I would check that assumption
and see if it does fire, is it delayed by the trip to the server and back
"Call a RPC method of this GameObject on remote clients of this room (or on all, including this client)."
But typically that shot call would be done locally by the owner, not in the remote code.
You fire locally, get the result, then RPC out the result.
right
okay i'm changing the RPC to just a normal method call
i deal with the audio later
having it in the body, I cant comment. That is odd.
moving is also
like flipped
well
here's the weird thing
when i'm alone
like only one client on the server
i can move fine
then if someone else joins i start controlling them
π€¦ββοΈ
You got bugs yeah
i'm like not grok'ing something
I'm mobile now going for a walk
sure no problem ty for all your help i really appreciate ti
@tribal vessel maybe take a look at magiconion or asp net core generally?
<- reading Magic Onion "What is it?" docs for the third time, lol/cry.
best line from docs so far: "Here is the sample filters, you can imagine what you can do." lol.. but seriously, this looks great!
i asked this on another section thingy and there was anothere problem going on. Then i relized this is the proper place to put it. So is there an easy way to pass a Vector3 threw unitys networking?
@faint goblet You mean UNET? If so, you can use the networked transform component from the UNET package or serialize it with UNET's message API in scripting. Do you know UNET is deprecated?
yeah, be sure to indicate Netcode vs UNet when talking about built in networking
oh thanks
Hey guys should I use Mirror for my unity game? Ive been trying it out and I think I'm getting the hang of all this command and clientrpc stuff, but is it the best option? I'm new to multiplayer.
@sullen steppe you can fix controlling other clients by checking if local player on the movement script and disabling it if it isn't the local player
Or checking hasAuthority might be better actually.
@untold sentinel mirror is fine if you are starting out, it's not the best but has a lot of documentation and an active community
@hallow fractal Here would be ideal
@jade glacier here we meet π
Ok, wait i have to include you asset because i removed it, than i tell you where im stuck
So my capacity to really dig into stuff is a bit limited right now, since I have a pile of dev work to get done for Exit, but we should be able to figure out where you are going off the rails
Can hold off on using SNS
Would be fine to just try to figure out what was going wrong with Vanilla PUN, to find the bug in your code or setup
Basically step one is to back things up until you can get things spawning correctly, before adding any extra code/components
Yeah, im at that point now, i mean now i will include your asset again in my project that tell you when the issue appears
So right now you can have 4 players join, and all 4 show up correctly?
Without your asset yeah, everything does work, just let me test it again to be sure 100%
@jade glacier yes i tested with 6 players
It works
Ony the players controller
Almost all issues tend to result from controllers that are fighting with the syncs
So next step is to add a transform sync, TransformView or my SyncTransform
Have the editor be the last player to join, so you an see in the inspector where all of the players are, and what their transforms are doing
Soo i show you the video i made before if you remember
Just to see the problem i had
Yeah, things go sideways, we have to dig into what the conflict is
If adding a transform sync makes them vanish, remove the controller code but leave the transform sync
We are trying to isolate down to where the conflict is. The most likely candidate is the controller is fighting with the syncs on players that don't have IsMine
Yeah alright, just have to include you asset, than tell you when im ready
Wait, i have to try
An issue in that video if I recall is you seemed to have both SyncAnimator mixed with PhotonTransformView. So trying to avoid any weird mess like that yet.
soo imported the project
getting this now, i know i had this before but forgot how to slove it
Assets/emotitron/SimpleNetworkSync/Assistants/Editor/LauncherAssists.cs(43,18): error CS1061: Type Photon.Pun.UtilityScripts.OnJoinedInstantiate' does not contain a definition for AddPrefabToList' and no extension method AddPrefabToList' of type Photon.Pun.UtilityScripts.OnJoinedInstantiate' could be found. Are you missing an assembly reference?
@jade glacier soo should i remove this line from the code?
i have already a instantiate script
I am recalling that as well, forgot the conflict there, let me look
Yeah,that is just an assist - its not critical. Not sure why the conflict but will fix that if I already haven't
so i remove the line ok
yeah, won't affect this.
The latest PUN2 had some changes to OnJoinedInstantiate so I need to sync up for that is all.
soo ok, now i imported the project, i havent done anything yet
No errors in the log now?
Shouldn't, the sync accounts for that
ok, i have a character controller, i heard its better for leg
Basically the sync leaves the object RB as is if IsMine is true, otherwise it turns it into kinematic
CCs often use an RB that is kinematic
shouldn't matter
the sync is just capturing the tranform state every tick on the owner, and broadcasting that over the network. All non-owner versions are turned to kinematic if they have an RB, and they are moved by their transform.
So what your RB setup is and how you move it shouldn't matter
So first thing now is put a sync transform on the root of the player object where the PV is.
See if that breaks things
there are a lot of controller looking things on there
only the character controller is waht i need
i disabled the others, just to be sure
might want to add AutoOwnerComponentEnable
Will auto disable a bunch of that without you having to go in by hand and add IsMine to everything
Yours will be a bit different since that beta is older, but it should create a list of unrecognized components, that you can tell to auto enable/disable based on ownership
take off the sync animator
lets go a couple components at a time
adding too much stuff at once makes debugging futile
You can try that for giggles since you just did it
Give that a shot and see how it breaks or doesn't break
yeah, you have a wall of components there which is a rough place to start testing networking
let me log in now hrough the builder
I can't debug all of it without your project in front of me, but I would back WAY up with this and get rid of all of those components.
You have like 8 components on that player already that were added before you had networking working - so you have a large pile of sand to dig through.
For networking you need to get the networking lib in place first, and then slowly start building up your code, testing every step of the way.
So I would back up first to just a basic movement controller on your player, and trying to spawn/sync that.
hmm something weird is happening, now i joined the room through the console and it worked, i mean i can see the other players, but the 5 player that didnt work before that coulnt see no one now its seeing only the one that joined from the console/editor
Backing up on that, did you join last with the editor?
yes
Did the editor show all players present?
Errors are helpful yeah
but i think these errors have nothing to do with my issue
Errors have to go
all errors are for the ui
Object reference not set to an instance of an object
emotitron.Networking.VitalUI.LateUpdate () (at Assets/emotitron/SimpleNetworkSync/SyncVitals/UI/VitalUI.cs:184)
errors mean code didn't execute and that can do all kinds of messed up things
these are for the armor and health, i dont need them
Just remove the Vitals stuff
ok, soo it means i have no error
At this point we just want your movement code, and a transform sync
which of those controller components actually matter? You have like 3 of them
only the character controller
Get rid of everything, you are putting yourself in debugging hell with all of that on there
lose sync state for now, lose mounts for now. I wouldn't do the whole ConvertToPlayer assist thing yet until you debug this conflict
the player movement controller if for mobile
Just your original player, with the most basic controller... and add SyncTransform
Still not thrilled with all of those controller components (3 total), but sure give it a shot
May still need/want to add the AutoOwnerComponentEnable if your scripts aren't all wired up with IsMine checks.
Join with the editor last, look for warnings, and check the transform values of players that seem to be not where they should be.
ok, soo when i joined with 5 it worked, but than the sixs one that joined it didnt work, than i joined through the editor and it didnt show other player,,,,
but this errror is showing up
No Object found for viewID 3001.
It is not unsual with PUN2 for messages sometimes to arrive before their target gameobject is ready at startup.
UnityEngine.Debug:LogWarning(Object)
over and over, or just a few times?
it wont stop, i mean the error is just repeating
How large is your project? That might indicate an legit bug I should open up your project in that state.
No previous warnings or errors?
no
That indicates a failure to spawn the object
its a small project,
Yeah, export a package if you would for me
So in the editor, none of the players show up as spawned in the hierarchy?
no
Yeah, going to be easier for me to open the project and see than try to guess.
Failure to spawn is typically a PUN thing, so for SNS to somehow cause that... worth looking into.
How are you sending it?
wia megaupload, its the best
I only have 2018.4f for that, but shouldn't matter.
When this works im gonna name a npc after you π
It will eventually work, you aren't doing anything exotic here
just have to sort out what this bug is
I still need a link btw
Sure, just putting into rar and than upload
Oh, im sending the whole project
yeah, please dont LOL
Alright, i usually do this with friends ahah
If you do that, just share a git - otherwise just export a package
if its small enough, can just drag it into a PM here
Uncheck all textures and sounds, I don't need any of those
will take a few mins to rebuild. Will let you know if I can reproduce the error.
alright π
In the meantime if you want to try stuff, try removing all controller code and see if just the sync on your object results in any issues.
Things fall apart at 6 players you said?
old?
just opened the asset store, its dosent show any update
very odd, because this OnJoinedInstantiate component is definitely old
will i have error now when i import the new?
No idea. You have a lot of assets in this project already, so you already have a pretty messy stew of stuff. The log is like 100 lines of warnings when I opened your project.
So you are really not in a great starting place to begin networking. π
But I would get the current PUN before getting too far, there will be bug fixes and such that you might end up dancing around needlessly with an older one.
I can't even get my demo scene in this project to connect, so not sure what is up.
Be sure to delete the old folder, and import the latest PUN2 Free (unless you paid) in clean
I'm trying that now with your project
i imported the new one, and build the game, its works, i mean its again the same issue,, all the ones that i opened through the build do work good with each other, but when i joined through the editor i coulnt see the other players in the room
yeah, working on recreating that here - first have to get even my demo scene working and sort out why my builds aren't connecting from this project
well, now i notice one of the ones i opened through build its the same like in editor one
If the editor is showing player objects as having not been created, there is something serious going wrong
If they are there, but in wrong places or have messed up scaling, that is a different issue
Until I get a working repo happening here, I can't even guess
this error still shows up
No Object found for viewID 4001.
It is not unsual with PUN2 for messages sometimes to arrive before their target gameobject is ready at startup.
UnityEngine.Debug:LogWarning(Object)
but the nr like 4001 changes
2001, 6001 and so on
open the build like 5 times, and than join through the editor, you will see
the player setup error hase nothing to do with it, it shows becuase i removed the components
yeah, that indicates an object has not been spawned
I got my test scene working, so where is our scene?
I got my demo scene working in that project to make sure things are firing right, now need to try your scene
Nope, still trying to untangle why this project after import is having so much trouble
first step was updating PUN2
Firewall is being weird with this project. Will poke at it more a little later.
hmm? you build it, i mean did you reproduce the same issue that i did?
Other issues to resolve first
No idea, I haven't gotten to it yet - have to first resolve why this imported project is getting blocked by my firewall
just to note, i am using only 2 assets on that project, BattlePhaze and AllInOneGameKitELC
So where is your scene that I need to build and run?
Lobby and GameScene both needed?
one for the lobby and than the game scene
That transition is suspect for getting started
really? but most if not all games do use multy scenes
Second client trying to join room is just hanging at trying to join
First client seems frozen
ohh i know
you need t go to the gamescene and put my character prefab at the game manager
it happens alot, never know why
this character from the resources : Player character contro
You are creating the players characters before being connected to the Room?
Or is it spawning those after the scene change or something?
hh?? i cant follow you,,, in my game scene i have a instantiate script, than put my character from the resources on it
can you join the game?
I am recreating the issue, but there is a wall of other issues I have to parse through first.
Do the other issue have something to do with my project or are these from your asset site?
Are you using buffered RPCs or anything like that in this project?
Its just slow trying to test things because the process of getting 5 players connected takes 2 minutes of having to type in names and click buttons
I would suggest for network testing to remove this whole lobby thing and add that later
Dont know how to change that, you saw on that video i posted, it was really fast
Just with the PUN prototyping componetns
Ohh alright, you can do this if its easier
Then you just run it, and it will create a room and spawn players for you without all of the clicking around
You will go mad trying to debug networking if every test takes 5 minutes
I thought code changing is needed
You have to break thigs into small bits for networking
you literally will spend a month on this stuff if you don't streamline how you iterate
Networking is 90% of the time broken
and is already slow to test because of the need to build out
so anything you can do to shorten the test cycle is good
I really never thought if it, but this can only been done with that one script of yours that you showed
I would start there, and just get your players spawning and moving right
Then replace the prototyping stuff with your more advance systems for matchmaking and such once you are happy with your mehanics
As you are seeing, stuff that should have been resolved in hours is taking you weeks here
Too many moving parts in play at one time
I will make this in the future projects, but you need to know that i only noticed this problem after i played with my cousin, he told me that the animation like attack are not sync, and than it was too late to simplify the project for testing,
I would never thought that animation would be my biggest issue
I watched soo many tutorials, and followed them
Until i got across your asset
There may be a bug in the asset, but I can't get to that until I get this cleaned up and iterating tests quickly.
I would nuke all of the shaders and such too during testing
Will let you know, I have to tear the scene apart and strip this down to something that can tell me something.
All I can say so far is you have WAY too much complexity going on here for the level of testing we are doing.
But that isn't the cause, it just makes finding the cause very hard.
You can delete these if you can, everything except the character itself π
already doing all of that. I have the scene auto launching and spawning players, and I have removed all of the controllers.
And moved the camera so its easier to see instantly if other players are all showing up
The editor is having issues, but so far the builds are all seeing one another.
there is some odd behavior of the charaters showing only after the next client opens
After the second you say? What kind of behavior, not the issue right?
Editor is having the usual PUN region issue of finding a different region, but resolving that
I only did for Europe,
I'll just get back to you with my conclusion when I have one
Alright than, hope everything will go well :/
removing all of the lobby code, and all of the controllers and other stuff from the player objects and just sticking on the animator sync and a transform sync... everything spawns correctly.
The editor gives a dozen or so warnings about updates arriving before object spawn, but they don't keep coming. The spawns happen and its all correct.
in your MobileFPSGameManager that timing for spawning characters is suspect
Typically I would put character spawn in OnJoinedRoom.... Not in a Start() method
May or may not be related, but there is a lot of headscratchy stuff like that all throughout
Soo what was the issue?
I mean you removed almost everything, so somewhere must be the issue
add them back one at a time until you notice π
I hope it isn't something that can change my project
yeah, that is kind of the problem with having so many moving parts
My guess is as good as yours without going through the task of slowly adding them back and seeing when it goes off the rails.
Are you still looking for the issue?
As best I can
I only have so many hours I can put into this though, I have work slated to get done this weekend
Ahh, I thought if not, so that you could send me the package so i can continue
If I don't find it, you will either have to give up on the components involved, or go through this process yourself of slowly adding things to a working starting point
yeah, I can export it
Alright, than i can add stuff back till the issue appears
I just put everything back onto the player object and its spawning on all clients and the editor
so looking more like an issue with the whole lobby/room handoff/spawning mechanism, or how and where you are spawning.
βΉοΈ,,, stupid bug
I did just see a player fall through the floor, so that isn't good
A bunch of things got lost in the export, so anything is possible
I am not concerned with any of that, I just want to see that all of the objects are spawning
and they are
So the reason why im looking to make this work is making my animation sync over net
Can you export it differently?,
It has all the lost tags and such, but they don't matter for this
I stirpped out all textures and shaders as well
long build times are bad when doing networking tests.
nope
So how did you open the one i send you? Just made a new project and that import it?
yeah, in this case use a new project
Alright
this isn't meant to be a working game, this is to find the problem
strip out all garbage
cosmetics, whatever else
Soo this now works
you want fast fast fast build times and scenes that start up showing you what you need to see without having to enter a bunch of text and click a bunch of buttons in the game
It works because its using the prototyping launcher atm
Or at least is working for me.
Alright than, you can pm me the package back and i hope i can find the issue
Which is more affective?
Photon, or Mirror?
depends on what it's doing.
Keep in mind Photon is actually 3 different libraries, but I assume you mean Pun vs Mirror?
Pun is cloud relay based, and Mirror is Unity exe server based.
Pun hosting is handled for you, with the downside being you have no server authority unless you write plugins for it. Mirror you need to host a server, or do some work to allow players to host, but you have control of the server and it can simulate normally, as it is a Unity exe.
Which is more affective?
Photon, or Mirror?
@left ruin TL;DR: Mirror for flexibility and control, Photon for just getting stuff done.
Personal experience: I was recently writing netcode for a pretty big title using UNet, and I can't recommend it or any derivatives based on that library.
I still have PTSD from all the reflection hacks I had to write in order to make it work the way employers expect. They had a strict technical vision and their own way to do things. I had to adapt.
Once you advance with any library you will want to get away from the wrappers they provide and go right to the byte[] serialization and send/rcv of.
Pun and Mirror are both incomplete stacks, they get you messaging wrappers like RPCs and handle things like ownership and object IDs, but they both don't touch simulation or even encourage good practices when it comes to syncing simulations.
Unet/Mirror does use weaving at least with their RPCs and Syncvars to avoid runtime reflection
But it does create a lot of "blackbox" where stuff magically happens without really giving the new to networking dev any kind of clue what they are doing behind the scenes.
And they are all adhoc timing, encouraging treating messages as simulation - which always devolves in to tangled race conditions late in the production of any game.
I have an odd issue; (I'm using Photon PUN II)
So, I've had Photon PUN set up in my game for a while now. (The intent of the game is to put everyone in the same big room.). A weird glitch has been happening: Sometimes, some players join one randomly created room, and then another player can't find that room. It's hit or miss when it happens: Normally, a lot of people can join the rooms, but one person is "Locked out", it won't appear for that person at all, even if they shut the game down and re-open it. The only way to make the glitch go away is when ALL open rooms for the game close, it re-cycles things somehow. It's not like room limit or size is hit; It's just like one person randomly can't access a Photon-created room, it won't appear or show for them at all.
When this glitch happens, one person can't get into the room no matter what they do; The room doesn't appear in the lobby at all.
I'm having a lot of trouble reliably reproducing the issue too: But it still happens pretty often, and it's an issue when people are getting locked out of the game's main "room", and can't join other people, and no one can join them π¦
To the right, I have another "player" already in a room they made normally (I checked and they were int he default lobby when they made it). On the left, I am trying to show a listing of all the rooms: But in my editor version of the game, the room the other player is in just won't show up during this run! Also, even if this player in the editor tries to make a room, no one can find or join them!
Even stranger, in this second issue above (Same run, the game on the right is the same one open earlier), in this second image on the left, I have another executable for the game open: And the room shows up!
The issue is this: The room will show up every time when I pull up this second executable window, but it will never show the room in my in-editor window until I close all in-game rooms and try anew!
The issue isn't editor specific: Most of the time, the editor works fine and finds rooms, and so does the executable. But when this glitch happens, it can happen either in the editor, or on the executable on a player's computer: And when it does, there is NO way for the open rooms to show for them until all rooms shut down; It's like they are locked out somehow, even though they are all in the same lobby and have access to the same stuff!
I'm totally stumped with this... does anyone have any ideas? I would greatly appreciate any help you can give! π
The latest PUN added Dev Region to settings, to force a region in the editor and all development builds. Or you can set the fixed region. Either will ensure that all players are using the same region. @nimble eagle
@jade glacier OMG, that totally fixed it! You're the best, thanks so much!!
This issue was driving me crazy π
It's a common problem. Are you running the latest PUN2 btw?
I am not! But my version includes the feature to set a fixed region, which I had not been using before!
It's hard for me to update to the latest version on Assets, I'm the only programmer on the team... π
Is there something important I'm missing from the latest update?
Just remember if using FixedRegion rather than the new Dev Region that you have to remove that when you publish for real.
Or all users around the world are going to connect to the US
The new Dev Region only applies to the Editor and Development builds and is ignored by release builds, so you don't have to remember.
Okay, thanks @jade glacier ! Is there an issue with having everyone connect to the US when the game is still relatively small? I'd prefer to have everyone in the same room / interacting with each other even if there is more lag, since our playerbase is still pretty small!
If they live in Africa... might be a bit of a problem for those people π
You can do a bunch with the region settings, to reduce the number of zones
Oh okay, good to know! I'll look into that later
Oh, by the way...
@jade glacier , I wanted to ask you about another issue I had! This may be a long shot since I haven't been able to do much testing on it yet, but when I ran an Alpha the other day, players from Germany and (Poland I think?) could not load the game (At that time it was auto joining / creating rooms, so I don't have as much data from then); No matter how much they tried and re-opened the game, Photon would never spawn their player- I don't know what the exact issue was, but it was almost like they were not even connected to Photon somehow.
My Co in the Czech Republic had no issues, and it worked fine for him, so players in Europe can access the game; But I'm not sure why those players in Germany / (Poland too I think?) had issues, and the game wouldn't even spawn Photon Objects or let them make their own room?
That's a wall of text I don't actually have time to read closely, but it sounds like more of the Region vs Room stuff.
TL;DR: people in Germany can't play XD
Players when they connect automatically do some pinging for the first time to find which region they should use
Once that is picked, they connect to a master in that region
and that master will only matchmake them with people in that region.
They will only create and see rooms that exist in that region
You can give the user the ability to pick a region in their starting menu if you want to make that less automatic
The issue was, they were not even creating their own room: It was like they could not connect at all?
That I don't know about
I may need to do more testing, I don't have a lot of info on the issue yet ^^'
They connect to master?
Yeah, you need to debug every step of the operation. Turn on all of the debugging log stuff in settings
and see where its breaking.
There's is no official unet.replacement. the new netcode is a totally different approach, aiming at a different kind of developer. You should take a look at mirror
Which continued the unet approach
If you are going for the LLAPI stuff there are a bunch of transport options out there
MLAPI I think has some variant of Unet's transport still going
Can't speak to the transport layer currently being used by netcode
But might be just fine for what you are doing.
Transports are dime a dozen these days. The main thing is to abstract your own higher layers from them as much as possible so you can change your mind later
How should I think about when syncing like visuals. I have a projectile which can move thought multiple shields, and each time it does it will create a visual effect, and then finally an effect when it hits an object. So in a server authoritive setup, what is the way to go? I was thinking of having some rolling buffer on the shields or projectile, with something like {tick, pos, (effectID)}? I'm a bit hesitant to throw in the collision logic to the clients, and let it simulate the visuals of the info it has, if there would be some diff from server which would indicate wrong info to client...
As long as nobody's steering the projectile all the server has to share is where, when, and physical properties.
If the simulation is 100% deterministic this is all clients should need. If the server needs 100% authority then it would run the simulation too and correct any out-of-sync clients. In some cases reducing server authority in favor of anti-cheat mechanisms is favorable
Does this projectile bounce or deflect in any way that is unpredictable?
If you avoid the determinism problems with bouncing off of players or player affected objects, you can cheat quite a bit just by shifting the projectiles timeframe into the local players timeframe
Some are homing on ships controlled by players..
Good evening,
I am not sure if this belongs here, but I hope somebody can help me out at least a bit :)
Right now I am creating a geo-map Game with multiplayer,
I got the geo-map running and instantiating a player with gps etc works fine. The map is also running. That is for Singleplayer testing purpose.
But now im absolutely unsure on how to implement the multiplayer part. I have done multiple hours of research allready and somehow cant figure it out.
I have read about Photon Pun quiet a lot, and the 100 ccu seems like a great deal for starters. It seems like it saves much effort aswell.
How do you manage for example Enemy NPCS health? And how do you handle the positioning?
Does it have to be in a server database? Do I have to rent a Server just for that purpose?
Regarding the database, I would have help from a programmer if necessary.
Also, how do you store player-account-info, like LVL, EXP, Items, etc.
Is there any Asset that could help with that?
My plan was to let enemy npcs Spawn around a certain radius after players enter the Server,
loot should directly appear in ones inventory.
The instantitation itself shouldnt be the problem, but I would like the npcs to share the same life to every player if they are nearby.
Also, how much work-effort is it to differentiate between no players nearby -> dont have to upload current hp , so you save data
and players nearby -> share hp
Smart objects definitely throw a bit of a wrench in things, but might still be worth making some experiments with advancing their timing into the local players timeframe. @stray scroll
Basically it involves simulating the projectile forward 1/2 RTT between the client and the authority
And then deciding if that works, how to cheat the timeshift. Without some lerping you will basically be spawning the projectile on other clients already well ahead of the launcher, which might be undesirable.
Homing logic would have to act differently based on if your are the target, or someone else is the target, since you would want to put that missile into the the timeframe of the object it is chasing
I'm using Photon for a 2D turn based multiplayer combat game. I'm running into an issue where if the master and client machines have different screen resolutions the scene objects get created in the position set by the master. Is there a way to make the objects be placed in the same relative position on the master and client machines?
It sounds like you are trying to sync UI elements using photonTransformView or something?
The main thing would be whatever you do doing, is getting your 2d elements into a standardized/normalized space that scaling has no affect on.
Definitely don't be moving them in screen space
If I put them the characters in world space and use photon transform view would that keep them in the same relative locations?
I have the UI elements working correctly as they are using screen space - camera canvas. The characters are created dynamically at run-time using PhotonNetwork.Instantiate.
Photon Problem
The player on the left is the master and the played on the right is the client. If the larger resolution player is the master it's using that as the coordinates on the client and vice versa.
No matter how you sync them, with the view, by hand or with the SNS extension... you are going to need to get them into a space that is screen independent
what are the SNS extensions?
https://docs.google.com/document/d/1ySmkOBsL0qJnIk7iN9lbXPlfmYTGkN7JFgKDBdqj9e8/edit Additional stuff for PUN2 that is in Beta. It has syncvars and syncTransforms in it that are a bit more advanced, but they would still fail you if you aren't working in a space that translates from one resolution to another.
do I need to insantiate the objects via Photon to a wold-space canvas?
You need them to exist in world space, one way or another
I can't speak to Unity basics, I can just tell you that until you are in a space that is screen rez independent, you are going to have trouble.
If you stay in screen space, you will need to normalize all of your values.
almost have it working, have it so it doesn't sync the transform position and sets the position on the client to its correctly scaled spawn point.
Once you get your translations between spaces shorted, it should be pretty easy
I got it working now, just need to fix some other pvp issues now, heh
excellent
@jade glacier thanks for the input, when you say; "you can cheat quite a bit just by shifting the projectiles timeframe into the local players timeframe" do you mean simulating them locally on each client?
Somewhat. Projectiles are deterministicy if you limit not deterministic interactions. Typically you just need the starting position/rot/velocity, and then you just simulate them without syncing their transforms.
It's mostly a question of what timeframe you want to show them in
Assuming you are doing snapshot interpolation. With interpolation and client prediction, every player exists in their own timeframe, that is in the future compared to the unopened entities around them.
Yeah, right now I think I'm modding things so they spawn at nozzle, but interpolate to where they should've been shot from and towards.
So since there will be these kinds of hacks, I'm wondering if I should really "simulate" to create visuals locally, or get them from server by some buffer I told about.
Morning, Iβm new to game developing and have unity 2018. Iβm making a FPS game since Iβm stuck in quarantine. I want to add basic multiplayer whatβs the best what of doing this?
You do not "add" it.... Multiplayer is something you develop the game for since day 0.
Honest advice (you'll hear from others): do NOT start with a multiplayer game. Create something simple, single player first.
I would say make a handful of small proof of concepts, each testing out some mechanic you might eventually want to try in a real game. Complexity compounds so quickly with networking, any large early undertaking is going to be a miserable demoralizing defeat.
@stray scroll If I am trying to push it into the players timeframe, I spawn it at the indicated spawn point, and then simulate the number of ticks or the time delta between the local player and the authority
That will move it closer to the timeframe relative to the player as the authority will see the projectile in relation to that player.
The issue is that if that bullet isn't meant for you, it is now not in the timeframe of other players
So you start getting into the voodoo part of networking in trying to decide how to cheat the timeframes. Like you could split the difference between the local timeframe and the authority timeframe, or you can do some educated guesses about whether that projectile is an actual concern to the player and only advance its timing if its something that player is likely to need to dodge or is likely to get hit by.
The other option of course is to move away from interpolation and into extrapolation, so everyone is in the same timeframe, but then you obviously are now going down the path of a different model and you will need to constantly resimulate.
Alright, thanks for the help
@jade glacier I think I understand what you're talking about, but I'm not sure if how I would work with things like shields, if the shields shield points go below projectile damage it will pass it, and above - not. This shield points value will be synced, if I would sim the projectiles locally I feel like I would need a state from the server and a local state and at some point update the local if the simulation didn't turn out to be correct locally. Because I can't really assume my simulation on client and server will turn out the same if not using something like quantum? π
What I'm going on about here is that if I would simulate the projectiles locally, and only have one state for shield points. If I would get the updated shield points value (reduced) and let projectile pass by it, while on server it didn't it would sim wrong. So it feels like it either shouldn't happen (if destruction of entity was in that package as well as shield poitns), or simulating projectiles for this setup is bad idea n' should not be used.
Hi all, so I am standing in between two tables right now and I could really use some advice. We are planning on developing a general VR Multiplayer platform that we plan to use for multiple VR projects in the future. Therefore we are trying to make a good solid base. But like many of you I can't figure out what network layer to continue with
Right now I struggle between using Photon Quantum or Unity's Connected Games solution. However, I know very little about Unity's connected games and, from what I can read, it seems like there is still a long way to go before it is ready?
What are your opinion on the above mentioned systems? How would you figure out is the "most"-future proof solution?
There servers would definitely be cosmetic only on the non authority versions.
@light harness I'm one of Quantum core devs, so I'll refrain from saying much about Unity's, unless you have questions about our tech.
Unity's Connected Games is a long way out (2021?) and not in any usable state now or soon. If Quantum is a technical fit and in your budget, do that.
hello has anyone connected unity with a node red server ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class MinerSpawn : MonoBehaviour
{
[SerializeField] private Miner Prefab;
[SerializeField] private List<Gold> goldSources = new List<Gold>();
private PhotonView photonView;
public void Summon()
{
GameObject ParentGameObject = GameObject.Find("Player1");
GameObject ParentGameObject1 = GameObject.Find("Player2");
Miner miner = Instantiate(Prefab, new Vector3(-2000, 190, 0), Quaternion.identity);
photonView = GetComponent<PhotonView>();
if (photonView.IsMine)
{
miner.transform.parent = ParentGameObject.transform;
}
else if (!photonView.IsMine)
{
miner.transform.parent = ParentGameObject1.transform;
}
// miner.AddComponent<Miner>;
// Miner m = gameObject.AddComponent(typeof(Miner)) as Miner;
miner.MoveTo(goldSources[0].transform.position);
}
}```
Error:
NullReferenceException: Object reference not set to an instance of an object MinerSpawn.Summon () (at Assets/Scripts/MinerSpawn.cs:17)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class MinerSpawn : MonoBehaviour
{
[SerializeField] private Miner Prefab;
[SerializeField] private List<Gold> goldSources = new List<Gold>();
private PhotonView photonView;
public void Summon()
{
GameObject ParentGameObject = GameObject.Find("Player1");
GameObject ParentGameObject1 = GameObject.Find("Player2");
Miner miner = Instantiate(Prefab, new Vector3(-2000, 190, 0), Quaternion.identity);
miner.transform.parent = ParentGameObject.transform;
// miner.AddComponent<Miner>;
// Miner m = gameObject.AddComponent(typeof(Miner)) as Miner;
miner.MoveTo(goldSources[0].transform.position);
}
}```
There it works
I would like that if I spawn a miner from my point of view, it should be from GameObject "Player1" as a child. And if it is not my view, then the miner should spawn as a child from Player2.
Hello, anyone knows how to use NetworkAnimator in Mirror?
My animations work only on Host
and i can't find any tutorial or smth about NetworkAnimator in Mirror
You will want to get into the Mirror discord for better Mirror help. But the thing they will ask if you are disabling your controller code using if (!ni.hasAuthority) return; and such.
And that your NetworkAnimator is pointing at the correct Animator, since the sync has to be on the root of the object, even though the animator may be on a child.
NetworkAnimator is in Root of player(?)
I just need one line of code to sync everything
This is line from UNET
and i need something like that or smth
I don't know what changes they have made to their animator sync, but typically animator syncs all just work. The main exception being that you do need to use passthrough methods for like Play(), SetTrigger() and other things that can't sync well or at all as states/parameters
If you can't get it sorted with them, I do have an asset https://assetstore.unity.com/packages/tools/network/simple-network-sync-134256 Specifically that deals with all of this. But better to first try and sort it out with their tech, since I don't officially support Mirror.
@round ferry
hello!
I have a question
I want to add multiplayer to my game, but I dont know what FREE soulution should I use for it. I already tested dark rift2 but the problem with it is that it isnt open source, and also It is hard to implement. another solution that I tried was forge networking remastered, but It had some problems with rpc and syncing position, rotation or stuff like that looks like a mess on clients screens
so what other solution can I use for it?
Multiplayer is no easy task, and is not something you add to game alter, but something you start with in mind. If this is your first game try make some single player games first.
But if you want to go down the multiplayer route, you can check mirror or photon.
also, what is ccu, how much players can join a match??
which one is better?
I guess photon, it is used by a lot of games
they are different, you should check them out yourself. Also I doubt Forge Networking has any problems of get go, but the problems you see are problems you've created.
okay!!
the forge problems that I had were mostly about syncing positions and rotations
with interpolation it was too slow, even with interpolation at a higher values
and with out it, it was like stop motion
well @neat salmon you have the following choices:
- send state and interpolate;
- send input and do deterministic predict/rollback;
- a mix between the two (send state + input, run with extrapolation);
You cannot get around the speed of light... With forge (or PUN) you either interpolate or you get stop-motion or you extrapolate...
Not to nitpick, but it'd be speed of sound, no? π
considering most data transmissions are fiber optics and radio, it's light...
ain't no light in that copper we get from Comcast π
But in REALITY, it's more about the Router delays when, well, routing packets...
Lol
Took me a while to get the joke
Sound-speed brain at this late hour
π
Nobody seems to be venturing into network programming with unity anymore...:(
I plan to π
Did anyone try unity built-in multiplayer system/server? I mean, is it okay to use that?
<--- NetCode
@chilly parcel talking about NetCode? It's preview like everything with dots, not production ready.
I don't know what it's called, while back I found out that Unity offers free servers for testing a multiplayer game, at least for small number of players. I kinda more of a meant is that still a think and is it still available for learning. Will I have difficulties when switching from it etc
So what really are the options for a C# server and client for unity
If I dont want to code my own that is
I guess I could wait until unity comes out with there new multiplayer in the year 2030
DarkRift
Probably the easiest to use low level solution there is
And one of the best performant ones
Huh. Ill check it out
It's more of a socket wrapper is it not? One would code quite a bit to go with DarkRift.
It depend son what you want to do
If you just want to play around at a hobby level, do some multiplayer programming... use whatever it doesn't matter.
If you actually want to ship a quality multiplayer game, pick some tech that other people and studios have shipped games on.
Yeah it seems to make a scalable networking solution youd have to do quiiite a bit of coding atm especially if your game is pretty physics based.
Which I figured at the beginning but I havent attempted networking in 3-4 years and figured maybe something had changed
Well @indigo stratus do you want to write a game or a tool? Because as said before, there are existing solutions that are good for production, including for physics-based games
Since 3 4 years a lot have changed... Unity still does not have an in house solution, but external ones evolved by quite a bit
Want to build a game with a max player count of 4 per server
I've looked at mirror and it looks promising but it may not scale well due to it being run in the unity client and not from a console app
Max player count of 4 has no scaling concerns, unless you are planning to spin up lots of game instances on a server or something. Then yeah, you want to avoid your server instances running Unity.
I think he's talking about scaling in terms of servers. Even with 4 players there could be a lot of stuff networked, depending on the implementation
Yeah, if he is spinning up instances - Unity EXEs should be avoided unless he really only knows how to dev using the built in Physics.
That or if his game type is right for it a relay setup like PUN2 to avoid spinning up at all.
4 player games, spinning a unity headless server is the wrong way to go in any situation...
Well, if it's a LAN game fine
Online, it would be a waste of resources
We have a lot of "just for fun" devs in here where a untiy based server is fine, because its never going to scale. But if it has to spin up instances... Unity bad.
Everyone is weighing in with the same answer... not sure the original asker is around to hear it π
Does not matter... The answer is always: see what successful games with Unity use...
Anyone here ever used the SteamWorks.Net to invite a friend to your game? I'm having a bit of trouble.
yeah, I would recommend not really getting lost in any "just for fun" traps with game making.
But hard to convince people a lot of times to not take those shortcuts. Whatcha going to do.
I've looked at mirror and it looks promising but it may not scale well due to it being run in the unity client and not from a console app
@indigo stratus Just going to mention since you've been away from networking in general for a few years...Unity has a "Server Build" option in Build settings that does produce a console app headless server. For 4-player matches, it depends on what all the game actually does, but it may well be possible for a single game server to run multiple isolated concurrent matches. Mirror does support this in a couple ways, but again, it depends on what the game is.
Thank you for all of this discussion. The game would basically be 4 players (all rigid-body physics) interacting with each other.
Just coded the basics and then realized I should probably network before I go too deep into mechanics.
I didnt know unity had a server build option so it seems like that would allow it to be more lightweight.
@gleaming prawn is there no other alternative though? I definitely dont want to implement a physics engine to keep it as its own console app
Rigidbody physics over the internet is going to be the biggest challenge. Quantum is the Cadillac solution there. Below that, having the server do all the physics and just sharing position/rotation updates to clients is probably the next best option. Rewind, prediction, extrapolation, correction...there really isn't a good free solution that does this really well.
I was thinking of doing just thag and having the server share the position/rotations and send that to the clients
What kind of game play do you plan?
Because quantum ticks pretty much what you say you want. Decoupled.from unity, designed for accurate physics
What you are asking for is some.of the most difficult things to build
This is why you would not find something read... And it's not something you can build alone
Unity physics seems to handle it well but I see how desync and things could be issues
A fighting game in 3d with building...
From another channel... this feels like one of those "spot all of the things wrong with this picture" puzzles.
Unity handles in single player
For multiplayer is a totally different story
You want to have the state of the art thing... Maybe you do not have experience with multiplayer u guess
I*
It wouldnt have to be state of the art
:)
Look at brick rigs. Guy built it himself in unreal
Is Unet still available in Unity 2019 and Unity 2020?
no, it's deprecated. Mirror is the closest replacement @rotund burrow
https://assetstore.unity.com/packages/tools/network/mirror-129321
It can be accessed as a package still, but that is just really there to support legacy projects that use it. It also stripped out the NetworkTransform and Animator and who knows what else.
If our intent it to stick with Unet, Mirror and MLAPI are going to be preferred avenues.
its deprecated in 2018 as well, but you can still use it, im curious because of a project that has already been completed in 2018 but used UNet, I'm curious if that project could be moved to 2019 or 2020 and still be able to function its Unet code
I know there are numerous other challenges involved
Its a package that I think will auto add itself if your project already had it and you move to 2020
just make a copy and try
Hi, i'm having so much troubles with networking in unity, i want to make a "win screen" appear but i can't ...
Hi, does anyone have any experience of implemeting Amazon web services into unity?
@gaunt smelt sure, what are you looking to do
Anyone here used SteamWorks to invite a steam friend to a PUN2 room and start a match ? I'm currently using FacePunch's sdk implementation .
Hello guys, does anyone know how to do a multiplayer messaging system ? like sending mails between players ? Thanks (I use Photon / Pun)
I would create a network event that has the messege and receiver ID in it's data and raise it. Then on receiving the event check if my id matches the receiver ID in the event and process the message .
or do want messages to stored even if users are offline cause I dont think PUN can do that
i can do that with playfab, thanks
Hi, is anyone using mirror networking here?
I'm very new to it, I got the room project example working on the network in p2p. Now I want to be able for any player to join at any time while the server is running. By default in this example scene players have to hit 'Ready' and then you have to manually 'Start Game' in the host application. I don't want that I want anyone to join at anytime and spawn. Can someone point me to some ressources to learn how to do that?
@weak plinth You'll want to add a bunch of debug.log calls at the various points. And put a debug into an OnTransferOwnership calback (or whatever the correct name is for that callback) to see that it actually fired.
@wary elk , join mirror discord, they have a help channel guys will help u
Anyone here used SteamWorks to invite a steam friend to a PUN2 room and start a match ? I'm currently using FacePunch's sdk implementation . Re-asking my question hah.
Hello, I've recently picked up Unity for school and have also recently started using Photon to do multiplayer, but I've come across this issue:
At seemingly random points throughout development, I'll start to get this error message (even though I haven't changed anything relating to my networking code) and the only way I've found to fix it is to go back to a previous commit. I've tried searching on the internet but most problems were from people whose client wasn't connected to Master Server in the first place...
has anyone had this problem and might know how to fix it ?
Is there a large, comprehensive tutorial on getting introduced to making online games?
I saw a brackeys fps tutorial but it's quite old and I'm sure a large portion of it is no longer relevant
I'd like to be able to get knowledgeable about making online games but I'm sure it's a big beast to take on and I'm hesitant about it
@gilded pollen no there isn't really
lmao. damn. brutal.
so i imagine its a pretty lengthy journey to figure out good networking practices, etc
yeah it's a long journey usually
Specific networking API's usually have their own tutorials with example projects. It's a good way to start.
Huge diffeence between learning a networking API, like UNET or Mirror or Photon, and knowing how to network a game from scratch
could most games accomplish what they want to simply via unet / mirror / photon
and making one from scratch is more for advanced cases?
basically im wondering why someone would want to make their own when there is options
unless the options are all like... shallow
i guess is the word
completely depends on your ambition and game scope
okay, thanks. ill do some googling into them, and their pros/cons, etc
overall im just wanting to make an fps with mp
whcih im sure those will be able to do
which*
@gilded pollen I would recommend checking out Mirror, Photon, playfab. They are very high level solutions
thanks
@gilded pollen I came here because I'm in the exact same boat trying to make networked fps but I think the tutorials I found were old they were from early 2018
im just reading about general networking overview articles right now, because after doing some reading, it definitely seems like some prerequisite knowledge i need to know
I've done networking before with javascript sockets but I'm new to unity trying to make it multiplayer
and then, idk, im just gonna go with either photon or mirror for my little current small use-case for now. and hopefully in the future, unity's new "connected games" is finished and i can transition to that
ah
If I'm going to be finishing this project in the next few months can I just use a LTS version of unity and use the deprecated UNET multiplayer to make it work?
Only trying to do basic P2P stuff
π€
also im just curious what state unity's new networking thing that they're working on is at. Is it out? Announced? Alpha? its kind of hard to find concrete info on it
I'm reading the blog posts about the switch and it seems like I can just use the old systems which should work for a year or two more
yeah but im just curious if the new stuff is out yet, or is soon, or what
ahh, do you have a link to that page?
so i guess a chunk of it is already out
This too
Actually I'll try to use mirror this series looks helpful https://www.youtube.com/playlist?list=PLS6sInD7ThM1aUDj8lZrF4b4lpvejB2uB
Any one tutorial that does it all correctly, we be so long and unfinishable it would hurt anyway.
And there would have to be like 5 of them for the wildly different architectures
Mirror and Mirror tutorials will get you familiar with the concepts of dealing with a messaging layer and the concepts of networked objects. It won't get you the high level AAA concepts involved in syncing input/states and simulations though. No single path will get you it all i one shot.
You have to learn a part, and that will reveal why you really need to learn a couple other more complex concepts... which will reveal the need for even more complex concepts....
So I would just start with a basic tutorial... and see where it leads you.
I have a low level networking system thats built upon unity transport UDP library
thats what I use personally
whys it gotta show my face everytime
Ima change it to something more anonymous lmao
Usage example ``` /// <summary>
/// Packet received
/// </summary>
/// <param name="c">The network connection</param>
/// <param name="packetId">The packet ID</param>
/// <param name="packetBytes">The bytes to process</param>
private void OnPacketReceived(NetworkConnection c, int packetId, byte[] packetBytes)
{
if (packetId == 2)
{
//Read packet
LoginResponse_2 packet = new LoginResponse_2();
packet.readPacket(packetBytes);
LoginResponse(packet.accept, packet.errorResponse);
}
}```
are you mr dinnertime?
Me? No im new here
So in conclusion, is it best to use Mirror/Photon for networking at the moment?
I just wanted to work out a simple solution for just 2 player multiplayer for a driving game
For first games PUN2 has the advantage of you not having to work out hosting. The disadvantage being that that is made possible by it using a relay server - so your are going to be writing it with full client authority - which isn't always the ideal answer.
However, if you are just learning, that in itself is a good lesson. You kind of have to see the issues latency creates for authority and prediction in order to even start thinking about them.
If your design requires server authority and hosting is not a concern, something like Mirror will do.
If you want to make it legit and are doing this for an actual release and you need server authority, you should look into Bolt and see if it fits your game type.
Hi guys, I'm learning PUN2, and I'm having a hard time getting a grasp on how to determine which player is which. Like if I am creating a 2v2 game, and I have the four players in the room, how do I sort them to be Player1, Player2, etc. which then has access to whatever they should have access to?
If that makes sense. I understand that on load the player instantiates an object to represent himself, but as for how to actually assign which player # he is in the game scene, I haven't figured that out.
here is a common question, I've been trying to figure out what is the best networking approach for an fps shooter. I am very much confused. Should I use PUN2? should I use Mirror? if UNet is deprecated and Connected Games is not out yet, what should I do?
I use MagicOnion for everything
hmm
does it work well? fit for a shooter with req of less than 80 ms?
not really sure, I haven't built a shooter yet
I've mostlybeen building turn-based games
ty
@tired raptor consider photon Bolt, it's built for that type of game.
@gleaming prawn looks good, ty
Is annyone know how to call cloudscript when a playstram event is called ? (Playfab)
nvm i dound it
found*
@tired raptor consider photon Bolt, it's built for that type of game.
@gleaming prawn
Thinking it over,I think I want a dedicated server so I have to go with PUN2, unless this is also achievable with Bolt?
PUN2 would be the opposite of a dedicated server though.
PUN2 is all based around using a relay instead of a game server.
If you want dedicated server, go with bolt
Keep in mind Bolt Free does not allow you to run your own custom dedicated server with direct IP connection, that's a Bolt Pro feature, which they claim requires directly contacting them and is part of their Enterprise offering
They don't advertise this fact on the feature splash page, and it's not super clear under the pricing splash page, but if you drill down into the docs you get this:
Yes the connection is facilitated through Photon Cloud, however the connection to your servers are not relayed. It is pretty easy to get up and running, you deploy on PlayFab Servers 2.0 within the space of an hour following our doc here https://doc.photonengine.com/en-us/bolt/current/demos-and-tutorials/playfab-integration/overview
Fair enough. Would be nice to see a bit clearer breakdown on the photon site, with various SDK integrations in mind
how do i delete a bolt state/other thing?
cant find a button for that
and i created that state by accident
i dont want it anymore
client-side prediction with PUN2: pain in the ass?
Not really
Local player movement is already local...
Maybe you should take a look at @jade glacier 's SNS extensions to PUn2
I think he handles this
@gleaming prawn on the asset store?
I'm trying to set it up so that the master client keeps the authoritative game state and all commands are sent to the master client and the current game state is sent back
if there are any packages that can streamline this that would be amazing
if you are going that route, using master client as server
You should just use Photon Bolt instead
It's designed as clients vs authoritative server
with server being a unity instance of the game (wither listen server or dedicated server)
And works both over photon rooms (bolt free in relay mode) or direct connections (punch-through with bolt free, direct IP connections with bolt pro)
Bolt's API will be what you need
I'm worried that will be even more complicated than using PUN. I'm pretty new to all of this
Designing this over PUN2 is just reinventing Bolt
Well... PUN is easy
But you want server authority, which pun is NOT designed for
So it is complicated
Hasn't been easy for me so far π
Well
If you've never done multiplayer games before, do NOT try to do something complex
Start with something much much simpler
If have never done a GAME before... Do not even try multiplayer
Yes but I still want to be on the right path. I'll start simple. Photon Bolt is better for authoritative state?
Right path: start with a simple game
You will throw it away anyway
Do not think what you will write today will be useful for a complex game in 6 months, it will NOT
Start with a simple game, try to FINISH it
And "release" it even if just for friends and family
Then start over after you learned a few things
That's my only advice
Alright thanks
We have a Photon Bolt Discord if you're interested
@fading pawn invite
What happens If Bolt sounds better for my project, but I would also like a dedicated server in a month or two?
Will I need to add PUN2 as well and rewrite everything?
support both? I feel that it could be clearer ...
Like people have said, PUN2 is peer to peer over relay, so hacking a dedicated server in there is a bit backwards way to go about this.
Hosting PUN or Bolt on your own server infrastructure requires you to make it rain on Exit Games afaik, so I would just pick the one that makes the most sense in the first place.
They are totally unrelated libraries. Bolt and Pun2 aren't mix and match. I would do tutorials for both and get comfortable with understanding what they are before even trying to decide these things.
Bolt can be hosted in your own infra, no need to "make it rain" on us @spring crane
That's what bolt is designed for... You do not host photon servers, you host your bolt servers
Yea meant completely off Exit Games servers, so direct connection
You can..
Bolt PRO
Designed for that
That's not really "make rain"....:) It's our product, you can license it and have just like that
Only available directly through us to select customers. Access to SDK via subscription.
Wording makes it sound like "make it rain" situation π
Well I don't doubt that considering the studios that work with Exit Games π
I don't get the fear of Exit's pricing. The quantity of active titles using all of the libraries should be some kind of an indicator that the models aren't abusive.
I don't touch that side of things so I can't speak to pricing, but a LOT of small developers seem to be happily operating using Photon.
Probably partly because people don't know the actual cost and time required for these sort of things
Bolt can be hosted in your own infra, no need to "make it rain" on us @spring crane
@gleaming prawn
From my understanding, Bolt aims for a player to host a server, this means that if he goes out, the server is closed.
Still didn't understand if this means I can use that as a Dedicated server and just ignore that player that is hosting it?
Will I be able to achieve Dedicated & Player to player connection with Bolt?
What I am trying to achieve is kind of like Half Life, you can create a dedicated server and you can also host your own game.
@tired raptor bolt can be ran both as a dedicated server or one of the players hosting it
I'm the guy that wrote bolt originally, so I'm pretty sure I'm correct π
lol
And in either case (player hosted, or dedicated host), even bolt free would use direct connections whenever possible (via STUN punch through)
Awesome! so there are some people who explain this the wrong way and they are very misleading.
They say that PUN2 is used for dedicated server and Bolt for Player to player connection
PUN/PUN2 = relay based, with a central server that facilitaties connections and data between players. But no logic on the server by default - and no unity process running on server
Did you see that in our website, or from any of us?
Bolt = uses the same relay as PUN/PUN2 to perform punch-through and form a direct UDP connection between the server and it's clients.
I'm not aware of anybody who says PUN2 has anything to do with dedicated servers...:)
Did you see that in our website, or from any of us?
@gleaming prawn I will check it right now and verify
Well I guess it was my bad that I've concluded it:
https://doc.photonengine.com/en-us/pun/v2/reference/pun-vs-bolt
That said, this title is confusing:
Host Client (Bolt) Vs. Dedicated Server (PUN)
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!
Should have notices that:
"In Bolt however, one of the Bolt clients needs to act as a server, a true dedicated server or real host"
Bolt is the right one:
But the wording is wrong on that section headline
I'll poke the guys here
Cool tnx, I will make sure that next time I will read the entire paragraph and not just the title lol
It's not wrong, it's just a bit misleading
Agreed
The server is there (the relay server), and it is dedicated to that, all clients connect to it directly, etc
It's NOT a simulation server with authority (which is a completely different thing)
The thing is that in that particular case, PUN has a slight "advantage":
- because the relay server is always dedicated, if the PUN master client disconnects, the game can still continue for others (as long as you did not try to write the master client as an authority "host"). Master client role will be passed to one of the still connected clients, etc...
- Bolt does NOT offer host migration... If the Unity client that acts as the Bolt HOST disconnects, game is over (unless you implement host migration yourself, which is not easy)
I should also mention that Quantum doesn't suffer from this at all. Game keeps running normally for connected players, no matter who disconnected or got back in, etc
Yeah but what I understand is that you are able to achieve kind of the same behaviour (in a different way) with Bolt so that if the host leaves the server shuts down.
Also I am not familiar with Quantum
If the bolt host leaves, game is GONE
Bolt is client-server (in which the server is a unity instance)
pretty much like Unreal, CS, or Unity's ne netcode or Mirror (I think)
by gone, I mean:
- all game clients will notice their game host/server (not photon server) times out, so they "quit"
Yeah
"Master client role will be passed to one of the still connected clients"
Quantum because no unity instance is a "host"
Bolt is based on CS:GO - so if you know how hosting locally and with dedicated servers works with that.. you know how Bolt works.
For PUN because it is client authoritative, and most of the time the sim can "survive" recorver from a master-client disconnect, unless you do something very specific
Yeah, for PUN authority is just a virtual baton that gets passed around
All clients should have the same info, the Master is just the one that is flagged as being the current final word if you need that behavior.
Though your code isn't required to respect that its literally just a flag on a client that says "I'm the leader", and that flag can easily get passed to any other client.
The common mistake in understanding is that that is NOT a server. The relay is the server.
'host' in Bolt is just the 'server' which happens to have an bolt entity it can control locally also like a player
so if server dies = game dies
If you try to treat the master as if its the server for authority and such, you are looking at a LOT of latency.
Bolt uses the same naming convention as Unet. Server, Host and Client right?
uhm
good question
i think it just has isServer and isClient
FWIW bolt is not 'based on' CS:GO, it use the same topology as CS:GO, but bolt is an eventual consistency framework, where CS:GO is a delta snapshots setu p
IsHost basically is (isServer & isClient) for unet
just to be clear
Yeah, for PUN authority is just a virtual baton that gets passed around
Only if you implement authority in a master client..:)
By default there's no singular point of authority
Ah, didn't know you used a different consistency model. Good to know.
Makes sense, since CS:GO has no need to scale beyond what it is.
I mentioned CS/Unreal just for the sake of hosted authority, with some form of state transfer
yes
What I understand is also that as opposed to Bolt, PUN can go docker?
new word for me too
do you mean docker as in the orchestration?
But @tired raptor Bolt has the whole kitchen sink of delta compression (one form of it), lag compensated raycasts, client predicted commands, scoping/interest management
Live in a container
All built in
Unity host can live in a container also afaik?
Bolt host can be osted on docker AFAIK...
But @tired raptor Bolt has the whole kitchen sink of delta compression (one form of it), lag compensated raycasts, client predicted commands, scoping/interest management
@gleaming prawn Yes that's one of the reasons I've shifted to that
We do not enforce anything... Even with bolt free...
I don't think you can run unity on Docker
Β―_(γ)_/Β―
You can NOT docker-ize Photon Server, which is something else completely
When I describe Bolt, I usually just say its the only complete stack available for Server Authority using snapshot interp and client prediction.
i dont deal with devops
I don't think you can run unity on Docker
That would be a Unity limitation then... Not specific to Bolt
Agreed
@jade glacier bolt is not snapshot interpolation AFAIK
Isn't it?
yeah, sad state of terminology when three devs for the same company have to sort out terms
I know it does not do full frame snapshots, etc
It uses eventual consistency, etc
snapshot interpolation = the act of interpolating between two known values, say Tick=100 and Tick=102.
delta snapshots = a way of transferring data to the client
eventual consistency = another way of transfering data to the client (which bolt uses)
lol
I guess there is much I don't know about the struggles of Gaming Networking, but as opposed to Bolt, Pun, Quantum what will happen if I'll create a udp server myself, dockerize it, and just store a json that describes each player position and other state properties ?
both DS and EC can be used with snapshot interpolation or state transfer (extrapolation)
got it
I would assume if the dev wants to get crafty they can extrapolate with Bolt, but not aware of any of the lib doing that for you.
If its a short explanation, if its a long one just let me know and I'll go a research
the fact is that you do not extrapolate locally (you interpolate) on bolt, except for the local player... Is that correct then?
yes, bolt uses snapshot interpolation
But it does transport inputs and it creates rewindable components and such
And when we mention state transfer, this normally is also associated with extrapolation?
But it does transport inputs and it creates rewindable components and such
Bolt? AFAIK no
So the seeds are there for input extrapolation and resim, if someone wanted to get nutty
Only on server
Not sure how far reaching his built in physics/controllers are
Not on clients... The clients apply the commands for local player immediately, reconciliate server authoritative snapshots
So only fholm can answer that
On server it does rewind for Raycasts only... AFAIK
And commands are integrated on server (and confirmed down to clients as conciliation updates)
raycasts and sphere overlaps
I believe the ability to have that code anywhere is possible, but can't say for sure. I don't know what is in a black box and what is not
Does it have the seeds of input extapolation and resim?
I stand corrected then
Without the ability to do that, extrapolation with it would be all transform/velocity based and such... would be a mess.
So yeah, its firmly a Snapshot Interp engine
yep
What is the current state of those libraries that aimed to "beat Bolt"?
Any got released?
π©
2014
Maybe at 10th anyversary
lol
There have been a couple hobbyists "me too" attempts we have seen.
Hello all
got a question for you all
I have a CMS system that has question those questions are assigned a video and 2DTexture. everything works good now if it pulled from the internet. What i want to do is to serialize the data to a file if there is no internet those get reloaded. Should i / can i serialize all the data the strings for the questions images for the textures and video for the video?
is MP easy to add in or do you need to rebuild the game to add it?
A networking expert can probably implement multiplayer within a few weeks if the single player implementation isn't too problematic to convert
Depends on game complexity and what you expect from networking. But yea, a few weeks for a rough proof of concept should be enough.
Not gonna happen for deterministic solution though.
@hasty fiber sure, you can grab all the data from a CMS and turn it into static content, which is what you really want to do. there are many ways to do this
for example, the static web framework Gatsby.js can transform a wordpress site, in a fixed point of time, into static content queryable with graphql
you can of course save the files and create an ad-hoc copy of a website
@tired raptor i've found that it's very challenging to migrate game state data, like player positions, and that's why in practice i don't think anyone goes that far with persisting game state into a database or file or wahtever
when there's a big WoW update, there's downtime, they save your inventory and such, but they restart the instances
it's not like they freeze exactly you in your battle, then restore it later
instances == literal C++ processes with memory that have all the game logic
"but something something scalable" usually the piece that is missing is a load balancer, which connects people to the same in-memory game state, across many computers all running games