#archived-networking
1 messages · Page 84 of 1
not yet
How are you trying to learn then?
Can't really help you much until you get through it and understand the basics. Otherwise you are just asking people here to walk you through it.
ok so i have this problem i want it so it will show an arrow above the local players gameobject and this is my script and i dont get why it doesnt work: ```public class Instantiate : MonoBehaviour
{
public GameObject arrow;
private void Awake()
{
if (PhotonNetwork.LocalPlayer.IsLocal)
{
arrow.SetActive(true);
}
if (PhotonNetwork.LocalPlayer.IsLocal)
{
arrow.SetActive(false);
}
PhotonNetwork.Instantiate("PLayer1", new Vector2(Random.Range(-12.84f, 13.2f), 4.9f), Quaternion.identity);
}
}```
LocalPlayer.IsLocal will always be true by definition no?
Just hide an arrow graphic based on IsMine
o
w
so
something like this? using System.Collections;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class Instantiate : MonoBehaviourPunCallbacks
{
public GameObject arrow;
private void Awake()
{
if (photonView.IsMine)
{
arrow.SetActive(true);
}
else
{
arrow.SetActive(false);
}
PhotonNetwork.Instantiate("PLayer1", new Vector2(Random.Range(-12.84f, 13.2f), 4.9f), Quaternion.identity);
}
}```
cuz that gives me this error NullReferenceException: Object reference not set to an instance of an object Instantiate.Awake () (at Assets/Photon/PhotonUnityNetworking/Resources/Instantiate.cs:13)
k
nope doesnt fix it
o
i might have fixed it
nvm
now it doesnt work anymore
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class Instantiate : MonoBehaviourPunCallbacks
{
public GameObject arrow;
private PhotonView photonView;
public GameObject Player;
private void Start()
{
}
private void Awake()
{
photonView = Player.GetComponent<PhotonView>();
if (photonView.IsMine)
{
arrow.SetActive(true);
}
else
{
arrow.SetActive(false);
}
PhotonNetwork.Instantiate("PLayer1", new Vector2(Random.Range(-12.84f, 13.2f), 4.9f), Quaternion.identity);
}
}```
Use OnJoinedRoom
is photon a suitable environment for persistent player shops? Thinking of using playfab to hold players inventories and currency, then transfer between the two but the only google search relevant comes up with an old post from 2014 saying photon being peer-to-peer is not suitable for this, I'm assuming they didn't take playfab into account and were referring to a photon-only solution.
tldr photon + playfab = persistent player-to-player shops ie auctions so on?
I'm sure it's possible just making sure photon being peer to peer won't be an issue in this quest
Photon products are for the realtime aspects of gaming. Persistent stuff you would use something like Playfab.
We are trying to help our friend with this small indie game. He has a single camera 4 person game. Currently local co-op. He wants to add networked multiplayer. He suggested we look into Photon. I have successfully converted his code so we can render and move around networked players. We are struggling to figure out how we can have local co-op players mixed in with networked players. eg: 2 local players + invite a steam friend who has their own 2 local players. Is this even possible? Seems like we'd need to keep track of locally joined players and manage the logic of if the room is "full" on our own? Does anyone know of a server solution that would handle this use case better?
Is this even possible?
Yes, but you need to code it yourself, assuming that by "photon" you mean PUN (photon unity networking, one of the products in the photon family).
Does anyone know of a server solution that would handle this use case better?
Yes, photon quantum has this as a basic feature (multiple local players)
i wanna make a simple lobby using photon pun in unity and , in which player can join by entering room id or can create it ,i am ready with basic ui interface ,please anyone help me
and i also installed photon pun into my project
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!
lol channel might as well be renamed to photon channel
thanks @prime beacon
Has anyone tried nakama? https://github.com/heroiclabs/nakama
Hello! Is there a good resource to make a server inside unity that is fast? I tried TCPSockets but it's very slow for player movement. The player movement jitters
Use UDP
Also if it's jittering, you should interpolate between positions
Should TCPSockets be jittering in a local network?
no
I'm doing something bad then 😅
are you interpolating between positions?
No interpolation at the moment
that's ya problem. All games ever do that. Doesn't matter UDP vs TCP
True but TCP is a bad choice for realtime movement
If it's always going to be local then no harm no foul. But yeah agreed.
hey guys i want to sync skins between players
any approach
for syncing of weapons and teams i use enums
like, UV maps?
Are you modifying it like, every frarme or something?
nope,
i am just asking how to sync stuff like that which is in large amount not in limited like teams, squads or weapons
Just trying to understand your situation, and why you can't just do what you've been doing with something like weapons and enum solution
oh. So you're already using an enum for skins?
noPe i am not goin to
i just wanted to know is there any other approach to sync stuff like skins which is in large amount
Enums.. IDs... etc
if you let them conflict sure. There's plenty of ways to prevent that. Or the internet as we know it would not exist.
@silver steeple so whats the process of it
IDs should not conflixt
if it's your game and you decided for the game assets database I mean
@fair cosmos depends on your situation. It's hard to understand the context and why you're having trouble with anything. Would recomend looking into how to prevent IDs from conflicting in whatever situation you're in.
In all game clients the same skins would have the same IDs/Indexes respectively, etc
It's your game data, etc
Say you store your skins as an Array in a scriptable object or any other mean... Then just pass the index of the chosen skin, etc
There's no excuse for why they would conflict tho. Things like youtube, a massively distributed asyncrounous realtime system dealing with billions of requests still maintain unique video IDs
That's it
If you are using a player profile database like Playfab, the unique IDs for each individual item/skin would be generated there, etc
So there's no conflict
@gleaming prawn thnx
On Photon when I pass a variable via RPC, does it use the local avatars version of that variable or does it pass the one from the networked player
If that makes any sense
GameObject go = GameObject.FindGameObjectsWithTag("Player").ToList().Find(g => g.GetPhotonView().owner.ID == switcher.ID);
PlayerGameplay pg = go.GetComponent<PlayerGameplay>();
else if (Weapons[weapon].IsSecondary)
{
if (pg.m_Camera.enabled)
{
pg.Weapons[SelectedWeaponIndex].gameObject.SetActive(false);
pg.Weapons[weapon].gameObject.SetActive(true);
pg.Weapons[weapon].gameObject.GetComponent<OnAnimationWeapon>().PlayerGameplay = this;
pg.FPSAnimator = Weapons[weapon].gameObject.GetComponent<Animator>();
}
pg.isReloading = false;
pg.SoldierAnimator.runtimeAnimatorController = SoldierAnimatorSelection[1];
pg.WeaponHolder[SelectedWeaponIndex].SetActive(false);
pg.WeaponHolder[weapon].SetActive(true);
}```
this is a part of code i use for letting the players switch weapons through the network, it's sent with a photon rpc, but i cant get it to work and i have no idea why
i basically copied my script from the not networked weapon switch and i call the networked weapon switch from the not networked weapon switch
The values you pass to Invoke arrives on other clients as the argument values for that RPC.
Ah ok cheers
please can anybody here help me with how to make lobby ,rooms and play together using photon and yeah i have read the documentation of photon and i didn't understand much also i don't want to just copy paste either ,i wanna understand ,so please somebody help me who have experience with photon ,you can dm me ,thanks
Being straight:
- if you come up with a few directly technical questions, people may answer
- if you want someone to go step by step and teach+write the code for you, this means hiring/paying someone for their time spent (possible, but not sure this is what you meant).
- you can always go for youtube and blog tutorials: http://letmegooglethat.com/?q=pun2+tutorial
I am using PUN2 . Is there anyone who can help me make the character move smoothly
Hey can anyone let me know if this is wrong
Is it possible for the local player to send variables like this via RPC's?
what is ScriptablePose?
Is it a Scriptable Object?
If yes, NO, not possible like that
You should send something like:
- the string name of the scriptable object, so it can be loaded from the receiving RPC (slower)
- an int pointing to the array index of that scriptable object in an array you define in a ListOfPoses main scriptable object that ALL game clients have (cleaner and faster)
It's NEVER possible (or sometimes not advisable) to send these as part of RPC params:
- game object (not possible, send a way to find the same object)
- scriptable object (same as above)
- textures, audio, assets in general (too much data, does not make sense - do as above and send an index/name)
Whatever scriptablepose is, you will need to define your own serialization and deserialization handling for it. You can't pass arbitrary objects to photon for serialization. Only supported types automatically serialize.
That you for detailed responses guys. I ended up taking the string and send that in the RPC then using Resources.Load on the networked avatar
@gleaming prawn I don't want to have to store all different poses at runtime, on an in-scene object but I agree that way if they were in the scene would be much better
@jade glacier Thanks for breaking that down for me. I've only been using Photon for week so still getting the jist of how everything works. Doing it for VR as well poses quite a few extra challenges
Would either of you have any advice on how to handle the disconnect between held objects and hands on networked players. Both have different PhotonViews so I can set the streams in a way to pass all the data in synce.
Edit: I've just realised that while you can't modify observed comps, you can disable and enable them which opens up a lot of possibilties
i can't understand why is this saying that object reference is not set to an instance of an object
Debug.Log(photonView.Owner.ActorNumber);
got it
i have this simple script to show deaths of a player PlayerScoreboards[i].transform.GetChild(1).GetComponent<Text>().text = "Deaths: " + playerScoreDeaths[PhotonNetwork.PlayerList[i].ActorNumber - 1];
but if second player joins
i get this IndexOutOfRangeException: Index was outside the bounds of the array.
public int[] playerScoreDeaths = new int[6];
it seems that it gives an error when array is more then 0
localPlayer.transform.GetChild(1).GetComponent<PhotonView>().Owner.ActorNumber this gives the same error
playerScore[localPlayer.transform.GetChild(1).GetComponent<PhotonView>().Owner.ActorNumber] = 0;
even this
anyone?
maybe you should join Photon's DIscord
this doesn't seem to be a thing
is there a way to not use .ActorNumber but still get player id.
because that thing seems to be breaking everything
ok i did a little bit more tweaking and...
playerScore[playerId] = 0;```
only second line gets an error
this one playerScore[playerId] = 0;
Is PlayerScore a dictionary or an array?
This looks like a C# understanding problem at a glance, not actually a networking issue.
mirror only updates movment unitl other player joins the server then it leaves the player standnig even if i move on the other client ill be still
Likely you aren't disabling your controller code if hasauthority == false. I would try explaining your problem in the mirror discord. @sterile ore
i fixed it like 10 minutes before you wrote it emotitron
does anyone know of a good networking library for unity 2020.1? mirror networking doesn't work for me and has errors upon building, photon is expensive to use, and UNET is decprecated and i cant even find it anymore in the actual code
telepathy is not resolved in mirror networking so i cant use that :/
Mirror should work.
And Pun2 only costs money if your game is successful.
Unet and Mirror both will require hosting or nat punch, but do have a Unity exe for a server. Unet is deprecated, but it would give you about the same set of difficulties as Mirror/MLAPI.
Your requirements for networking seem a bit steep?
Just hit the Mirror discord for help resolving that transport issue.
i just want a working library that doesnt cost because i want to host it myself
does mirror work in 2020.1?
it says it requires 2018 on their docs so maybe thats the problem?
alright well i might have to join yet another discord server just for this :/
No idea, hit up their discord and see
If you are losing patience with networking just picking a library, I have to warn you that the actual development experience is likely not going to be your bag.
Networking games is the most difficult part of game dev.
Expect lots of frustration and failure along the way.
@white wedge https://github.com/nxrighthere/ENet-CSharp
And what emotitron says is true, it's a lot of frustration or maybe you don't experience it like that, it's nonetheless a lot of work
There is no silver bullet solution however so you need to pick something and get some experience along the way
@white wedge mlapi works in 2020.1
hm so,
DefaultPool failed to load "APrefabInResources". Make sure it's in a "Resources" folder. Or use a custom IPunPrefabPool.
this is using a well known kit, which works all until I close out of unity for the night and restart, then it throws the above.
"ask the dev for help" he's pretty inactive, and I'd like to solve this myself if possible
(photon)
oddly enough it was to do with my scene, which makes sense if it's running at a certain- I don't even know. Whatever it works now lol.
"APrefabInResources" looks an awful lot like a placeholder
like "InsertNameOfYourPrefabHere"
Does anyone know if services like Multiplay or AWS Gamelift provide their own networking library, or are they purely hosting platforms, and a library like MLAPI or Mirror is still needed?
@jade glacier lol yes, but unless me renaming it for the sake of clarify effects it
to be clear it is assigned and it is an actual prefab,
original name was "AISoldier" if that helps
which it doesn't, so anyway.. that's my life
@nocturne current From what I understand no they will not providing a network library for your game they are just hosting what you've already made
I'm not sure if that's the case for lumberyard with what I can only assume would be a tight integration but for unity it's not the case
MLAPI is a great choice, though mirror has a far larger community / examples so on
Alright thanks! That is was I was assuming and hoping for so that there is more flexibility when it comes time to actually work on hosting.
I've been stuck between MLAPI and Mirror, so I haven't made a decision yet. Are you aware of any "success stories" for games using MLAPI?
good comparison here;
https://mlapi.network/features/
also found this, which uses mlapi as well as the steam transport
https://www.youtube.com/watch?v=2Mz-j7CLhac
@nocturne current
"success" is relative but I would say mirror definitely has the lead in that
from looking at Mirror and MLAPI the advantage for the latter seems to be its code seems very concise, clean and performant. It also has some advanced features, in the client prediction department.
MLAPI looks like it will be a bit more work to get started, but for more advanced projects will likely save time I suspect.
If you know what you're doing definitely go with MLAPI, just starting out I'd stick with mirror
some pretty decent names in mirrors book, using it myself currently so I'm a bit biased lol. Though MLAPI was my first choice, community support stood out
for my project I am trying to decide if I should just go with the new netcode, since I am starting with 2020.2 or if I should use MLAPI.
Awesome! I'll take a look at comparisons and go from there. I'm starting to lean more towards MLAPI.
Good luck to ya!
@sacred grail I'm waiting a bit to see it fleshed out myself I think I saw some of it recently looks pretty cool
ya I am leaning to using the new netcode, simply because my project wont be done for a couple years lol
fair enough
and I want to be able to support a couple hundred players ideally (Rust supports 300 players).
DarkStar, I spent a month or so dealing with the current state of DOTS, and I must say I did not a have a great experience with it. The technology is there, and it is highly capable, but there are countless bugs and quirks associated with it.
https://gyazo.com/614cf686e7b1201aeac7331b5e1e611a
I believe this is the same, 100k entities 50fps or something just wild
If you have the time and are willing to go through many code changes as DOTS comes out of preview, I would say go for it.
Danmw3 ya same. But since my project time horizon is a couple years and I don't need dots for the majority of the game play, just the more complex work and I want to use havok physics it makes sense for me.
My final straw was when something panicked, threw a invalid memory address exception, and managed to crash several other programs including my GPU drivers.
At that point I just didn't even want to know what other issues there might be.
understood, I suspect dots will be pretty stable in 6-9 months. the recent changes have made the code quite a bit easier to use and I suspect that will continue.
I sure hope so with Unity's change of pace and focusing more on ironing out all of the "half-baked" features.
I want to push some boundaries with my project so I kinda need some of the newer stuff. i.e. latest HDRP + Havok gives me 50,000 meter maps without floating point issues.
how would i select a random player in the server?
@weak plinth give each player their own number or put them in array then choose one
how to make so that rach client has an invididual camera
give each player their own number or put them in array then choose one
How? When I use an array currently it’s different for all clients
And how would I match the correct number with the corresponding gamepbject
Nah pun
@weak plinth unless you get into making server plugins, you would probably want to have the Master Client do what you are describing. It can "act" like the server as needed.
Have the master select a random actorID and RPC that to all others.
ActorID?
Anybody knows why this is happening?
Does Photon send RPC to only 1 room or all rooms?
Players can only be in one room
What do you mean
thats the thing i wanna learn ,exactly same
I don't believe you can RPC outside of a room. If you are connected to the master server, that isn't something you can do.
i wanna learn it too , how can i learn this ? pls help me guys
so is it impossible?
You aren't in a room, so there are no other players
Matchmaking and being in a Game Room are very different.
please somebody help me with photon ,please i am really struggling from a week
i got what do you mean, but so what should i do? Do you know anything that can help me?
Have you completed the Getting Started tutorial? @fallen frigate
yeah i installed photon into my project ,already made an account in photon .com and know how to connect with master server
Until you get through the basics, there isn't much anyone will be able to help you with.
i have read that whole article
and kinda have idea how multiplayer works
rooms or lobby etc
but i don't understand how to use it in my unity project
Is there a way to RPC to another room?
I am not sure what to tell you. The point of the tutorial is to walk you through how to get a working networked project happening. @fallen frigate Be sure to DO the tutorial, not just skim it.
@grand skiff no
😦
ok but i don't want to make my player randomly join room
how can i get list of rooms in PHOTON?
If you have a specific question, you can of course ask it @fallen frigate
3 days ago i followed some tutorial from youtube and i made my player radomy join or create a room from that ,in which i attached my launcher script with ui scene and after entering name of player it instantiate it in room after clicking join button
but i want something like among us ,in which we can create a room give a code to friends and they can join it so we can play together
by creating a scene ?
I mean you need to know a little bit about how PUN works
yeah
thats why i wanna learn
not just wanna download some projects from github and use them
I haven't played among us so no idea how their code works, but I did something similar where you'd go to a URL and it would connect you to a photon room
yeah yeah something like that
Basically the one who created the room can create a URL and someone else can paste that URL in the game, the name of the room is then obtained through a http request and then you can join
That's not a photon question however, you'd have to know a little bit about web requests too and how to create a simple webserver to help with matters like this
yes i know it is pretty complex process without photon thats why i am using photon
Creating the room is as simple as calling PhotonNetwork.CreateRoom, then you (or rather the client who created the room) has to do a http post request, passing the roomname to a webserver which stores the room name and returns a web addres or some code that another client can then use to connect
like there is a demo asteroid scene in photon and i just wanna make something similar to it ,neat and simple
I think that's wiser to just try and do something simple like that first so you have an idea of how PUN works
yes i am aiming for very simple ,just to learn not even a actual project ,how it works ,how i can use but i passed 7 days without much progress bcz ,i only understand
how to install and integrate photon in your scene
how to connect with master server
and thats all with some theoretical stuff
i have even read all the documentation page of photon website
so you want to create a room and pass room name to other clients right?
yes
with room name right ?
yeah
so first i have to make a empty gameobject with photonmanager script attached to it ,in which i will do that stuff and i can trigger any funtion in that script with button on click method right ?
photonmanager?
script name @prime beacon and sorry here was a powercut thats why i took so long to respond
ok ,can i ask you if i face any problem @prime beacon ?
Always better to just post simple clear questions to the channel. Whoever knows the answer and is free will try to help.
how to have each client have their own camera(camera is a child of a player) in mirror?
Disable the camera on your player prefab based on NetworkIdentity.hasAuthority is the most simplistic way.
We have started a new tutorial series about implementing Mirror in Voxel Play: https://youtu.be/UTMuqgNBhu8
This is part 1 of a tutorial series about creating a battle-royale game using our Voxel Play asset for Unity and the popular Mirror networking framework. I hope you enjoy it - subscribe and stay tuned for future episodes!
Get Voxel Play on the Asset Store: https://assetstore.u...
public struct Item
{
public string name;
public int amount;
public Color32 color;
}
public class Player : NetworkBehaviour
{
readonly SyncList<Item> inventory = new SyncList<Item>();
public int coins = 100;
[Command]
public void CmdPurchase(string itemName)
{
if (coins > 10)
{
coins -= 10;
Item item = new Item
{
name = "Sword",
amount = 3,
color = new Color32(125, 125, 125, 255)
};
// during next synchronization, all clients will see the item
inventory.Add(item);
}
}
}
does anyone know why this would result in:
"Cannot create an instance of the abstract class or interface"?
at line:
🛑 readonly SyncList<Item> inventory = new SyncList<Item>();🛑
Assuming mirror; SyncList<T> is an abstract class. You have to derive from it and implement yourself (unless using one of the prebuilt types:
public class SyncListString : SyncList<string>
{
protected override void SerializeItem(NetworkWriter writer, string item) => writer.WriteString(item);
protected override string DeserializeItem(NetworkReader reader) => reader.ReadString();
}
here is how you'd use it for your struct - https://hatebin.com/lirpnzecsm
What is your Item class?
probably not what it's supposed to be I would assume, given the example provided
I mean, can you paste that class?
in my case item would be player, all I'm trying to do is sync a list of players
public class Player : NetworkBehaviourNonAlloc {
it's not something I can paste here no
the entire class
You are trying to make a List of that and sync it?
a list of gameobjects that hold the player class, sync that as a list yep
yeah, that is going to not end well.
I know how to offline, why not online with synclist?
your class or struct I would expect needs to be restricted to primitives
whenever a client joins, if not added already add them to the list and sync- that seems simple
a MonoB is a whole different animal.
The issue is you are asking Mirror to serialize a very complex object
would you recommend a more simple sync choice then?
maybe their id
but like eh.. I would like to access them more easily
A value or a simple struct/class that only contains items you want synced
really I would just like their object
If you try to sync a MonoB it will 1) Probably puke on that and just say no and 2) End up serializaing a bunch of garbage fields that have no business being serialized.
If serialization were that easy, you could just RPC(MyScene) and be done with it... but obviously that can't be done.
i get this when trying to do this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class FragmentsCollision : MonoBehaviourPun
{
public float damage;
public int GrenadeOwner;
void OnCollisionEnter2D(Collision2D collision)
{
photonView.RPC("DamagePlayer", RpcTarget.All, collision.transform);
}
[PunRPC]
void DamagePlayer(Transform playerTransf)
{
Health hpScript = playerTransf.GetComponent<Health>();
if (hpScript != null)
{
hpScript.damage(damage, GrenadeOwner);
}
Destroy(gameObject);
}
}```
why can't i pass transform
i did it before
but this specific one doesn't want to work
@lunar plinth You probably can pass the pun network identity component
i think
i dont know the exact name of the component
i am talking about that one component you have on all networked objects, that enables you to do pun stuff
ah PhotonView
yeah i think
i think you will have to pass that in param
or maybe gameobject @lunar plinth, it could work as well
its been a while and i dont do networking this way
neither of those worked
i still don't understand RPC. I changed it to just a function and it works
can someone please explain what is an actual RPC use
i tried searching tutorials
but they don't explain why do i need it over funtion
documentation doesn't seem that clear also
You can't pass transform to pun2 serialization.
what can i pass through it tho?
Vector2, vector3, quaternions
so just numbers?
Received RPC "Explode" for viewID 0 but this PhotonView does not exist! Was remote PV. Remote called. By: #02 '643' Maybe GO was destroyed but RPC not cleaned up. what does that even mean
grenade has a photonView
and it's id is actually 0
Pretty sure zero isn't a valid view Id, so not sure how you have one with that number.
ah i was instantiating it not by photonNetwork.instantiate
but there is a problem
if i instantiate inside RPC. There is 2 grenades appearing. One is the correct one that completely works. And another one just kinda sits there
i feel like it's not 2 but 1 per player
for some reason PhotonNetwork.AutomaticallySyncScene isn't working, the only person that doesn't go into the new scene is the master client
Anyone know what’s going on?
The master client should be where scene changes originate from no?
i thought that would work but i still had issues
just tested it, the masterclient stays in the previous scebe
should i change levels in an rpc or a normal void using photon.loadlevel
update: even when its not in an rpc the master client doesnt go in the new level
I don't really touch that part of Pun2 so I don't know what the correct or best practices are. But I would read the documentation on it and look at some of the sample scenes for guidance. @weak plinth
okay
are RPCs like a static function?
@weak plinth master client should load scene
if (PhotonNetwork.IsMasterClient)
{
LoadGameScene();
}```
@lunar plinth You really need to complete the Pun2 basics tutorials and read the docs for some of this stuff.
if (PhotonNetwork.IsMasterClient)
{
PhotonNetwork.LoadLevel("Arena");
}
also this -> PhotonNetwork.AutomaticallySyncScene = true;
I can tell @lunar plinth
Networking is VERY difficult. Don't kneecap yourself by trying to skip to the end.
You will end up stuck on simple things for weeks.
now when i think about it the only thing i skipped was raise event
but here is a question. Again i want to transfer a game object to the RPS. But how can i convert the game object into the number and then back? Is that even possible?
The question is more vague than you think, but what you are describing cannot be done. You don't serialize "objects" and have them instantiate on the other end.
You instantiate objects using PhotonNetwork.Instantiate, and then you sync up values within those objects.
The reason why i need this is because i instantiate an object in the normal function via PhotonNetwork.Instantiate and then i want to parent it to the player
but i parent it via an rpc so it parents to the player on every pc
you can serialize reparenting, though you will need to come up with a way of indexing the parent object so that all clients agree on its index.
o o f
well time to get stuck on this part for another 5 hours
wait if i make an RPC that will fire a normal function will it work?
Or just read up on the docs and finish the tutorials so you aren't struggling so much 🙂
this thing helped me: https://forum.unity.com/threads/how-to-photon-networking-send-gameobjects-transforms-and-other-through-the-network.343973/
What is according to you guys the best and the most simple way to make a server which is can be joined from other ip's for a beginner?
There is no best nor there is any simple way
And although I understand why you are asking this question and this channel is supposed to be about networking, what have you done so far to find out what options there are that you could choose from?
Because if you want to make any type of multiplayer game, it's important to have a good idea of what requirements you have and what options in libraries you have, just telling you what is good in your case is impossible
Do tutorials for Mirror and Pun2 at the very least first. Then decide on your game goals... THEN you might be able to start thinking about the right library choice.
Any answers you get to your question will look like a meaningless wall of jargon right now.
What type of game u making
Photon is simplest to learn but if u plan to launch a game then think of the best way to monetize it cuz photon will cost a bit. If u have cash on hand then I suggest buying a small dedicated server and using mirror. Again monetize as u will need to expand the server's player capacity. For a beginner photon pun2 is best
Agree emitotron and I also think the meaning of simple can be misleading. I'm using a very simple library, but only in terms of setting it up so it's ready to take connections and receive data. On the flipside there is no handholding with anything. A big portion of the work is in making the actual communication between server/client possible through packet structures that are easy to convert from/to binary, but also keeping their footprint small because you can't be wasting bandwidth while sending data. Another thing I stumbled into just by going through the experience without any formal education in networking is the fact that data can get corrupted while making its way to its destination, so that's another thing not being done by this 'simple' library. And another thing to consider is protecting data so it can't be easily snooped/mangled with by using something like wireshark, so encryption is another important thing. These are just a few of the downsides of using a library that is theoretically very simple (and I personally don't mind this) but I wouldn't recommend this to anyone who is starting or hasn't been programming for a decent amount of years.
As the person above stated, going full AAA server is not something you will be able to manage without years of exp but a simple server is prone to corruption, lag and hacks. Photon pretty much eliminates corruption and lag is based on whether your code is complex/simple and how heavy your stage is. However, you will face hackers if ur game is online multiplayer and incentives competition. For a starter I recommend making ppl create rooms and play with their friends rather than pvp
Btw guys. When using photon for a card game. All I have to do is make logic for one player and photon will handle the enemy side. A simple if(!photon view.mine) should handle the enemy player side right?
In theory yes, that's how you can differentiate between the local player and a remote player
Well let me try to rephrase. You need to do logic for both one way or another, but checking whether you own the photonview or not is an important aspect of it
I've done this in a very similar manner on my server. The server creates objects and assigns it a unique object ID. This object will also be assigned to a player which has his own unique ID. I then update all clients with which objects exist by passing them some information about what type of object it is, the object ID, and which player owns it. Then on the client side the player has a game object with a NetworkObject component on it, and he can know if he owns it by checking isLocalPlayer on the NetworkObject component
So in practice these objects can have any script on them which can handle both local/remote player, depending on whether the local player owns the object or not it either can control it, or just set the object state that the server sends
@jade glacier I've tried your HalfUtilities to compress my rotation vectors to float16 but I noticed precision is pretty bad on float16. Even for euler angles the loss is still .22 degrees. Just multiplying my euler angles * 1000 and casting to short gives more accurate results. Is this the wrong use case?
half float is pretty terrible for anything not close to origin
what kind of values are you putting into it?
make sure you normalize rotation into a -180 to 180 range for best resolution
I use +pi -pi
What are the actual values being given to the compressor?
-3.14 to 3.14 ?
that should yield pretty reasonable results. Though not sure why you are using that range.
To apply it to a transform you need it in degrees.
or a quat
HalfUtilities aren't mine btw, its a public library that everyone uses. But it does have significantly less resolution that normal floats.
And halffloats are not ideal for rotation, since rotation is range based.
@grizzled narwhal
Its rotation so -3.14 to 3.14 is the best format
it has 2^-9 precision
thats fine
but for anything else its pretty bad
I would have to see your code. Not following what you are doing at all.
But regardless, half float isn't ideal for rotation.
Typically rotation is done with smallest three quat, or compressing euler floats to ranges.
Hey, I have a problem with photon, whenever I test my game inside the editor the first time it works fine, but the second time I try to test it it crashes, how can I close photon threads? I know it's photon cuase whenever I don't interact with it I have no problems. (using Pun classic)
hey guys i tried using photon bolt for the multiplayer in my game it works and all but your controlling the wrong player does anyone know a fix?
It’a an old project
@weak plinth Not a lot of bolt users in this channel, typically better to ask Photon Bolt questions on their discord
they have a discord?
yeah
dude
wtf
if i knew i wouldnt have switched to bolt
i was having movement problems so i gave up
They are different animals. I would use the one that fits your games needs
a simple fps shooter
by chance did u ever have this glitch?
when u join another lobby the other player is lagging up and down
I've gotten all kinds of glitches in the past. If I have a bug in my code sure.
Have you competed tutorials for the various engine options you are considering?
Mirror and MLAPI are also popular. Different architecture and hosting requirements.
i just need something to play with friends
like 1v1
or 2v2s
have you heard of welton king?
i was following his tutorials and then i got the bug and then i switched
nope
Photon docs are very good
follow the doc & tutorial
I just started using PUN like 2 weeks ago
yeah i added lag compensation using the docs
it reduced it by alot
but its still bad
Lag Compensation similar to what is being described in the Pun2 doc on the topic is mostly only useful for shifting the timeframe of deterministic things, like projectiles.
Trying to lag compensate something non-deterministic like a player will produce insane rubberbanding at best.
then you are trying to do advance stuff too soon. Just complete the official tutorials for Pun2, Mirror and anything else you are curious about before even trying to get advanced or make any choices.
Definitely don't even think about networking yet then.
Learning unity and networking at the same time will lead to months of slow grinding failure.
yes
Hey, I have a problem with photon, whenever I test my game inside the editor the first time it works fine, but the second time I try to test it it crashes, how can I close photon threads? I know it's photon cuase whenever I don't interact with it I have no problems. (using Pun classic)
Sync view with others devices is different, how can i fix it
Hello , i use Photon in Unity. On click button i want to leave from room and disconnect in the same time.
I have little problem with disconnect.
Where is a problem ? Could you help me fix it ?
Operation LeaveRoom (254) not allowed on current server (MasterServer) #1 error
NotImplementedException: The method or operation is not implemented. #2 error
If I not mistaken, disconnect only allow when u in master server. When u in the room, you're in game server not master server, so you probably need to wait until you reconnected back to master server after you leave room then only call the disconnect
You have right.
I understood what happend.
When i connect with game server i don't open room yet. I have leave from room (#1). About (#2) you explain it 😉
But how can i disconnect from game server ?
I have another weird situation. If i connect to master server (and game server) and too long stay there i have another errors:
NetworkPeer broke! (#1)
NullReferenceException: Object reference not set to an instance of an object (#2)
what options do we have to make multiplayer in unity thats not p2p?
there are headless unity server instances,
you could just write your own backend in any language,
and there are services that allow you to have some authoritative server code, I think (?) photon bolt is one of them?
You can use unity headless build or write your own backend (but that can't make of unity physics so you might have problems there)
Is there a way to make a server for free and use for unity to an online unity game ?
depends. If you are a student you can maybe get azure / aws student credits else nope
heroku possibly but.. that is also limited
Hello,
If possible, I would like to gather information on how I can create. Opponent draw system (random selection) that will retrieve the names of players to be drawn from Play Google (accounts)
The major cloud providers all have free tiers
Okay But talking about system of select opponent if you know what i mean 😉
Ewww PUN
hey guys i tried using photon pun 2 for my game but the movement is horrible i tried to use photon transform view and photon transform view classic and i even tried to add lag compensation but none of those worked the players keep glitching everywhere
does anyone know how to fix this?
Hard to say without any information. But a usual problem is not disabling your controller code if IsMine == false
@weak plinth
Have you completed the Pun basics tutorial?
yes
You'll have to give a lot more info then
You have disabled all controller code as required for the syncs to work?
can anyone help me? I am upgrading from Pun 1 to Pun 2 (bn is a string[])
@jade glacier you are a developer of pun 2 right?
One of them
do you think you can help me?
where?
The photon discord.
found it
How many places did you crosspost? (that is a frowned on practice... typically ask in one place and wait)
people on one of these channels are in most of them, so you just clutter up everyone's feeds.
👆
i have a pun 2 function cs [PunRPC] void SetChildLol(int Weaponint, int TransformInt) { Transform WeaponTransf = PhotonView.Find(Weaponint).transform; Transform PlayerTransf = PhotonView.Find(TransformInt).transform; photonView.RPC("ChatMessage", RpcTarget.All); WeaponTransf.parent = PlayerTransf.GetChild(1); WeaponTransf.GetComponent<ShootGun>().SendDFNL(); } but when i'm trying to call it it gives this error
this is how i call it cs localPlayer.transform.GetChild(1).GetComponent<PhotonView>().RPC("SetChildLol", RpcTarget.All, Weapon.GetComponent<PhotonView>().ViewID, localPlayer.transform.GetChild(1).GetComponent<PhotonView>().ViewID);
yeah, that error message is correct
looking for opinions from those who have looked into the most recent dotnets code, if someone was just starting a large scale multiplayer game today would you use the new official netcode or mlapi? If using the new dots networking, does that mean one has to use 100% dots entities for anything that needs to be synced?
How on earth do you invoke the Instantiate(); function on the main thread..
I need to run the function that continuously listens for incoming connections in a infinite while loop in a separate thread to not deadlock the game.. Why do I feel like the solution to this will require some overly engineered and complex solution with 100 layers of abstraction added to it
such things are often handled by a command queue,
you could have a queue or another collection type with locking, in other threads you enqueue tasks that have to be executed on the main thread,
and each frame, the main thread can poll for tasks to execute from that queue, if any are available, and execute them
Hey guys how does one update UI over the network for like what i am trying to do is set a lobby name so the other player can join it when it sees it on the room listing
something common would be to have a central server, for example for match making (if you don't have that, you probably have a client as host, but then connection can be more tricky),
so if a client chooses to open up a lobby, the server receives a request, opens a lobby with a specific name or code, and it would send that code back to the client, then with the received package, you could update an UI element to display the text of the code or name, so that the player can share it with others
then there should also be a kind of request to join a lobby, with the data payload being the name or code of the lobby
(oh sorry, not sure about framework specifics, but I think photon should have something for it yeah)
The create lobby works fine is just seeing the other lobby from the other player is not working
Would 200 players be possible in a single room with a low poly game?
Games like Battlefield 4 have up to 64 players per room, and it's not even low-poly.
Poly doesn't matter. Number of objects sending data, and what kind of data matters
You aren't sending polygons with networking
@azure crown yes as long as your backend infra is capable of handling that and what scale you are looking at, for example, GTA SAMP have server hosting 1000 players in a single world
And its raknet :) old tech
I wrote my server using system.net, and know nothing about dots. How difficult would it be to switch my server to use dots?
About as long as a piece of string is
Was that a reply to me @grizzled narwhal ?
Can anyone point me in the right direction for how to do websockets using a webGL build for unity? Is there a standard way of doing this?
From what im seeing, using a library like websocket-sharp or using a JavaScript plugin to implement seem to be the two options?
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
Camera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed * Time.deltaTime, 0);```
so this seems to fix my camera shakiness
by adding time.deltatime
however this locks it to one axis
if I remove deltatime it allows me to look up and down, but the shakiness comes back
how did I get in the networking channel wtf
Does anybody have any tips for safe multiplayer modding? How can I stop servers from running malicous code on clients? Is there a way to sandbox assetpacks?
From what I can see, the only way to do this completly safely is force servers to use a sandboxed scripting language, but thats sorta a nuclear option I think. Are there other methods that people have used?
Done this with sandboxed lua
Does your client need to run user code supplied from the server?
Is there a specific "best way" to save a json downloaded from an API in Unity?
I've heard everything from just storing it in Resources, storing it in Assets to encrypting it and hiding it among some random asset folder.
I don't need it to be super secure since it's just gonna store a rule set for my biomes that are generated.
In the editor or during runtime?
I do everything in code, so runtime.
@winter kraken Yes cause your question is impossible to answer. But I can say the following : dots atm is in beta so its buggy, there are little resources out there, and it will probably change until the release so code you write now will be broken in a few versions
Anyone here good with photon?
If you are i need help getting my players to load the same scene
how to make players gather and join together using pun
currently what i have done
an interface with a button to join
integrated pun into my project
and an script to make room and connect with master server with feedbacks
a 2d player prefab which can move left and right
and 2 scenes one is empty for player to gather together and another is to for ui which i above mentioned
i hope this will help you to understand project situation
please help
@stray moth PUN?
Yes
I have
I think my rooms are messed up,thats why let me get back to u
The room name is exactly the same but it wont start up the scene for both players
@prime beacon
i have this script that should add a player to the teams ```
[PunRPC]
void SetUpThings(int teamToAddPlayer)
{
if (teamToAddPlayer == 0)
{
redPlayers++;
}
else if (teamToAddPlayer == 1)
{
bluePlayers++;
}
}
// Start is called before the first frame update
void Start()
{
Vector3 pos = new Vector3(0,0, -25);
MenuInstantiated.SetActive(true);
Debug.Log(redPlayers);
Debug.Log(bluePlayers);
if (redPlayers == bluePlayers)
{
teamBuffered = 1;
team = 1;
}
else if (redPlayers > bluePlayers)
{
teamBuffered = 1;
team = 1;
}
else if (redPlayers < bluePlayers)
{
teamBuffered = 0;
team = 0;
}
photonView.RPC("SetUpThings", RpcTarget.AllBuffered, teamBuffered);
}``` but it looks like buffered RPC happens a bit to late
so first player team is assigned corresponding to the amount of the players in the team
and THEN you get a player amount
how can i make it so i get the player amount first
how to make players gather and join together using pun
currently what i have done
an interface with a button to join
integrated pun into my project
and an script to make room and connect with master server with feedbacks
a 2d player prefab which can move left and right
and 2 scenes one is empty for player to gather together and another is to for ui which i above mentioned
i hope this will help you to understand project situation
please help
@fallen frigate no one answered after detailed question
i am getting this error and don't know how to solve it
i successfully created a room according to script or debug testing
but can't able to join using random room
and getting this error
Does anyone know of an in-depth authoritative server architecture books/courses?
@weak plinth Hi, sorry pulling up yesterdays converstation because I went to bed. Yeah I'd like to get compiled code running on the client if possible. Is that feasible?
@crystal galleon Don't ping admins
They are admins not support staff
And to get help post a specific question
Not 'Uwu we need help'
@tired locust Please don't post off-topic
#archived-networking message why everyone is ignoring me ,please help guys
😞
Very tiny picture because of screenshot over 2 monitors, but for the first time I have 2-way UDP communication between Unity and my server 😄
@fallen frigate have you successfully finished the tutorial? It covers the basics of matchmaking. Your question is a little hard to make sense of though.
How do you give a download link to your friends for your multiplayer game without fully building it.
I just want to give it to them to see if it works and to test it
you still need to build it @ancient iris
Since it is just a test build, you could select all the files in the build folder, right click, and select "send to zip." Then you would send that file to your friends, either via e-mail or whatever online upload/download option you choose.
are the new multiplayer tools out yet? I cant seem to find any docs for it
you could run the server on your own computer and connect using localhost
ofcourse you'd want to do major testing with a remote PC before you roll anything out
I think that's an option you need to select when your installing unity
I installed it but then It still says the same error
Do I need to make another whole project?
If I installed it just now
@fallen frigate have you successfully finished the tutorial? It covers the basics of matchmaking. Your question is a little hard to make sense of though.
@jade glacier which one ?
@silver steeple
@ancient iris No. Projects and Unity versions (and its modules) are separate
@fallen frigate https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/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!
@fallen frigate https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/intro
@jade glacier but i can't able to fully understand it
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!
i was watching a youtube tutorial on pun2 rooms
by info gamer
and i followed that
If you can't get through the basics tutorial, you may want to hold off on networking until you get more Unity experience. @fallen frigate
i just want to know why this error is coming
@jade glacier
like i have experience with unity
and made 2d games with it
i am trying my best to figure out
but
That error says exactly what is wrong though
this error i so confusing
like i have put a debug statement when i connectedtomaster ()
which said i am already connected to master
and i can't able to join room after creating it
using joinrandomroom()
thats the whole situation
and i don't know what that error even mean ?
and for which callback i should wait?
@jade glacier
😒
You have to do the tutorials to understand the process of matchmaking and then joining a room.
No one is going to be able to help you if you can't get through the basics tutorials @fallen frigate
your particular error is saying you are connected to a game room already, and you aren't on the master server (matchmaking server)
yes but i already figured that out
how can i i know how many joined the room ?
like how to monitor those who joined the room
is there any method in photon ?
to do that ?
private void SpawnPlayer()
{
GameObject go = PhotonNetwork.Instantiate(Gamehandler.Terrorist.name, Gamehandler.FFASpawns[Random.Range(0, Gamehandler.FFASpawns.Count)].position, Quaternion.identity, 0);
go.name = PhotonNetwork.player.NickName; // + go.GetComponent<PhotonView>().owner.ID.ToString();
Gamehandler.gameObject.GetPhotonView().RPC("AddPlayer", PhotonTargets.All, new object[] { go.name });
}```
[PunRPC]
public void AddPlayer(string Name)
{
GameObject player = GameObject.FindObjectsOfType<PlayerGameplay>().ToList().Find(pg => pg.GetComponent<PhotonView>().owner.NickName == Name).gameObject;
StorePlayers.AddPlayer(player); this part gives a null reference error
}```
NullReferenceException: Object reference not set to an instance of an object
Gamehandler.AddPlayer (System.String Name) (at Assets/Main Assets/Scripts/Gamehandler/Gamehandler.cs:487)
im sending an rpc to all players to add a new instantiated player to their player go list (so i dont have to use getobjectoftype every time i need to access a player) but i have no idea why its giving me a null reference error
how can i i know how many joined the room ?
@fallen frigate you could manually count them by just in/decreasing an int whenever someone joins or leaves a room
@fallen frigate you could manually count them by just in/decreasing an int whenever someone joins or leaves a room
@copper wadi k got it now ,thanks 🙂
@copper wadi which line shown there is 487? Have you isolated which object is null?
@spring crane So what do I do to solve the problem
This isn't technically networking related, but I figure y'all would know anything about it if anyone: https://twitter.com/roystanhonks/status/1318677036177784835
Have a replay system that is fully deterministic for same build/different machines, so long as the CPU vendor is the same 😦
Anyone know why determinism would break in #Unity between Intel and AMD CPUs (same build)? Tried both Mono and IL2CPP and get immediate desyncs. Floating point determinism is tricky, but I've had no desyncs with running very long replays on different machines w/ same CPU bran...
is this the right place for netcode/ghost system questions?
I'm upgrading a project from earlier this year. I'm trying to get the index to my ghost in the ghost collection
there used to be a GhostSerializerCollection.FindGhostType<EnvironmentCubeSnapshotData>(); method but it appears to be gone
the samples show doing some loop and finding the ghost based on a component that is on it
the thing is my ghosts are not uniquely identified by any one component (currently, although obviously I could change that)
so I guess I"m looking for the ghost generated type? but there's no generate button anymore so I don't get a type for my ghost anymore?
how does this work? do I have to create a component unique to each ghost type?
what does this generate?
where is Name used?
FindGhostType does not appear to be in the changelog
basically I want to get a prefab from EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection) using some hard-coded value
do I just hard-code the index itself based on the order I added it in the ghost collection?
and just be super careful to never insert any, and leave empty placeholders for ones I delete?
there's gotta be a better way...
I would definitely try Netcode questions in the DOTS channel, not many people in networking have even played with it.
ok thanks
Heya, does someone here have experience using Mirror?
I started using it some days ago and I've been having a problem syncing objects that are saved with the scene (as in, I can't spawn them)
@floral turtle Floating point math just inst deterministic across cpu arc (and os?)
There are deterministic physics engines but most are behind a pay wall
@grizzled narwhal most modern intel and AMD processors both use the x86-64 architecture, so this would not require cross arch determinism
Try it out. It isnt
Hmm, are you sure? I made a small C# app that does hundreds of computations that is determ across intel and AMD: https://gamedev.net/forums/topic/708301-floating-point-determinism-in-unity-physx-and-net-intel-vs-amd/
I've read that article, but he only states that determ cannot be expected across different compilers, builds or architectures
And even on the same pc across different runs
PhysX isnt build for determinism too
we actually have a functioning replay system that works on different runs/different machines, provided the CPU vendors are the same: https://twitter.com/roystanhonks/status/1318677036177784835
Anyone know why determinism would break in #Unity between Intel and AMD CPUs (same build)? Tried both Mono and IL2CPP and get immediate desyncs. Floating point determinism is tricky, but I've had no desyncs with running very long replays on different machines w/ same CPU bran...
Then im guessing floating point math isnt deterministic across cpu brand?
well, the test I did above shows a case where the arithmetic is deterministic with simple .NET apps
'Simple'!
?
PhysX isnt simple
And it isnt build for determinism
The expert on determisim here is @graceful zephyr
But he will tell you roughly the same stuff
I'm a bit confused
physx and Unity are clearly determ on same build, different machine, same arch same vendor. I am asking if it is possible for it to work across vendors. Are you saying it is not possible?
Probably not
do you have a source for that? I'm finding it hard to find anything concrete
"The PhysX SDK can be described as offering limited determinism. Results can vary between platforms due to differences in hardware maths precision and differences in how the compiler reoders instructions during optimization."
yes, I have read that. I am looking for a clear answer on whether it should be deterministic across vendors on the same arch
Dont have that
okay, thanks anyways @grizzled narwhal
@floral turtle So as you know it's possible to get physx determinism on the same arch/compiler/etc. thing... if this is usable or not depends on what ur trying to do .
If you want this to be deterministic you always have to step the simulation forward, you can never reset any objects, etc.
You can't do "predict-rollback" thing with that type of determinism
Because the second you reset objects, the determinism promise is gone
You also can't have anything from the 'outside' influencing the physics simulation like animation systems, etc.
@graceful zephyr yeah, definitely not prediction with rollback...I'm under no illusions at how difficult that is to build :S
Not primarily planning to use it for networking (brought it up in this channel since I figured it would be where the knowledge was). Mainly seeing if it is something that can be solved with compiler flags/configuration to allow users to share replays cross CPU vendor. Using it for deterministic lockstep networking w/ input lag would be an interesting stopgap to moving to a more powerful system (like quantum), but the cost to users is significantly higher when a multiplayer session desyncs versus a replay, so probably not worth the investment
So using it for like... client side prediction
And getting "close enough" to determinism
It all works for
But like hanging your entire game on physx being 100% deterministic
I wouldn't dare
At least not without being able to compile physx myself
and make changes
If you get a year or two down the line in dev, and then realize oh wait there's this specific scenario which breaks the determinism on this arch/setup/etc. whatever
I'd never ever dare to hang my game on something
I don't have control over
When its such a core part
👍 that is mostly the kind of opinion I was looking for. It's easy for us to just flag replays if they are captured with intel or amd, and warn users that sharing may lead to desyncs...it's a nice feature, but not critical
Hi guys, so I’ve been making some prototypes for some game ideas I’ve had using Unreal. I’ve found the engine really uninspiring (I know that sounds weird) and there’s something about Unity that I really love
The one game I want to make is multiplayer however. Not overly complicated but still multiplayer.
Do you guys find Unity is a big pain for networking using Photo or other plugins? Or is it more so just time consuming but enjoyable?
how to make my photon manager script act like an singleton in unity ,like it should not get affected by changing scenes ?
also i am trying to make other player join the room so we can move together in a scene but only host can start the level
and i want my lobby to show players name who joined and arrange them in a column
please any experienced in pun 2 help me
Hey so I'm trying to understand prediction for a multiplayer game. Can I do all of the prediction clientside based off the user's current velocity?
How its going to work is just a simple websocket server. Client sends his rotation and position to the server, and the server sends back the same information of all players in the lobby
Third day in unity so idk if this will work. Also will it be a problem with users that have low framerates?
also how many ms should every request be
I would post that in the DOTS channel. Very few to no Netcode users in this chan usually @patent magnet
@wide bolt photon is said to be the easiest way to get connected and playing.. Though it has limitations in terms of scaling, the easy is weighed vs the cost of leaving the "educational" tier of players allowed online at once. Unitys networking itself is a mess to be honest, its not happening as far as I'm aware so you would be relying on a third party like photon or community extensions reviving collapsed systems like unitys old networking "unet". "mirror". Which to be fair is easy enough, has a great community behind it. (With no ccu paywall)
If its a small uncomplicated game with a small lobby definitely go with photon
Sure, everything is possible and of course we're only biased to our experience and opinion
Rooms in photon products are limited by the same factors as any other platform. How much data each user is pushing the main factor.
Right but its known with photon or any cloud service data is expensive
Mirror and Pun2's limits to users per "game" are largely tied to how efficiently the dev is serializing and sending.
They charge based on usage of course. The alternative is either hosting instances, or doing a Nat Punch system and having clients host.
We're talking best case really though here
Servers are expensive with the "free" products as well
Except for the "free" steam thingy...
after you gave them 30% of your rev
True, and I think with all the heavy lifting photon does for you its worth the cost
So classifying a product as expensive is relative...
You can do player hosted, and skip the relay backup, and rely on just natpumch for the cheapest route. But that will leave a lot of players in the cold. But it is an option.
Not really a winning business plan, but an option
And that's why nobody does that
That's what Unity originally shipped with, the old defunct UN (Unity Networking), with a master server to run punch (raknet underneath)
Mirror and Pun2 and most other products get increasingly difficult to develop once you pass 16 players per game session
around the 64 player count point, you need to be an experienced dev. Regardless of netlib.
I can't even blame it entirely on my own ignorance, nearly everyone if not everyone I've spoken to about photon says its great for smaller gigs but be warned you'd get more bang for your buck going with mirror, maybe they dont know what they're talking about or maybe its just a matter of optimising
If they have finsihed their game and have the numbers to show, then sure
I haven't seen any Mirror releases, or their revenue numbers so can't comment.
Among Us runs their own thing (funny enough, very similar in approach to photon), so he could run down the costs well
Fully relayed, client authoritative, etc
Phasmophobia is on Pun2, and the consume insane quantities of data
Phasmaphobia is photon (and I'm sure their bank account would not even get scratched by what they pay us...:)
I have been talking to one of their net devs about helping them implement bitpacking and other compression.
can't disclose anything, of course... except it is PUN2, as lots of people know.
Fair enough, average dev probably wont need to worry about hitting any ceilings either
I don't know their numbers, and couldn't share if I did yeah.
All cloud models are designed to scale endlessly, that is the appeal of hosting that way.
When people say Pun2 or Mirror can't scale, they typically mean the number of users in a game... which is all libraries.
If you've got a good consistent revenue model ofc, I guess that goes without saying
Ye, SCALE normally means:
- you can host 1 million or more CCU without effort?
it scales down as well. If your users drop off, your costs drop of.
The appeal is it is a fixed operating cost, that is directly tied to usage.
Honestly David, its a fair model for the customer more than us... Other industry sectors have more "hungry" models... But that may be subjective, of course...:)
Unlike buying 20 servers and hosting them yourself.
CCUs just scare hobbyists. But to anyone running a business, the predictability of the costs involved are a positive.
I must be talking to the wrong folks I guess, clears photon up for me at least
photon is also a lot more than PUN
I know as a game dev id rather worry about that, than managing my own server fleet or whatever lol
Hobbyists tend to gravitate toward Mirror because of the allure of "unlimited free", but obviously it never is. Someone wants to get paid for using their bandwidth.
Ask the Among Us developer his opinion on Photon...:)
He's not our customer (anymore), but he normally recommends photon
Cheers guys, ill do more research, currently invested in mirror but may change I think it may fit my needs more
The reason to use Mirror should be because you want a Unity based server... not for money reasons.
Pun2 vs Mirror should be a choice based on architecture.. not trying to get away with "Free"... because neither are.
GL @somber drum
If you are comfortable with its API, and trust it can do the job you need, and you understand what will still be needed "outside", done
Hello, i am not sure i have this error "JoinOrCreateRoom failed. Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: Joining). Wait for callback: OnJoinedLobby or OnConnectedToMaster." ?
Wait for callback: OnJoinedLobby or OnConnectedToMaster.
@gleaming prawn @jade glacier @somber drum
Thank you guys for all the awesome information! I had no idea Phasmophobia was running on Photon
Very cool! I’m really excited to jump back into Unity development 😊
I fixed everything, but i have another problem when i "joined" (i am not sure i did it ) and try to leave from room i have next error
"Operation LeaveLobby (228) not called because client is not connected or not ready yet, client state: ConnectedToMasterServer
UnityEngine.Debug:LogError(Object)"
"Operation LeaveRoom (254) not allowed on current server (MasterServer)
UnityEngine.Debug:LogError(Object)"
When you joined which?
System is :
- connect to server 2. Choose create or join 3. if i create everything is okay if i choose join (joinrandomroom) it is little problem i don't know why
Might want to paste your code, not sure from what I seeing so far.
In a bin preferably, since its likely your entire conntection cs file.
https://doc.photonengine.com/en-us/pun/v2/lobby-and-matchmaking/matchmaking-and-lobby#lobbies
Are you working for the docs on dealing with lobbies and matchmaking?
Not seeing anything in your order of events there that suggests the need for lobbies?
So it should be pretty boilerplate code to get a room started.
I will read this docs but i tried with Lobby
I connected in the same time like to connect to server
i think it's works 😄
Thanks 😉
What kind of problem is with Disconnect(). I made a button to leave a room and also server but disconnect doesn't work i read lots of this topic but i do not know how to fix it .. Could somebody tell me something about disconnect from photon server ?
Just the usual Unity noise as far as I know.
I'm trying to find a way to get rid of jitter in my movement. The client sends 10 packet/sec to the server and the server sends 10 packets/sec to clients and attaches a timestamp (similar to Time.time which is just an incrementing counter) to the packet. Upon receiving of the packet on the clientside I'm using the timestamp to interpolate the position and rotation but I still experience serious jitter. How can I resolve this? Here is a general breakdown of how it works on the client
float timestampprev = 0;
float timestamp = 0;
void OnNetworkUpdate(Packet packet)
{
BinaryStream stream = new BinaryStream(packet.data);
timestampprev = timestamp;
timestamp = packet.timestamp;
for(int i = 0; i < m_networkObjects.Lenght; i++
{
Vector3 position = m_networkObjects[i].gameObject.transform.position;
Quaternion rotation = m_networkObjects[i].gameObject.transform.rotation;
NetworkObjectState nos = new NetworkObjectState();
nos.position = stream.ReadVector3();
nos.rotation = stream.ReadQuaternion();
m_networkObjects[i].gameObject.transform.position = Vector3.Lerp(position, nos.position, (float)timestampprev * 10);
m_networkObjects[i].gameObject.transform.rotation = Quaternion.Lerp(rotation, nos.rotation, (float)timestampprev * 10);
}
}
The jitter is both on translation and rotation
I feel like maybe I should interpolate between previous position that server sent, and the new position I just received, instead of interpolating between whatever the position the object is at and the received position
Or maybe it has something to do with my timestamp which isn't between 0 and 1?
OnNetworkUpdate is the same timing segment as Update?
I'll have to check actually give me a sec
Typically you would see interpolation inside of Update()
OnNetworkUpdate looks like either a fixed timing, or some kind of arbitrary timing based on your networking.
No actually it only runs whenever a new NetworkObjectState is received
Then you are baking in jitter
So yeah possibly kind of arbitrary although in theory it runs 10 times a second
In theory, it happens whenever your packet arrives.
which is internet noise.
Interpolation is the act of translating frames into the screen refresh updates.
Yes I see your point, so I should have it run on a fixed rate and what if there's no data to update with?
With extrapolate you mean like prediction?
This is why networking uses buffers
Not really the term I would use, since prediction has other meanings in networking
just extrapolation
Never have done that before, I know interpolation between 2 points, but extrapolation is the opposite right?
So you keep moving an object at same speed/direction it did with last data point?
Do I still have to change the function so it runs on fixed rate or is that just something you recommend doing?
How you implement it is up to you. But if your buffer is dry, you have to either hold the last value, or extrapolate something
you get the concept, I can't really give you much more without actually writing your protocol with you.
I understand, just trying to do this without having to rewrite much although I feel like that would be the better way
i found that to be the case when i was working through this... still am
Wouldn't even be that much work probably, just have to rethink the strategy on it because I did it a little too straightforward without thinking about the implications
I did it similar as I did with PUN in the OnPhotonSerializeView, but I don't know anything about the implementation of that function, just that it runs whenever there's data
dont trust timestamps btw
Yeah kind of naive I know
You can't lerp unless you have a tick defined and some kind of buffer
If you want to avoid making that system, try using MoveTo and RotateTo rather than lerping
Those let you set the rate of change as a way of damping changes. Won't be perfect. But you can't get perfect without proper lerping in Update.
And you can't lerp without a proper buffer.
Thanks I'll give it some more thought instead of trying to rush it, you've given me multiple possible solutions so I have to see what works best given circumstances
Proper transform syncs are hard. There is a reason all of the networking libraries have terrible implementations. They require a proper tick engine to do right.
I feel you and I'm guilty too haha
Which library are you using?
I've seen you talk about tickbased simulations before but haven't tried yet to implement that
For networking you mean?
ENet
Everyone makes a bad transform sync to start. You have to try the shortcuts to find out why the shortcuts don't work.
Yeah this is more like a practice project for me to see what problems I have to deal with if I want to make something serious
here's how i did it for input + prediction strategy
- server sends current tick to client upon succesful connection
- client caches this value as offset
- client begins counting ticks at same rate as server.
- client subtracts offset from received input.
- client adds offset to outgoing input.
I either find no useful information at all, or it's some long boring essay and I lose focus quick to absorb all the information
Thanks @slim ridge that doesn't seem too complicated to keep some kind of timesync that's not floatingpoint based
Most of us just use FixedUpdate as the tick, since its the same tick engine that runs physX and most of Unity internals.
ya, count ticks as int or long or even short
But that would mean I definitely need to have a buffer right
byte is plenty
There's no buffer currently
unless your tick rate is super high
its 4 seconds of buffer at 60 ticks per sec
Any packets that late, aren't worth trying to resimulate.
I'm doing 10 per second so not very extreme
Not doing any prediction either and if packets get lost so be it
I don't want to overcomplicate a project like this, if it looks good (and no obvious jitter is visible) I think it's good enough
Try MoveTo and RotateTo rather than lerping then
That is what the Pun2 vanilla sync does and most people are fine with it.
That works without buffering values?
It is always rotating or moving toward the latest value at a fixed velocity/ang vel
About the best you will pull off without a proper buffer.
Just moving your stuff to Update for interpolation is a start no matter what.
you can't interpolate outside of Update()... by definition.
I might give that a try. Got another question related to this jitter however. My server is in Germany and I live in Suriname (South America). When I connect with 2 clients to it (both on my computer) I don't see jitter, but when a friend from America joins I see him jitter around and he sees the same, so kind of curious how that works
prolly the timestamp
You can do crafty things having a timestamp
they are expensive and clumsy, but as long as you have it you can use it.
That makes it more difficult to test it because it seems to look fine untill someone from another location joins
So not sure why it doesn't jitter because both my clients need to send data to a server that doesn't run on my local machine
In a way I expect to see the same problem
Eitherway I guess this method I'm using isn't really bulletproof
You aren't buffering properly, so you are going to see the internet jitter and framerate jitter in your rendering.
Yeah gonna try the MoveTo/RotateTo method and see how that plays out
So I’m working on a game, and I plan on implementing some sort of multiplayer further down the road (like 8-12 months down the road), but I know little to nothing about networking. Does anyone know any good tutorials out there that covers this topic pretty good in depth?
it's a good idea to start building with multiplayer in mind, it's not going to be something you'll want to start with 8-12 months of offline code made, pretty much from the ground up
Dapper Dino has some good stuff
depending on your needs, different channels tend to teach in depth for what they use, I watched this guy for mirror he does a great job explaining the general idea
https://www.youtube.com/watch?v=77vYKsXC4IE
Join our Discord: http://discord.shrinewars.com
Patreon: https://www.patreon.com/shrinewars
In this Unity multiplayer tutorial, we cover the building blocks of multiplayer Unity games, go over various network topologies, and design the architecture for a sample game based on ...
@winter smelt
Does steam host servers? Planning on releasing a game in steam so I would like to know for my games multiplayer.
If not, I will just use Photon PUN
@slim ridge
Not sure I'm saying something you already know, but this:
- client begins counting ticks at same rate as server.
Caught my attention
You know that hardware clocks DRIFT, and that stopwatches will not keep aligned... Besides the network "jitter" may make your original alignment bad in the first place...
You need to keep CONSTANTLY fixing/correcting the local clock using the server clock as reference (needs to be send down frequently)
If you do not do this, you will get very bad "rifting" in any slightly longer game/match
thanks @gleaming prawn
What kind of problem is with Disconnect(). I made a button to leave a room and also server but disconnect doesn't work i read lots of this topic but i do not know how to fix it .. Could somebody tell me something about disconnect from photon server ?
You need to ask a SPECIFIC question to get help.
i mean by ids
i have to make an array of skins with ints(ids) on server and then compare stuff with that?
i got some anwsers before forget to take ss
Need a general answer
What is needed on server and what to client and what to do when changes happen
Photon or Mirror both works
Yes but this is for specific questions
Its pretty easy to do with rpcs and you should be able to do that if you want to do multiplayer!
SyncVar, RPC, RaiseEvent, MessageBase
Well sorry for fucking noob English, i want to know is i make an array of skins and assign them a id this wiill do the server, on the client it will pass command N get data back
Somethingg like the actual process what games do to sync large amount of stuff
By iDs
@fair cosmos there's a lot of ways to do this, but as a simple way it's fine to just send an ID then have the client load the correct skin
yes, the basic strategy is to keep this information in a database. only the server accesses this database and serve the data to clients
then in your client build, you include the map of skin id -> skin asset
server tells client which skin id he can use
I wonder when you want to test multiple clients, is there a way to launch multiple clients through the Unity Editor or you have to build an .exe and run that multiple times?
It is a pretty common practice to do a project mirror and have two editors open. I don't recall the software used for that though.
I typically keep all networking development separate from the complete game though. leaving out all graphics and textures makes a huge difference.
Curious yalls thoughts
https://twitter.com/EliCDavis/status/1319369251468304401
Expecially coming from a unity perspective where swagger is really less ideal
If you had to have a Restful API distributed to you in only a single way, what would you prefer
as a properly documented module in the language i happen to be using to consume it or as a deployed swagger-like documentation
Unity goes radio silent on their Networking these past few months
:/
A lot of non-engine and non-game related news on their blogs too after the IPO
Very worrying
@dawn laurel How long have you been using unity? I don't think anyone would be wise to rely on unity's native stuff
from UI to 2d tiles and 3d terrain, networking and so on
Very worrying
Not really if you know the mature tools out there...
their UNET replacement chart seems a tad off https://support.unity.com/hc/en-us/articles/360001252086-UNet-Deprecation-FAQ
Update [11th April 2019]: As promised, we have been following closely, and building our new Connected Games solution, alongside your feedback. We’ve updated the FAQs below to address the concerns w...
As people in this channel is well aware, do not wait for a built-in solution
The new built in attempt will come eventually, but does not seem close to completion, and there's no word if it will ever target the mature GameObject Unity (currently it seems to target the DOTS pipeline, which is also not ready)
Their blog posts reflect whatever was their mind (and PR communication) at THAT time...
I'm having a particularly weird problem and hoping someone can help me out.
I am doing a Webrequest on some of my android devices. They both run Android 10.
Same apk is build on 2 of my devices.
On 1 the webrequest completes just fine and everything is dandy (OnePlus 5T)
On the other however, the webrequest just keeps going. Never returns an error or finishes the webrequest (Samsung Galaxy Tab S7+)
The webrequest itself is called in a coroutine "yield return wr.SendWebRequest"
What could be causing this?
Please @me if you reply to this, thank you!
The new built in attempt will come eventually, but does not seem close to completion, and there's no word if it will ever target the mature GameObject Unity (currently it seems to target the DOTS pipeline, which is also not ready)
@gleaming prawn Yes, but there is no other solution with server authoritative + lag compensation and client prediction as easy to implement out there like Unity's solution
And I can't really pull off in-house networking solution on my own
Realistically
There is
Bolt does exactly that since launched in 2015
if THAT is really what you need, you should give it a try
The other solutions are still in pre-2015 era, in that all they care about is Data-Transfering (which is a topic some people here discuss a lot: the key to a netcode solution is not how to transfer data, is how to control the simulation)
AFAIK, the netcode solutions that work on that (simulation, not only transfering data) are:
- SpatialOS
- Photon Quantum
- Photon Bolt
- Unreal Networking, Source Engine networking, etc (not Unity)
- Unity's NEW netcode (not ready)
AFAIK all others are lower-level (in that they offer you a few was to sync data, but nothing in terms how that helps you build a tight networked gameplay.
I might be wrong, of course.
If it makes yall feel anybetter, they hiring a buncha networking people. It's atleaast a priority
they seem to have the right idea for some stuff, but does anyone know if they have actually achieved cross platform determinism with Unity Physics? It's advertised as deterministic, but I'm curious if that includes between platforms and builds: https://docs.unity3d.com/Packages/com.unity.physics@0.0/manual/index.html#:~:text=Unity Physics is a deterministic,Havok Physics team at Microsoft.
but getting an initial release out and having it being mature and battle tested are different things
I have a question about Photon! How can I give a random player a tag, example: 5 players are in the lobby, when the game starts, one player has the tag "1" and the others have the tag "other"
You can just make use of IsMine instead for nearly every case where that would make sense.
@weak plinth
Do tutorials for Pun2 and Mirror is a good starting point for most first timers. @west pine
@weak plinth If you haven't done the Getting Started tutorial for Pun2, you won't have a clue about any of this.
You really will want to start on the PhotonEngine.com site and read docs. You won't guess how to network using any of the available libraries. They all require you to read their docs.
@jade glacier what about unity's multiplayer
How do I fix that?? The scenes are not changing in the System... Using Photon PUN
How are you changing scenes? Typically you do that though PhotonNetwork, and you initiate it on the Master Client, and that replicates out.
this?
That seems like the right code, so probably more an issue of the timing of when that gets called. Not sure. I don't have much personal experience with scene changes in networking or Photon. I typically avoid them.
is there anyother way just to restart the same scene btw?
I honestly don't use scenes in Unity enough to really suggest a best practice. Hopefully someone else here does.
@weak plinth
Did you already figure it out?
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex)
Good morning folks! Intermediate-level programmer looking to make my first networked game. I have a "digital tcg" idea in mind and I think that is probably some simpler networked code since it is turn based. I actually found a series from the develoeprs of "Socket Weaver" of doing a GoFish style card game over network. Do any pros out there think that is overkill or have even eard of SW? Or is it better to just do my own API calls to a C# library running on cloud or something to control the state of game?
I liked the fact that this SW SDK helps manage lobby and matchmaking logic.
@somber drum Only MasterClient is restarting :/ not all other clients
Is that not something you can rpc to the clients? @weak plinth
I'm not aware of a built in function to reload scenes for all clients, you're using photon? Maybe there is something in the doc
@thin cloud I found myself really good with python asyncio on server side, and C# .NET libraries for Sockets (for any kind of projects )
Im trying to make a networking engine that loads assetpacks from a server so that each server can basically run their own game. The problem is I need to sandbox client side code to prevent servers from being malicious. Is there any way to sandbox C# code in assetpacks? Or am I stuck with forcing everybody into an interpreted scripting language?
#archived-code-general might be able to help
Ok, thanks
Could look into AppDomains but this sounds very complicated and is largely solved out-of-the-box with scripting languages running in VMs such as lua
hey guys im using photon bolt for my multiplayer fps game but when I rotate my gun the other players gun moves too is there anyway to fix this?
4 sure but not without code lmao
@weak plinth You are probably not checking if the one recieving the input is the local player or not
Only the local player should recieve the input
i tried that but it just broke the script
it just stopped working
i used if (!entity.IsOwner) return;
and it just stopped working
then maybe you didnt give it ownership
how do i do that?
does it say in its network identity that its owned by local player or something?
it says id is not set
@weak plinth i really dont know i used different netwroking tools
i dont know really, but first you must make sure entity.IsOwner is true only for local players entity/character
some unet, photon pun and mirror
but i dont remember what i did on those neither, only the general idea stayed with me, not the api
oh ok