#archived-networking
1 messages · Page 116 of 1
We figured it out (I think), you need to call Dispose on the list in OnDestroy. No idea why this doesn't happen automatically
Regarding your second point, that is fixed in pre 5 Fixed a bug where NetworkList.contains value was inverted (#1363)
oh cool, thanks for that
as for call dispose ondestroy, is that in the networklist script in packages or wherever we use a networklist?
wherever you use a network list I think, hopefully someone can confirm this for me
we're doing
if (_networkedAttributes != null)
{
_networkedAttributes.Dispose();
}
_networkedAttributes is a NetworkList
I don't know why NetworkList doesn't use a finalizer to clean up the memory on its own
thanks!
Is this netcode stuff only or are mirror questions ok here?
All networking related questions are welcome here
what's up gamers, I'm having an issue where the ingame playertag for my multiplayer isn't seen by other users. I have a script called gettext, it gets the text from the input. I also have a scrip attached to the player called settext, it basically just takes the input and replaces the TMP child's text with the inputted text. It works on the client's end but for some reason on the server end, / other player's dont see the updated text.
here's the code'https://pastebin.pl/view/ca3c4b41
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
I don’t understand how a server hosts a game. On Playfab you set up a .exe (a build of your game) to execute when a lobby is opened on your dedicated server. But how does the server know what scene to open, know not to load in a player for the server, get past your loading screen/main menu, know to ignore everything related to a player/requiring input
Or does your server build of the game need to be completely different then your client build
what server ? try photon, it's super ez
i want to add teams to my game in photon pun 2 can anyone help??
please
my project has stopped due to that
cause i cant find a tutorial
make a team manager
Then on join the match, add them to the manager, on leave, remove
Not that hard, only question is what to do when teams are full or you want load balancing
Tutorials will only get you so far, you will need to take over from there.
Are you sending the string to the server and then setting it?
In mirror, you’d send a command, then a rpc back to set it.
Hey, what would be the best networking solution for chat? I'm thinking about php & sql but any others options like sockets are welcome. Also it have to works on Android devices.
A simple server with tcp sockets will be fine for that
Photon is a networking solution. I’m talking about using a dedicated server to host your game
Libraries like mirror, netcode and photon fusion deal with exactly that. With them you can separate client/server/shared code and manage connection send targeted- or broadcast-messages, sync variables, handle state interpolation/consistency and overall take care of authority all in the same .exe for Server and Clients.
Hello!
Do you have any rds diagram for multi choise question system?
how should I model?
Hi, How could I sync a list of game objects? Does it work if I use SyncList <>? I use Mirror for networking
Hey, I'm having a problem with (probably) NetworkTransform. It seems to prevent joining players from moving, but if I join from the editor and disable it, i can normally move the gameobject. Then if i reenable that component, it snaps back to it's original position. Any ideas what might be wrong with this?
If I host in the editor and join from the build, i can freely move the player gameobject, but the client cannot move on it's own. I think I should mention I'm using Unity Netcode.
Edit: I've just checked whether it's not the fault of my player controller, but it seems that input are working as they should, it's just position not changing at all.
Can you share the code you are using to move the player?
Well, since player is a car, i just apply motor torque to the wheels and it works.
leftWheelsC[0].motorTorque = m_verticalInput * actualMotorForce;
rightWheelsC[0].motorTorque = m_verticalInput * actualMotorForce;```
It does work and it does move the player if I disable the NetworkTransform and change Rigidbody back to non-kinetic (because NetworkRigidbody sets it to kinetic).
Other than that, player's position isn't modified in any way
My guess is you are modifying the position on the client. But NetworkTransform syncs the positions server authoritatively to all clients and overwrites it again. If that's the case you can import the ClientNetworkTransform from the package manager page of netcode and use that instead of NetworkTransform
Hi, which is the best way to update clients' rotation in Netcode? I have a joystick and I'd like to apply the rotation of the joystick on the right to the client
This works. Thanks!
Let me ask - if my thinking is correct and if i understand it correctly, it's better to use ClientNetworkTransform for clientside stuff like player, while NetworkTransform might work better for serverside stuff (like for example moving map elements), right?
So I am working with Mirror and have written a script to deal with the local player’s viewmodel and playermodel, the issue is that it does not work and Idk why, here is the code:
public GameObject Playermodel;
public GameObject Viewmodel;
void OnClientConnect()
{
if (isLocalPlayer)
{
Playermodel.SetActive(false);
Viewmodel.SetActive(true);
}
else
{
Playermodel.SetActive(true);
Viewmodel.SetActive(false);
}
}
Uhh
Of course that’s not gonna work.
Going from the snippet you provided, you don’t inherit from NetworkBehaviour, and OnClientConnect etc are required overrides.
That, and OnClientConnect is probably the wrong thing to use, I’d use OnStartClient because that is called once the client player object is actually initialised
Okay, thanks, anything else?
That should work…?
Aight thanks
photon not showing tmp text of other users
i instantiate the tmp right after spawning the player
and it works on the client end but other users cant see it
im attempting to make a simple 1 on 1 turn based game and the current plan is just to get 2 people able to join on any order
is there anyway of knowing whether there is a host, and if not then start hosting, otherwise connecting as client?
such that if 2 people join a game nomatter what order they join theyll be able to connect and game will start
id rather not have a seperate Server running
the current rough setup of the code is like this atm
Hey !
How to Synchronize My world for all players using mirror in unity
Please do not cross-post. I have removed your other posts.
Mirror also has a discord you can ask in which is pinned to this channel
?!
using netcode, how can i check if connection's established for a client? wanna do error message if could not connect and proceed to lobby if its ok
Google Firebase is great for such apps
it's old version though, don't know if still applies
also there's some callback on connect and disconnect, but can't check for sure (didn't find it in the latest docs after a quick search)
Thanx
I came here before and needed help, I did the changes but it’s still not working so I think the issue is with the setting up or I did something wrong here.
I have the script attached to the player, and put the playermodel and viewmodel into their gameobject places.
using UnityEngine;
namespace Mirror
{
public class PMandWMfixer : NetworkBehaviour
{
public GameObject Playermodel;
public GameObject Viewmodel;
void OnStartClient()
{
if (isLocalPlayer)
{
Playermodel.SetActive(false);
Viewmodel.SetActive(true);
}
else
{
Playermodel.SetActive(true);
Viewmodel.SetActive(false);
}
}
}
}
how do i create my own udp system for an fps not using mirror or any other programs like that then integrating it into steam
as coburn said use the OnStartClient override
I have haven’t I?
What-
No I changed it to that
Forgot to change it in the reference but when I did it still failed
that's still not overriding the base class's virtual method...
here's an example
public override void OnStartClient()
{
}
Oh, ok, thanks
You cannot integrate your own solution into Steam’s transport, if you’re going to use SteamWorks, then you need to use their own infrastructure.
Although I hope you know what you’re doing, because you are about to enter the raw API world where you have no luxuries of having an high level API handling stuff for you. You better know what you’re doing and understand a large amount of networking or you will fail.
Also, I would NOT recommend making your own UDP implementation unless you know what you’re doing as well. There will be a lot of topics that are complicated and have many ways to solve the issue. You’re much better off looking at existing implementations like Litenet, etc if you’re going to use a system that utilises raw UDP.
Making your own UDP implementation for development and research purposes? Cool. But you better test the shit out of it when you even want to think about putting it so the public can test it
Take this with a grain of salt, keep the warning in the back of your head, be prepared for the uphill challenges of making your own UDP system.
@ocean cradle , don't define your code inside the Mirror Namespace as it will cause lots of confusion later.
Instead, do something like this:
using UnityEngine;
using Mirror;
namespace OiranStudio.BoobaShooter {
public class SomeCharacterScript : NetworkBehaviour {
// ...
}
}
If you use ASM Defintions, which you should learn how to use as they help keep your code seperated than one stupidly huge assembly when using Mono, then this becomes very useful
using Mirror; tells the C# compiler that you are referring the Mirror namespace, and hence "give access to the goods contained within"
while namespace Mirror means your code lives inside the Mirror namespace. Allows you to access Mirror components very easily, but causes complications.
I always recommend, at bare minimum, having a namespace of MyGame or some project name (or codename, for example the one above)
Heyyy lovely people!
I want to trigger a event inside of unity from a website. How can I achieve this?
I can’t find no step by step practical method on this on the Internet.
For example if I press a button on my website, I want my cube to be destroyed in unity.
yo is this a glitch or something because I imported PUN 2 into my project but when I look at my project packages Pun 2 is no where to be found
@sullen basalt any compile errors?
No that’s the wierd thing bc it’s showing errors in visual studios but not affecting the game
Photon 2 is not under packages in the inspector. It’s usually installed via UnityPackage, not a Package from a repository via UPM.
I don’t think this is the right channel for that
All assets should now appear as packages in modern versions of Unity, no?
Yes and no, actual packages appear in your project folder inspector under Packages. assets, from the asset store, do not - they get imported into the project folder.
They show up in Package Manager, yes
Oh I see, misunderstood the topic.
All good
Oh shit, didn’t realise you were a mod
Now I feel bad for saying “no, wrong” 😛
The answer was good though 😄
hey im having trouble with photon multiplayer and im hoping someone could help me with it
heres the code https://gdl.space/ubamaxicuw.cs
i have two different issues. one is that i get the following error when player 2 joins in https://i.imgur.com/uCE0K1t.png
My second issue, and the weirdest one, is that when player 2 joins the game they destroy gameobjects and make references show up as missing. Basically in another script I create 50 humans and assign them houses and locations (also GOs) and set their parent to be an empty GO named "Humans". If I set humans to not destroy on load then when player 2 joins they will delete the references the people have to their homes and current locations. If I do allow humans to be destroyed on load then when player 2 joins they will destroy the empty humans parent and take all the humans along with it. Either 50 people go missing or they become homeless. Tragic. I've been stuck on this problem for days now so any help would be appreciated.
Ok thanks
Does anyone know all the pros and cons when it comes to "Photon (PUN 2)" and "Mirror", I see that Mirror is more optimized for full on MMOs but a lot more complex to maintain, and PUN 2 is a lot simpler to use but has very limited CCU (concurrent users).
PUN is non-server-authoritative aimed at max 16 friendly CCU and short uptime, which allows it to be simple. Mirror aims at being a general purpose netcode stack with server authority and able to represent close to everything you might need up to 200 CCU. However, anything above 16 CCU requires you to think hard what you are doing no matter what library/service you use. Mirror can also be used with shared authority. Neither is a solution fully capable of running a MMO out of the box.
Pretty spot on for a summary there Anikki
Although PUN charges for bandwidth and messages per second
if you exceed a limit per second, then you'll get lag or messages get dropped
I’d consider PUN a prototyping library/service at this point
PUN is a great choice if you need something in a hurry, but it is not ideal for an shooter or something like that. You could use PUN for a very basic VR chat thing with your friends
Mirror is focused towards MMO usages but it does support general workload. There's also Mirage that aims to be a "all round" solution that started as a Mirror fork.
Make that small scale mmo that still requires lots of custom extensions
No
Talking in general, mirror can do mmo because it doesn’t lock you into a particular way how state sync happens, you have source access and can implement custom messages
Ah yeah
no idea how stable it runs with 23h uptime and getting hammered with 200 ccu
yeah that's a good question
AFAIK the stress tests that Mirror has gone through haven't hit one day of activity
It would be a nice test to have a 24 hour stress test that has 200 headless clients doing stuff automated
Also they are tests and not an actually running mmo of relevant scale
Yep
The lead devs' weapon of choice for CCU tests is uMMORPG (probably since they program it too)
but even then, uMMORPG doesn't have all the features that players would use in a MMO (then again I don't play MMOs, but I know some MMOs have like 3 rows of hotkeys and spells/magic and buffs and debuffs etc)
Ideally you'd want to have a small world with a bunch of playable things and have 200 players moving around and doing stuff over 24 hours
that, to me, is less synthetic and more real-world testing
We charge per CCU and include plenty bandwidth. Charging for using more bandwidth usually helps getting the games to behave well, networking wise.
The MaxPlayers per room are low in PUN but we'd recommend using Fusion by now, anyways. This aims for up to 200 users in a fast paced FPS.
If you send more than the solution can send, then you end up with lag. If you send reliable, things get delayed. Unreliable might be lost, yes. That's the same everywhere.
hello @everyone new here can anyone help me with photon
im having an error saying duplicate photon id
hey guys, Im trying to figure out what networkengine i should use. As i read, Photon only can have 20 people in an application and mirror has a larger scale connection. is this true? My goal is to make matches with 4 players and have a server list, but mirror doesnt support server lists. what should i use?
or should i use steamnetworking?
How should the code look like when connecting to a steam lobby? I have troubles understanding what I need to do.. Tried several examples but doesent work anygood with my setup (Netcode + Steamworks)
It works fine creating a lobby and get the player object.
Heres the code that the client will run
void OnLobbyEntered(LobbyEnter_t result)
{
lobbyID = (CSteamID) result.m_ulSteamIDLobby;
if (result.m_EChatRoomEnterResponse == 1)
Debug.Log($"Successfully joined lobby {SteamMatchmaking.GetLobbyData((CSteamID) result.m_ulSteamIDLobby, "name")}!");
else
Debug.Log("Failed to join lobby.");
int playerCount = SteamMatchmaking.GetNumLobbyMembers((CSteamID) result.m_ulSteamIDLobby);
// Join host's game directly
if (playerCount > 1) {
var ownerSteamID = SteamMatchmaking.GetLobbyMemberByIndex((CSteamID) result.m_ulSteamIDLobby, 0);
hostSteamID = ownerSteamID;
StartClient();
Debug.Log("Starting client hosted by: " + hostSteamID);
}
}
public void StartClient()
{
if (NetworkManager.Singleton.IsHost)
{
Debug.Log("Hit Lobby Entered by server");
return;
}
NetworkManager.Singleton.OnClientConnectedCallback += ClientConnected;
NetworkManager.Singleton.OnClientDisconnectCallback += ClientDisconnected;
NetworkManager.Singleton.GetComponent<SteamNetworkingTransport>().ConnectToSteamID = hostSteamID.m_SteamID;
NetworkManager.Singleton.StartClient();
}
It get the room name and host id, but wont do anymore.
how to get client id of game object in netcode?
So it seems that the way I’m using playermodels and viewmodels is insufficient, everytime I test out the game through 2 players, one of my characters only show the viewmodel, with the other only shows the playermodel, to make matters worse, it stops my movement script as well
Nvm my movement script is the thing that does not work here
How can I assign the "Animator" variable of Netcode's NetworkAnimator from the inspector in a prefab? I can't do it and it gives me this error
Use a GetComponent call instead in a script @clear bridge
Just because a network library doesn’t support server lists shouldn’t mean you should discount it. I wrote NodeLS for that very reason, allowing for Classic Server browser API
PUN is quick to get started. Mirror is more tranditional server based networking stack, and requires some extra time and effort.
If you’re just doing teams of 4 then it really is a question of what stack you want to use, because 4 players is literally bugger all in the network side of things.
Just keep in mind that PUN will charge you for CCU, while Mirror is free.
ow i see
i dont have a budget, so pun will not work for me i guess. But why is it that 4 players in a match is a bugger?
What I meant by the bugger comment is that 4 player game would be pretty easy to do over the network
Depending how complex your code is
ow
In terms of PUN/Mirror stressing out
I mean, you wouldn’t use PUN for Battle Royale, for example. Mirror has done BR.
Anyway, Mirror is probably your best bet
okay, thank you so much! i've got a better sight of it now.
Good luck. Check out some of the examples that come with Mirror and take a gloss through the manual
Networking is hard, but Mirror aims to ease some of the pain
Ill try my best😃 . btw, did u mean nodejs instead of nodels?
it assigns the variable but i still get the error
NodeLS is Node List Server, which I wrote here: https://GitHub.com/SoftwareGuy/NodeListServer
ty
Thanks for the tip!
You’re welcome @upbeat wadi
Hmm, so where are you getting the error? Which function?
You could always wrap the animator stuff inside a null check
Which would squash the error
Oh wait
NetworkAnimator…
Okay so if you’re wanting to do that
Open a empty scene
Grab the prefab and drag it into the scene, then assign the network animator stuff, then zero out the XYZ position, select apply changes to prefab on the inspector, and then delete it from the scene view. That should make the changes stick.
ok, I'll try to do that
In the inspector, you can drag the object itself into a field iirc
It would then automatically grab the reference it needs afaik
it works, thanks
The code In using for my movement is breaking my game because, once more than 1 player joins the server, it freezes the players and the other scripts break too```using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Mirror;
namespace TFT.Controller
{
public class FirstPersonController : NetworkBehaviour
{
private float yaw = 0.0f, pitch = 0.0f;
private Rigidbody rb;
public float walkSpeed = 5.0f, sensitivity = 2.0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
rb = gameObject.GetComponent<Rigidbody>();
}
void Update()
{
if (!hasAuthority) { return; }
if (Input.GetKey(KeyCode.Space) && Physics.Raycast(rb.transform.position, Vector3.down, 1 + 0.001f))
rb.velocity = new Vector3(rb.velocity.x, 5.0f, rb.velocity.z);
Look();
if (Input.GetKey(KeyCode.Escape))
{
Cursor.lockState = CursorLockMode.None;
}
}
private void FixedUpdate()
{
if (!hasAuthority) { return; }
Movement();
}
void Look()
{
pitch -= Input.GetAxisRaw("Mouse Y") * sensitivity;
pitch = Mathf.Clamp(pitch, -90.0f, 90.0f);
yaw += Input.GetAxisRaw("Mouse X") * sensitivity;
Camera.main.transform.localRotation = Quaternion.Euler(pitch, yaw, 0);
}
void Movement()
{
Vector2 axis = new Vector2(Input.GetAxis("Vertical"), Input.GetAxis("Horizontal")) * walkSpeed;
Vector3 forward = new Vector3(-Camera.main.transform.right.z, 0.0f, Camera.main.transform.right.x);
Vector3 wishDirecton = (forward * axis.x + Camera.main.transform.right * axis.y + Vector3.up * rb.velocity.y);
rb.velocity = wishDirecton;
}
}
}
Protip, please use a paste in service like pastie or hastebin than huge code dumps, makes it lot easier to follow too 🙂
I do t see anything wrong with that tbh, you’re using hasAuthority and looks OK
How does it break? Error messages? Stack overflow?
Oh, alright I’ll keep that in mind, and it dosent say it, but basically when I tried to use 2 players in the server, the characters froze and the pervious code that made the playermodel and viewmodel split stopped working, with both not having their playermodels and only the guns.
I tried to check if it was a problem with the playermodel script or the movement script, and once I took the movement script off, the playermodel script started working again so I’m not sure
Chances are you had a race condition or something
But hmm
2 players as in 2 clients, or 2 players 1 client
Hello, can you help me? I want to convert json to object
This is the json file
and I have this error. what's the problem?
I mean 2 clients but I was using the same computer so I’m not sure
You probably need a wrapper class. For some reason, JsonUtility cannot handle JSON that only has one element, I remember I bashed my head against a brick wall with that
wrapper can be as easy as
public class JsonBubbleWrap {
public Whatever thatThing;
}
one element? there are some objects indexed by 0,1,2....
that is one big array.
Try that
ok, thanks
Otherwise IDK
Json can be a pain in the ass and also a blessing
See also: Newtonsoft's Json.NET
it didn't work
1,2,3.... are the names of the object?
mmm
that way works for arrays like that::
what kind of array is this... can anyone help? how to convert it to obj
Oh wait, 2 players 1 client
so basically couch co-op?
or you mean the editor and the built client?
Yeah that
dunno then
Pretty sure there'd be a tutorial out there for Movement + Mirror
I mean, I could write code that would work but eh
So I fixed it, very vague but I was able to find someone who showed me what to do, thanks
it gives me emppty string. why??
I've googled and they said something about certificate and root. Idk
Do i have to do something special when i connect a client
Player prefab creates fine when i start host, but start client wont create any player prefab,
Im using steam matchmaking
Hi all
Anyone have made/tried a game with large map size, networked? Say i use the Floating Origin Ultimate asset (which supports networked, but server side, unit position is still unchanged), what would be the limitation, or recommened network design?
Currently in my understanding, if i use a origin shifting client side, then the best case is to do fully peer2peer, client auth phys queries for every checks needed around that client
But.. what if i still aim for server auth? Is there really no hope?
It can be done... the question is how much time and effort do you want to put in to make it possible?
It depends on how much time/effort is needed hehe
What would you say is the best Networking solution so a Player can host a game and others able to join. Without the need of self hosting a server or manual Port Forwarding if thats possible 🙂
Hi, what does the NetworkAnimator component do in Unity Netcode? It synchronizes the entry animation of my characters, but when a clients starts walking (so the animation switches from idle to walking), the other clients can't see the new animation
Hey, what solution would you guys suggest for making a multiplayer browser game?
I went with mirror but then realized that you can't host a server on webgl build lol
should i actually just implement dedicated server or is there a way to make it work another way
i read somewhere that you webgl can never host, is that really true?
CAN ANYONE HELP ME FIND A WORKING CLASS THAT SENDS AND RECEIEVES DATA FROM A SERVER ON THE LOCAL HOST IN UNITY? (UDP)
you can if you use a relay server, but then youre still hosting a server somewhere at the end of the day
mirror + epic transport
unless you wanna pay, then use photon
I ran into this same problem with a previous project. I ended up using godot because it supported webrtc out of the box
So webgl builds could host and be clients
Using MLAPI - running a deep profile on our game, we see that 35% of the frame time is being spent in BinaryFormater.Serialize, I believe this is in NetStatSerializer.cs. How do we get this cost down? We don't have much being sent over the wire continuously so I didn't think we were serializing all that much.
but i wanna use unity
what do you suggest
yup
This dosent even have to do with code my Unity broke as my mirror wasn’t working so I reinstalled all of it twice and now unity is having a heart attack with the Mirror code, not even mine
And it’s not even one issue it starts picking random lines of code in random scripts each time like it’s spin the wheel
You're going to need to try and integrate webrtc in that case
I am unsure about how to go about this
the reason you need a relay server for webgl games is because web browsers inherently can't directly speak to other web browsers
this is what web rtc solves
That's the tools package which collects data for the netcode profiler.
I see. How do I disable that?
I'm not sure (besides running in release mode or uninstalling the tools package). I'll ask
tHANKS
Currently the only way seems to be to uninstall the com.unity.netcode.tools package in the package manager.
Ah unfortunate. It's not a toggle. Thanks for the help
If i want to connect to a created steam lobby, what method do i use?
I have this one now for joining a SteamID
m_Transport.ConnectToSteamID = "125454847874545";
Steam lobby id and steam user id is different
lobby is a separate steamworks feature. What you'd do is:
- Use steamworks to connect everyone to a lobby
- Decide on a host player in that lobby and share that with the other players in the lobby
- Use the transport to have all players connect to that id.
Hm, my translation from English to Swedish didnt go well there :D, Im using your sample project, I have implemented so when i Create a lobby, it appears on the lobby list, and Steamworks sends Callback "LobbyEnter_t"
In the public list, all steam lobby id's are shown, I click on an option - what do I do from there to connect?
Though i guess this is a steamworks question
You call ISteamMatchmaking.JoinLobby and after that you call ISteamMatchmaking.GetLobbyOwner to get the SteamID of the owner then you connect to that id.
Thanks I'll try that
Please help, I want to spawn a gameobject in unity using the instantiator from the multiplayer engine photon, but it doesn't work.
How do i send vector3 position with Netcode? I need to convert bytes?
How do I use different GameObjects at the same time?
I’m using mirror to create a tf2 style game with some alternating weapons, the issue here is that once I place a script on the gun inside of the Player prefab, it dosent work
It does work on the actual player itself, but for the type of system I want to use it’s just not a method I can use
You make a shimmy
should the NetworkAnimator component in Netcode automatically show the client's animation to the other clients?
The player itself should have a weapon manager, while the child objects are hooked up
Okay, so should I send out a message from the player to the gun once the fire button is pressed?
You’d have a script on the gun that acts like a remote, so when you fire, it calls the guns script to do visual effects, etc
Most FPS kits that do networking have this sort of setup
That’s the issue, I tried that and it straight up didn’t respond, no matter what I changed about it
What?
Explain what you did
Here’s a break down
WeaponManager
- knows the current weapon via reference
- knows the current weapon stats, ammo, etc
- listens for client input
- when triggered, it sends a shoot command to the server and locally plays animations and visual effects
WeaponRemote
- handles spawning of visual effects when triggered
- handles sounds, animation, etc
So what I understand is that the remote is mounted onto the gun and handles the looks while the weapon manager looks for the actual input.
This is fine but what if I need to change the weapon model as well? It’s definitely possible but the way I script is pretty messy, and it’s gonna get really long and tedious if I want to add a lot of weapon varieties
Just have the weapon remote take care of that
Make some sort of attachments system that toggles the meshes on and off
Again, you honestly should plan for this before you start programming it, otherwise you may encounter the snowball effect
aka Feature Creep
Alternatively, start with the absolute basics
Then grow from there
What’s the snowball effect?
Feature Creep
You do one feature, but then you’re like what if… and before you know it you have 20 features instead of just one
Oh ok, I understand that
One more issue that is vital to the game if that’s not a bother
So I need a way to make the menu and map in different scenes, let me explain.
I’m using the basic network manager as a placeholder. One thing I hate about it is that the map and connection scene(The one with the network manager HUD) is the same. The issue with this is that if I want to inevitably, and very soon, add more maps, it’s not gonna be possible
Make the menu offline
For example, when you disconnect from my game, the game goes and cleans up stuff and takes you back to the menu.
Menu is offline
Wait but how does that load you into a new scene/map?
What do you mean?
When you connect to a mirror server it already loads the map the server is on
If I have more than 1 map I would need a system in which the client loads into a new scene, aka the map. Because if it’s gonna have different specialists I think I would need a separate unity scene which the client loads into to choose his character, and then join the map
If you are in a server and you call Mirror ServerChsngeScene then all clients are notified and they’ll change scene.
You’d find that a lot of the select operator stuff is actually an additive scene loaded into the current one
For example, the one off the top of my head that I know uses that is Genshin Impact
It actually loads an additive scene, turns off the world camera and related stuff, shows your characters, then when you leave that menu it resumes rendering the world
Alternatively, you can do what I do and send a custom Command to spawn your character as well as set them up with equipment etc
But that’s down the track
So what you’re saying is that I should just load in maps as prefabs and do it all in one scene?
Make the operator stuff as an additive scene and then toggle camera between world and operator select
Put the scene at like -1000
On the Y axis
I’m a bit confused on what you mean by “operator stuff”
Operator select or whatnot
Alternatively you could just have a UI menu
That has mugshots and you just get the user to pick the operator that way
There’s many ways of tackling this
So- I make a separate scene for the main menu, it’s offline and is not the actual server, and once the client connects to the server the scene changes to the actual server, with a room where you can pick your character/specialist, once chosen you vote a map, if a previous map was already there, it deletes that one and spawns in the new map which are just huge prefabs?
More or less… I could break it down further but I’m about to do a 40 minute drive so I’m outta time
Alright, I think I understand it, thanks for the help
I actually want to do a series of no bullshit topics like this, like how to spawn a object but with different things
Covering both Mirror and Mirage
Basically tidbits that can help others
Presented in a friendly and respectful manner
This completely fixed our issue by the way. Would be great if this was maybe integrated in a bit more visible way. Thanks for the help
can we change scene in photon..??
i have 3 scenes setup main menu room 1 and room 2
i managed to spawn the player to room 1 from main menu
to enter room 2 ive put up on trigger
but room 2 doesnt seem to work properly with multiplayer game
need some help with this
I think you should, you sound like someone who would do tutorials, and having a series like this could get you a lot of views

Just gotta make sure my script is short and sweet but covers the dot points enough.
Does anyone feel that Netcode for GameObjects is production ready? I know it's new but other than the boss demo there's no other examples or studios that I know are using it,.
I have a P2P networking solution, I need to update player position to other clients, but I dont want the my player to be affected by position change to server
Easiest solution to only update on other clients, not mine? My player is both server and client
Hey guys, did anyone manage to run a Server Build with Steam transport over a Linux Distribution? I get so weird errors which relates to steamclient.so, which doesn't appear on Windows.
Need help photon unity to switch between scenes
Hey, anyone have experience with photon fussion ?, specifically syncing animations with network mechanim. If you know a working example i can take it from there
not really even i am trying to do that
hope i find any solution
ill send a msg if i find a solution, hope u do the same ;D (currently it works on host only, client is not synced)
thank you so much
sure will
also @sterile vortex are u familiar with photon pun
no, sry. ive only worked with fussion so far
ohh ok no problem im having problem with scene changing
Hey all! I posted this over in the Mirror discord, but was curious if anyone here might have some input:
Good afternoon, fellow developers! I've been using Mirror to develop a simple platforming game over the past few months. Since the beginning of the new year, I've been stuck on the big problem of how do I handle physics in my networked game.
The core of my game has platforms that rise up and down. When attempting to get this to work out of the box with Mirror, due to the normal latency between server and client, and the natural desync of the platform positions as they move, the characters from the other clients will always float above platforms / rise through platforms. It seems that without implementing some form of Client Side Prediction + Lag Compensation + Server Reconciliation + etc... I can't achieve the desired results out of the box with Mirror.
So is everyone who has some physics related interactions in their game implementing some custom form of CSP? Or am I approaching this wrong / missing something. I know this is a industry wide problem that has no perfect solution. I'm just curious what everyone else's experience has been!
Through a lot of research I've found one example that applies CSP in Unity (by simulating a client / server setup) and one project that attempts to do so while also using Mirror.
It's been really frustrating because I've had to shift my entire focus into understanding CSP and all of its facets instead of being able to work on the actual gameplay. I would love to find and pay for a solution that has already been developed if possible.
Thanks so much for any feedback / advice (:
CSP is the way to go, if you want that built-in, your only option is Photon Fusion or Quantum afaik
Going to look into these right away!
maybe you can get away with a simple version of it
I've been working on adapting a c# version I found into mirror (networking package I'm using), but its been a hell of a job. While I've been learning a lot, I really want to get back to developing the actual game lol...
its maybe a bit too much if your focus is on making a game rather than a networking library
a basic implementation should not be that much work but a great one definitely is
Using Netcode for GameObjects - I have a prefab A which has another prefab B as a child. Both of these prefabs are network objects. When I instantiate and spawn A, do I need to manually spawn B as well?
Looks like the answer is yes - I feel like potentially this could be pushed down into the Spawn call itself rather than me having to do it
I'm making a multiplayer game that is currently connecting everyone, but not showing movement updates. I've serialized the vector and passed it server side, but it's not showing updates, just original locations.
Currently using Mirror
You may want to also mention which networking framework you're using
thanks for the tip!
iirc you are not supposed to nest network objects
Parents network objects to each other seem totally valid though?
it just seems weird conceptually
is there a way to send data using netcode for game objects
i cant find the docs for it
Is there a way to open ports in unity?
use a relay network @polar lagoon
This is quite a common concept in other networked games
Do you have a reference, I’m curious, I’ve always seen a net object as a world of its own. What patterns does that enable?
hi does anyone here knows on making multiplayer game through LAN or hotspot mobile
Does anyone know a strategy to remove shaders from a server build?
@sand pulsar I think thats what headless build is for
But it probably removes more than shaders
Yeah should be, it is a dedicated server build (Unity 2021, i guess headless build was the name on Unity 2020). As i searched for it, there are articles which describes that it is a bug, but didn't find a solution for that case!
The dedicated server build is really bad, it only strips a little and you still need to do a lot of manual stripping or use something like the Headless Builder asset
ah okay sad that dedicated server build has no chance to strip that away :/, but thanks
This thread is pretty good to know what it exactly does and what not
Hello I'm using Photon what is the best way to sync the map seed over the network ? Should I use a CustomProperties or a RPC ?
which photon product?
PUN2
well, you can do basically whatever there, if you had syncvariables i'd use that
I'm very new to Photon, do you have any resources to learn more about that ?
their website has lots of documentation
is there a specific reason why you selected PUN?
(just curious)
probably custom properties in the room since its data everyone needs to know that doesnt change
this is the only free photon product as far as I know
all except quantum have a free tier
I have a problem with the OnRoomPropertiesUpdate method. I use this to update a property:
public void StartGame()
{
System.Random rng = new System.Random();
// Generate random int between 0 and 100000
int seed = rng.Next(0, 100000);
customGameProperties["MapSeed"] = seed; PhotonNetwork.CurrentRoom.SetCustomProperties(customGameProperties);
}
public override void OnRoomPropertiesUpdate (ExitGames.Client.Photon.Hashtable propertiesThatChanged)
{
base.OnRoomPropertiesUpdate(propertiesThatChanged);
// MapSeed changed
if (propertiesThatChanged.ContainsKey("MapSeed"))
{
// Get the seed value
int seed = (int)propertiesThatChanged["MapSeed"];
Debug.Log("Game seed received: "+seed);
// Generate the map
map.GetComponent<Map>().Generate(seed);
}
}
The problem is that OnRoomPropertiesUpdate is only triggered on the master client which set the custom property. Why ?
Hi
I'm building a turn based multiplayer game. The game timer is the only part which is real time and needs to be somewhat synced between clients.
What do you guys think about using an ASP.net core app for a turn based game? The client will have to make time sync requests a few times each
second which will be done over UDP, when the request is processed on the server it compare the client state with the server state and if the client
is behind it will include a flag in the time response (also sent over UDP).
When the client receive the UDP packet it will check the flag and if it's behind it will request the new state via a normal HTTP call.
When a client make a move in game it will just post it over http as well.
So basically everything is done over http besides the time/state check which is done over UDP.
Polling over UDP is very cheap and I also get the stability and multithreaded performance of ASP.net without having to manage any connections.
Is this totally crazy? would there be any downsides I have missed?
Sorry for the long post.
UDP is unreliable and unordered, so that may cause issues if not handled by implementing a app-specific protocol on top of it
thank you for answering, yes I make sure that they execute in proper order and if some packets are dropped it's okey since the clients will continue to send packets every n (probably 250) ms
i'd not use ASP as a framework since its targeted at a wholly different use-case and locks you into MVC
I do agree that ASP feels a bit bloated but you can create pretty good rest apis in core without the whole MVC part
you should just grab a reliable udp implementation off of github and use that instead (KCP, ENET, etc..)
this
and do the server in net core
just get rid of that bloat
yeah I thought about that as well but than I have to make it multithreaded myself
you have to do that anyway
automatic multithreading only works when your app fits exactly into the frameworks mindset
if youre just making a turn based game im not sure how much benefit multithreading will give you
other than a bunch of headaches
i dont think the ASP multithreading will help you in any way
ASP have async IO processing which is pretty nice
its completely built for scaling parallel and independent CRUD requests
yeah, I did not mention it in the post above but I kind of need to run lots of matches (1v1 games) in the same process
so lots of IO from different clients
that's true, running a single threaded process for each CPU core might work as well
sounds like you would want to definitely do the threading yourself
Maybe. If it's IO heavy I'm not sure I would be able to make something more efficient than ASP
there is no secret black magic that makes ASP amazing at everything... if you build a solution that exactly fits your problem it'll be 100X more efficient/performant
just by not doing all the extra stuff that ASP does, and by allowing a structure that is optimal for your situation
so if you want "lots" of players concurrently, custom is the only way
that's true, a more specialized solution should perform better. Guess I have to think a bit more about it and weigh in the time cost as well.
Thanks for the answers!
Excuse me, I want to ask a question, is it possible to make mmorpg by only linking to mysql?
Hello, guys i cant add multiplayer to my game with netcode everything is works but sometimes i have error Object refference not set to instance to an object line 58
code:
async void Start()
{
// Initialize unity services
await UnityServices.InitializeAsync();
// Setup events listeners
SetupEvents();
// Unity Login
await SignInAnonymouslyAsync();
// Subscribe to NetworkManager events
NetworkManager.Singleton.OnClientConnectedCallback += ClientConnected;
}
#region Network events
private void ClientConnected(ulong id)
{
// Player with id connected to our session
Debug.Log("Connected player with id: " + id);
UpdateState?.Invoke("Player found!");
MatchFound?.Invoke();
}
#endregion
Is it possible on someway to add 2 classes to a class,
Like: public class MyScript : NetworkBehaviour : AnotherClass
no, only interfaces
So if i have a class, with an enum, how do I solve it to add this to my scripts?
Via composition, i.e. some variation of creating a field and giving it a reference to an instance of that other class ```cs
public class MyScript : MonoBehaviour {
private OtherClassWithEnum enumClass;
private void Awake() {
enumClass = new OtherClassWithEnum();
}
}
the canonical way in unity is to add that second class as another component on the same gameobject
```cs
[RequireComponent(typeof(OtherClassWithEnum))]
public class MyScript : MonoBehaviour {
private OtherClassWithEnum enumClass;
private void Awake() {
enumClass = GetComponent<OtherClassWithEnum>();
}
}
Thanks, I will save that solution!
Hey, I'm making my game quite modular in the sense that every enemy, projectile, wave etc is accessible and modifiable in XML form. The problem I'm currently encountering is I'm not sure how I can send all this deserialized XML data to a client when they connect. Any suggestions? ( using the new Unity Netcode for gameobjects)
depending on your game design they should already have it by having the build of your client, or get it by downloading a patch from some sort of web api or you send it in little chunks as needed over the netcode messaging system. generally this sort of thing should not even be required information on a client of your game provided it is a regular, server authoritative system where the simulation is handled entirely by the server. If its there for ui purposes, the web api things is probably most straight forward. You can make that part of your server, run a little HttpListener next to the regular netcode.
Yeah so, the client simulates everything themselves but the server tells the client where x will spawn and handles damage registration etc.
Currently the idea is that the server/host can just modify the XML in their directory to customise all the player weapons, the enemies that will spawn etc. The way I was thinking about obtaining that data on the client was to just download the server's XML configuration into a temp folder and then load it as normal.
Kinda late answer, but, just a wild guess
If the error is at one of the lines (idk which one is line 58) where you're doing ?.Something(), you could try using a proper null check instead.
I recently had an issue where ?. didn't work while != null did, and my IDE told me that i shouldn't use ?. for Unity Types, never had that issue before, never got that message before, but it did work afterwards 🤷♂️
?. bypasses the UnityEngine.Object lifetime checks (i.e. it doesn't check with the engine whether the object is still valid), the != operator is overloaded on unity types to handle that check automatically when comparing to null. you can also do if (someUnityObject) {} to check if its not-null and valid.
Oh, thx for the explanation! Now I don't only know that it's an 'issue', but also the reason behind it!
Personally, i don't like the if(someUnityObject){} and instead prefer if(someUnityObject != null){}, but very good to know the tech behind that stuff. I was kinda surprised when ?. didn't work, but your explanation makes totally sense, tyvm!
you can also do if (!this) {} to check if an object is currently being destroyed. Can help with avoiding those pesky exceptions when exiting playmode/unloading
I am updating these photos from image uris but when I join with another account (photon) photos are not changed
how can I fix that?
change it
i need help, my loading scene doesn't work to load the connected player to the lobby scene:
(my Lobby is named Lobby for anyone thinking it's because of that)
not sure about how PUN works or how high-level it is but usually the Master or Server and by extension some sort of networked scene manager (from the library) is supposed to handle the scene loading
It seems as if my connection to the server does not work, did i configure something wrong?
it does not seem to be able to connect to the master server
Hi, what would be a good way to implement cross platform multiplayer in my chess game?
Hello, I need some help about the Netcode Unity system, for the Networkvariable if anybody got some time ? (i'm a beginner in c# & unity)
I'm stuck since a while now and i don't find my answer, however, I think this is a basic thing I don't get yet because i'm French and sometime it's hard to properly understand tutorials/explanations
I need some help. I've prepared a player for a network game. It has been made into a prefab for players to spawn as they connect to the server. but each one isn't spawning with it's camera seen in the first attached photo. This is during runtime. The photo after that is of the prefab as it should spawn in. All I see is the Main camera view in the last photo. Any insight is greatly appreciated!
is followpoint a netobject?
yes
you cant do that, each net object has to be spawned on its own, there is also little point in making it a netobject since it already is part of one
Wow thanks! that got it semi working, now i just need to adjust my offset! thank you so much
yw
Hi, should I create a camera for each player?
why would you?
because I thought I was doing something wrong: the camera works well, but i get this error
this is the camera script
and this is how I set the target
thats usually all you need, hook up camera with the local player object... unless you have special needs
Camera doesn't work when joining multiplayer? (bottom right)
(my camera starts disabled and than I enable it when my player joins the game.
this is to avoid other player's cameras over-riding this one.)
not sure why this is happening
My camera is being overwritten and applied to each new player than joins. So if player 2 joins player 1's cam goes to player 2 if player 3 joins player 1 and 2's cam's jump to 3's
great fix to this, Thank you!!!
fixed: cinemachine brain was missing 🤦🏻♂️
lol
how did you set up your multiplayer cam?
originally? normal cams for each player and they all start disabled
yea i'm trying to solve the problem of overriding now
I enabled each one on their own (if clientid == localid) camera
okay
so this was my fix
Hi, so I'm looking for a multiplayer solution for a 4 player Coop game. What are your thoughts on PhotonNetwork? Thanks!
probably the most developed and supported right now.
netcode for gameobjects is good but only the myth luke is a top expert at this for now (who is active at discords)
Hmm, I know PhotonNetwork gives a free server which you can use. Do you happen to know if netcode provides servers or is it P2P?
p2p
thats not how it works
you are the one making the server / client through it
I mean, you get the option to choose.
Photon does not give you a free server
if you were expecting "free server" as in "free dedicated server instance", then no.
Using photon:
public override void OnPlayerLeftRoom(Player otherPlayer)
{
Debug.Log(otherPlayer.NickName + " left the room");
}
when other players [x] leaves the server, how can i make this log show up for others?
this doesnt seem to work.
on [x]ing out of the game, all the gameobjects gets cleaned up, so the game knows someone left.
i just dont know what its calling to get that information
could it be this specific callback is firing on the server / host only? If that's the case, I figure in pun RPC is probably the standard route right?
server => clients a message
its not firing at all, no matter who leaves
roomOptions.CleanupCacheOnLeave = true;
is cleaning up the game
i just wonder if i can access the "onleave" part
mm just guessing, if you have the right namespace and derived from MonoBehaviourPunCallbacks OnDisconnected(DisconnectCause cause) might be worth a shot.. if not I would ask in the official photon discord in case nobody gets to you here @sage valve
ondisconnect works fine, its just unexpected quits that crashes the game
I'm not sure what all goes into preparing for an unexpected quit in pun, though I'd imagine there would be some cleanup to do like objects belonging to said player being reset to some other owner
ofc I don't think they handle host migration out of the box so if it's the host quitting that makes sense.
- shouldn't be a crash though
it crashes because i have the player object stored in an array
the reason i want to check for "OnQuit" is because i need to clear that array
Hi I'm using Netcode and I'm trying to stream every player's animation to the other player... is there a way to do it fast? I could create many NetworkVariables but I don't know if a better way exists
so im making a multiplayer game and this happens
before one client would control both players
so i added ```void FixedUpdate()
{
// Update IsRunning from input.
IsRunning = canRun && Input.GetKey(runningKey);
if (view.IsMine)
{
// Get targetMovingSpeed.
float targetMovingSpeed = IsRunning ? runSpeed : speed;
if (speedOverrides.Count > 0)
{
targetMovingSpeed = speedOverridesspeedOverrides.Count - 1;
}
// Get targetVelocity from input.
Vector2 targetVelocity = new Vector2(Input.GetAxis("Horizontal") * targetMovingSpeed, Input.GetAxis("Vertical") * targetMovingSpeed);
// Apply movement.
rigidbody.velocity = transform.rotation * new Vector3(targetVelocity.x, rigidbody.velocity.y, targetVelocity.y);
}
}
}``` the View.isMine so i only control mine,but it controls the other client
try localplayer
wdym
kk
never heard of so i would say no,im using Photon if u mean by system for multiplayer
unet is unity multiplayer
gime a sec
k
if (this.LocalPlayer != null)
{
//your stuff
}
and im guessing errors cuz i need to add Unet
I suggest you checking the photon docs: https://doc.photonengine.com/en-us/realtime/current/getting-started/realtime-intro
Global cross platform multiplayer game backend as a service (SaaS, Cloud) for synchronous and asynchronous games and applications. SDKs are available for android, iOS, .NET., Mac OS, Unity 3D, Windows, Unreal Engine, HTML5 and others.
Have you refer the photon library?
using Photon.Realtime;
im using Photon.Pun so u can type a password for creating a room and when joining u type tht password
I know whats photon
:)
idk i just want to fix the fact tht one client is moving the other
using UnityEngine;
using Photon.Pun;
public class FirstPersonMovement : MonoBehaviour
{
public float speed = 5;
[Header("Running")]
public bool canRun = true;
public bool IsRunning { get; private set; }
public float runSpeed = 9;
public KeyCode runningKey = KeyCode.LeftShift;
PhotonView view;
Rigidbody rigidbody;
/// <summary> Functions to override movement speed. Will use the last added override. </summary>
public List<System.Func<float>> speedOverrides = new List<System.Func<float>>();
void Awake()
{
// Get the rigidbody on this.
rigidbody = GetComponent<Rigidbody>();
view = GetComponent<PhotonView>();
}
void FixedUpdate()
{
// Update IsRunning from input.
IsRunning = canRun && Input.GetKey(runningKey);
if (view.IsMine)
{
// Get targetMovingSpeed.
float targetMovingSpeed = IsRunning ? runSpeed : speed;
if (speedOverrides.Count > 0)
{
targetMovingSpeed = speedOverrides[speedOverrides.Count - 1]();
}
// Get targetVelocity from input.
Vector2 targetVelocity = new Vector2(Input.GetAxis("Horizontal") * targetMovingSpeed, Input.GetAxis("Vertical") * targetMovingSpeed);
// Apply movement.
rigidbody.velocity = transform.rotation * new Vector3(targetVelocity.x, rigidbody.velocity.y, targetVelocity.y);
}
}
}```
this is my player movment script
and in thr
i put the view.IsMine thingy so i can only control my player instead of both
at once
but now i need to figure out
why this is happening
well i showed u the error it gave me
right here
hippidy hoppity ur code for slopes is now my property
is to other clients see yours
wot?
it works?
using my script?
oh let me try
make sure to copy it all in discord inst show the last 47 lines
lool
y tried srry i have to go
anyone else?
how would you compare photon to Mirror? i know photon is a beast of a system to use but it can be rather expensive but also probably faster to setup than Mirror. I havent touched networking stuff in like a year or 2 been very busy but im trying to get back into actual game dev and have to decide between thhe 2 again
essentially im trying to have some light server auth for when players try to deal damage or collect loot to avoid hackers etc
Is there host migration for unity netcode?
Photon is a brand under which Exit Games (a company) offers a range of products & services dealing with realtime networking in games, Mirror is a particular library that implements an opinionated, high level api for doing video game networking. As such, they cannot be compared.
Hi, do you know any way to stream an int array using Netcode?
you probably want a custom serializer
but netcode also contains an example for a network list, you could use/build on that https://docs-multiplayer.unity3d.com/docs/api/Unity.Netcode.NetworkList-1
Event based NetworkVariable container for syncing Lists
Thank you, I need this to send to server client's animation params, do you think this is a good way to do it? I tried using NetworkAnimator but I can't make it work... Or maybe I didn't understand how it works
The “Best” way is a custom struct with custom serializer sent via custom message
but i’d only use that rather elaborate method when there is a need to be maximally efficient about the data bandwidth
hello. I am alyx from beanie co. we are looking for someone who can help us make the game multiplayer. as well as make a in browser lobby that can allow people to join player made games. and make a custom player. if you are wanting to help, please DM me. you will be given a custom worker only skin. thank you -alyx(creator of beanies)
This dosen’t have to do with code, more about mirror and setup.The player instantiates a bullet once the mouse button is pressed, and then it does show up, but only on the local client and not any other client who has not fired the bullet
To add to this: the bullet has it’s own network transform and network identity
im making a multiplayer 2d survival/sandbox game that uses terrain generation, and i have a script for creating and joining rooms, which is seperate from the script that generates the terrain. in the create and join rooms script, there is a create room function that generates a random seed and the terrain generation script uses that generated seed to generate the world. this works fine, but the problem is when someone joins the room, the seed defaults to 0. im not sure what the problem is, maybe its because i give a value for seed only in the create room function? if i try doing it in start then the player joining also generates a new seed. can someone help me?
saw an update to Mirror. Made the mistake of removing my copy, installing the plugin update. now OnStopLocalPlayer is gone
Ok so im making a multiplayer game and i have a lobby system where the host can change scene from lobby to game and each player can pick a skin in the lobby, how can i put the variable of the skin i chose in the lobby and carry over to the game scene?
Wondering if anybody can help me. So i am using Mirror for networking, and I have put my player Prefab into the network manager game object.
I have my Player prefab setup with NetworkIdentity and Network Transform (Script) from the mirror package. I also have a "Player Controller" script which moves my 2d object using transform.position and transform.rotate. I set these using a [Server] tagged function which is called from a [Command] tagged function which is called by my update method.
When i connect with my first client (this host + client) I am able to move my player around, but when i connect with my second client (just client) I get "Does not have authority" . Why would my second client not have authority over their game object instantiated by the network manager?
Think I had a similar problem, what I ended up doing was putting the isLocalPlayer more frequently at the beginning of the void Update() and stuff
Hmm the problem is more sending the transform to the server tho
I have the network transformer setup and when i try to change position or rotation thats when i get the error
Everything works if i dont try to change transform with a server tagged method through. I thought i was suppose to change the transform in a server tagged function
im trying to make it so that only the owner of the room can create the seed, but when i use this code the person joining the room also makes a seed. can anyone help?
public static ExitGames.Client.Photon.Hashtable addSeed = new ExitGames.Client.Photon.Hashtable();
public override void OnJoinedRoom()
{
PhotonNetwork.LoadLevel("Game");
if(PhotonNetwork.IsMasterClient)
{
PhotonNetwork.CurrentRoom.SetCustomProperties(addSeed);
}
}
private void Awake()
{
Instance = this;
addSeed.Add("seed", Random.Range(10000, -10000));
seedInputField.text = addSeed["seed"].ToString();
}
hi
how can i make a steam multiplayer game
without entering tax info
I imagine if you want to release on Steam, you will need to give them your tax information
does anyone know how to make all the players in the network use the same camera? when the first person makes a lobby and plays it theres a camera that has animation and when the second person joins i want that player to use the same cam and if the animation is part way through want it to show on all screens
So it seems the networkTransform is all i need, i don't need to set [server] tagged functions for the transform. That was my issue. I can just use the update/fixedupdate/lateupdate methods and call it a day.
With Photon, how would I add score to a player on collision? Does Photon have a scoring system?
It's not built-in right to PUN but in the UtilityScripts folder. Look into PunPlayerScores. It's a simple implementation and easy to modify.
just so i know i got networking correctly:
every player has the game running on his computer and its a different world for each player (a new client gets the game state from the server) and in run time the world does not automatically update. right?
if i disable an object for one or instantiate on a client, it will only be for a client, and when i move one i need to update the position myself? (or use network position)
Hi guys, im facing a problem with Photon Networking, can some one help me out? I need to destroy a scene object that is owned by the master client, apparently i couln't find a solution yet.
Have the master destroy it?
To make what I said simpler, I am using Mirror, and I have a button that instantiates an Object, the Object, however, is only showing up on the local player and it dosent change even when I put a network transform on it
Hi there, yes i want to destroy the game object as a client
you can't, the owner has to do it
yes the master can destroy it, when the master hits the enemy then the enemy's health syncing and the enemy dies after its health its 0, if the client hits the enemy, de enemies health is going down but only locally i guess as its not displaying on the master client
i tried to take the ownership but its not working for some reason,
how can i ask the master client to destroy the scene object as a client? i tried with RPC, and to take the ownership none was working
you have to somehow inform the master that the object should be despawned, you can use any sync features to achieve that, when the master receives the information to despawn, it should act on it
and how can i inform the master client
the same way you do any other communication in your game
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 had read all the documentation and i did the tutorial aswell but none of them are including what im looking for
can i get help with PUN 2 here? (the networking api)
You can ask your question here, yes.
this is my code, the player in my game rotates around the mouse and when i try to do it on multiplayer it snaps to one cursor i tried is.mine with no sucess
Seems like you are missing if (!isLocalPlayer) {return;} at the beginning of your voids, are you using NetworkBehaviour instead of monobehaviour?
im using monob
i will also try islocalplayer
oh wait im suposed to use networkb
sorry im a bit clumsy today
when i go network behaviour the whole code goes red
the update method doesnt
only start
Can some one please help me with Pun 2??
What are some of the best Unity networking solutions? I know of Mirror, and Photon, but I don't know of any other ones
unity's own Netcode is shaping up nicely
what are the disadvantages to using it though?
it's new and api will most likely change
it requires you to know what you are doing
that too
I see
its in preview, so may change, but is largely done, the last big change was from pre-release to 1.0
imo, mirror if you have no money and not alot of experience, photon if you are ready to spend money, if youre just making stuff to learn then maybe try making something from scratch using a reliable udp library
it really depends on what you are making
Photon PUN/Fusion/Quantum are also very opinionated
im making an fps game lol
wdym?
i would say photon fusion then
its the best to make an fps atm
if you have money tho
i think they have a free tier too tho
it's quantum that doesnt
it forces you to code your game a certain way, mirror is the same way
yeah I have used mirror in the past, I do agree. I don't know what word to use to describe it though
opinionated :D
oh 🤦♂️
🤣
Photon Fusion is perfect for up 64 players in a FPS/ARPG type game, and aimed squarely at the needs of that, if you want to deviate from what Fusion thinks is the best way to do something, it looses all its niceness
if youre making something like valorant or csgo, fusion all the way, you cant get any better than that, the guys at photon have some pretty cutting edge stuff backing their new libraries
In something like Netcode, nothing is nice unless you make it so, but you have all the power to create the world to your liking
yeah, it will be semi-similar
what is the difference between fusion and pun2 ?
fusion is server authoritative, efficient, modern, fully featured, has client side prediction with eventual consistency, supports rollback, supports a dedicated server PUN is old, less efficient and simple with few (if any) advanced features. Both build on Realtime & Photon Server, so in theory you can add whatever is missing yourself.
interesting
I will try out fusion if there is a free version
is there a good tutorial series for fusion btw?
it has documentation
alright thanks
mind that you will not be making much of a multiplayer game if you have to rely on tutorials, reading docs, some theory, trying things and testing is what its all about
yeah I know. Usually when I start learning a new software, or new package, I follow a tutorial, and then go off on my own
there is very little structured learning content available for game networking topics
alright
I used Steamworks.NET for my latest game.
Hello does anyone use mirror here and can help me?
I have a project with firebase real time database but when i test it i get this error, can someone help me please?
Here are my codes
using System.Collections.Generic;
using UnityEngine;
using Firebase;
using Firebase.Database;
using static Firebase.Extensions.TaskExtension;
public class DatabaseManager : MonoBehaviour
{
private string json;
private DatabaseReference dbReference;
void Start()
{
dbReference = FirebaseDatabase.DefaultInstance.RootReference;
UserScript newUser = new UserScript("Test","15");
json = JsonUtility.ToJson(newUser);
dbReference.Child("Farms").SetRawJsonValueAsync(json);
}
}```
public class UserScript
{
public string name;
public string age;
public UserScript(string name, string age)
{
this.name = name;
this.age = age;
}
}
In my network manager, i have a List of players. But when a player connects, their client doesn't seem to know about the list of players. It's just empty. Any ideas?
OnServerAddPlayer and OnServerDisconnect of my network manager adds and removes players from the list
Basically when i call List<ArenaPlayer> players = ((Connection)NetworkManager.singleton).players; on the client instances it's empty, where as on the hostclient it has all my players
clients are not supposed to know about all other connected players
Folks, any smart tips on how I can keep track of concurrent players on all my servers?
Hi all
We're looking into using quantum mainly for the uncheatable/economics relation, but i need help in deciding if it's worth the price, and what monetization style makes sense. Anyone got insight on games made with quantum vs their money strat?
If 1 ccu is 0.5$, 1 DAU can pay off that per day, assuming the type of game is not a long running one for every player, but session based/casual
I'm probably talking nonsense, someone please suggest a better way to break this down?
Hello
I am currently doing a fps multiplayer with Photon 2, is Unet easier to use or harder than photon?
PUN 2 is hard to beat in terms of "simple to use". We'd pitch Fusion for shooters, as it gets you much better results with only slightly more complexity...
Unet is properly outdated. If you wanted to, use Mirror, Unity Multiplayer Networking or any other solution. Checking out a few may make sense for you.
Thanks so much for your response, I will have a look at those options as well
Hey guys, can some one tell me how can I sync the Enemy's(scene object) health to the other player, if im the master client all works fine but when the client cause damage then its not displaying for master client however the health of the enemy reducing. some one?
Here is my server code
and client code
I do make sure that the ipaddress and port are the same
But the problem is the server never receive the connect of the client
The client script doesnt debug an error,so I think client's connected
Plz help! > <
plz help
hello guys how are you doing, I hope you are doing well. So I wanted to ask about something, I was following a tutorial about making character's profile which has his name, Exp, Level and his money. He also made the character's profile to be saved depending on the binary formatter which I don't like because then the players would be able to change their profile easily and gain money, exp and level ups. So what to do in that case or how to deal with it? do I continue using the binary formatter or what exactly! and thanks 🤗
I’m using Photon to make a co-op game and I need to instantiate the player in the game, but each person can be wearing different gear. How should I go about ensuring the player is instantiate with the specified gear. Just looking to be pointed in the right direction, having trouble wrapping my head around it, multiplayer wise.
Seems like this should be in advanced code unless there is networking going on.
yea whatever you end up using, dont use unet under any conditions, it's deprecated, and youll get laughed out of the room trying to ask for help with it
Anyone that can help with the above issue? Or maybe needs me to further elaborate?
Assuming your player is logged in beforehand, and that your prefab holds all the available gear objects in place but disabled, it's then just a matter of reading current equipped gear data and activate the right gameobject(s) when spawning, right ?
So as always, the answer is: implementation depends a lot from game to game
@patent fog that’s how I had planned to do it so I’m glad you brought that up. My thought though, is there a more efficient way? If I have say 10 helmets, 10 body armors, and 10 guns and I want the game to know which one each player selected. Is it more efficient just to say make a modular character like we think or is there another way that I’m not thinking of.
Just trying to think of the most efficient way to code it so it’s not a lot of repeated ugly code activating and deactivating objects
If you need a game to compare the style of character customization I’m talking about, it would be something like an RPG or a Shooter where you can customize your character with items you own outside of the actual match and then spawn in with those specified items
yeah I was thinking smthg like Fall Guys
There shouldnt be "a lot of repeated ugly code" though, shouldnt be afraid about that
and never forget, you never try to optimize early, only when performance hit occurs (and is demonstrated via profiling/monitoring)
Sounds good, I’ll give that a shot. Appreciate your help.
Anyone here could help about how to calculate server & database needs for asynchronous multiplayer?
(If this question is not related to this channel, let me know.)
Does anyone know if there is a way to check when all players have finished spawning?
or a way to get a list of all spawned Players?
(that networkManager Spawns on netcode)
If it doesn’t exist yet you can make one yourself since the server pretty much knows everything about spawning players. For knowing when a player is ready, either use a serverrpc (if the specific ready signal you need isn’t built in) or use the builtin ones (Scene events/Pending connections), or both. The NetworkManager has a list of all pending and connected clients and their player prefabs
Hello, I need some help: The custom property (bool)"dead" don't changes when I eat a player, but I get the Debug.Log("You ate a player"). So the bool dead is always false and never changes.
PUN 2
If I want two simultaneous scenes on the server at the same time (clients in different scene) do I just load level additive and offset it from the other scene on the server? Or is there a cleaner solution to run multiple on the server like separate worlds with own origin origin?
yes, you load all scenes on the server additively (maybe without art to save memory) and just load the scenes on clients that they have interest in. Additionally you would also only sync the part of the world simulation to the individual clients that they are interested in based on proximity or some other metric.
So you just shift them around the world so they aren't near each other then? Ok, thanks.
it would probably be easiest if all scenes have their objects placed such that they do not overlap
Are you saying when I make, say scene X , I should have that scene offset from the world origin inside the scene itself so when it's loaded additively it's offset already?
mind floating point accuracy when doing this though... usually at 8k+ units from the origin glitches start to show up
yeah I'm kind of worried about that but my levels are going to be small, I think it'll be okay
scenes itself have no offset, you would maybe place everything in that scene under a origin-node and place that node somewhere off the origin such that no objects from other scenes interfere with it
naturally, you can also stack vertically (if that helps)
I forgot they all have their prefabs too.
I already used rpcs for this, but i want to change it to this.
If i check for each client on the networkmanager, on their networkObject if it exists. Will it tell me if the player is spawned or not?
it will tell you that they are connected but wont contain any information about whether they are ready to participate in your particular game, as this state may depend on additional things like scene loading and menu choices.
yea, I was only looking for a way to check if they are all fully spawned in (if the prefab completely exists in the scene)
@austere yacht Do you know how can I Spawn the playerObject?
when I startHost(); It starts without spwaning the player (like i want) but than i want to tell the networkManager to spawn all players.
you need to spawn some object to represent a connected player, that object can be separate from the visible representation of the player when the game starts.
i see.
so i will first instantiate the player and than look for a function to connect it to the server
no
i mean after the client is connected
you can use the built-in autospawn and just disable the part of the object that you want invisible, or you have the server spawn additional objects for each player when they join/start a game and hook them up via network events
I looked up everywhere but can't find anything about the auto spawn
how can i access it?
but lets say i have a lobby scene and a game scene.
when my player joins the lobby i don't want this to auto spawn
when the player enters the game scene i want it to auto spawn. is that possible?
you might be confusing a few things here
that player prefab does not necessarily represent anything visual or interactive in the game
it is just a proxy object through which you can communicate with that particular client and connect it to other gameobjects/monobehaviours
what you do with that, what it means for your game, is totally up to you
then i am very confused, how do i spawn a player in the world?
by spawning a prefab just like any other
i have a gameObject player that has his camera, inputManager and all that stuff
really?
you dont spawn a camera and input manager with the player prefab
those are unique to the client application
and should not exist for each player in the game
only for the local one
exactly.
naturally you can spawn those with the player prefab and just disable them for non-local players... but thats also extra stuff that isn't used
i have been looking for ways to solve this problem with the input and camera for days.
the only solution i found was by disabling and enabling.
i wrote a script that tells the player to enable its own camera.
so when a player object spawns, have it hook up to whatever you need it to communicate with in the local instance of the game
what people usually do is write an extension to the network manager that handles this kind of setup
wait, if i enable something on clientSide (GameObject.setActive(true)) will it also enable it for the other players?
but its very project specific
only if you explicitly tell the server to sync it
I see.
by default, only the server can change things
but you can pretty much do whatever you want, sync-wise, just have to follow the rules
so wait, can a client instantiate its own player?
you can have all clients do their own thing and maybe just sync a single value... or have all objects sync everything
technically yes, but the framework prevents that
ok so just so i know i understand:
everyone runs their own game, and the networkManager only does what i tell it to sync through networkObjects and NetworkComponents?
yes
i see.
so when i spawn a new player, best way to do it is just for every client that joins:
instantiate(player, position, rotation)
[clientrpc] -> EnableOwnCameraAndInput()
?
network objects and components are an abstraction over plain messages sent between client & server that make it easier to model your game in a way you are familiar with
if you want the server to control that, yes, otherwise the client can just grab its local camera
what do you mean "the server to control that"
each client will control its own player if i do that. -> both players have network objects so they should sync?
normally you do something like this on the player object ```cs
public override void OnNetworkSpawn()
{
if (IsLocalPlayer)
InitCameraForLocalPlayer();
// ...
}
sure
where is it written?
thats part of NetworkComponentNetworkBehaviour
are we talking about netcode for gameobjects?
yes
ohhh networkBehavior
found it. this is the true solution i was looking for.
Thank you so much!!!!! @austere yacht
😄
you are such a king
@austere yacht i tried instantiating a networkObject and it only instantiated it for the local computer. it is connected to the server but only placed locally.
even after networkObject.Spawn() it did not do anything.
am i missing something?
you have to spawn it on the server
What? but than how do i link each GameObject to its controller?
i mean to its user
or just for (Every userId)
{ instantiate(object) + Networkmanager.Spawn(object)}
there are plenty of ways in unity that allow you to find the required components (.Find(), Singleton, static variables etc.). A player prefab is just like any other prefab that configures itself... if you don't like that approach you can hook into the NetworkManager.OnClientConnectedCallback from a component that is not spawned dynamically and carries the static references to the camera and other systems you may want to pass on to the local player object
Can anyone help with Mirror?
You should just ask your question
Yeah but nobody usually answers so I’m asking now to see if people ARE online so I don’t have to write a long paragraph every time
Okay, the issue is that I’m instantiating a projectile in my game, but it only shows up for the player who shot it. Now I registered the gameobject and used spawn instead of instantiate but it still didn’t work
This is becoming a very large issue and has been stopping all progress
I can’t just not take care of it at it is a main and very important to making the actual game
Hi
I get some errors
Failed to register task with System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Firebase.FirebaseException: An internal error has occurred. --- End of inner exception stack trace --- --- End of inner exception stack trace --- ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> Firebase.FirebaseException: An internal error has occurred. --- End of inner exception stack trace --- ---> (Inner Exception #0) Firebase.FirebaseException: An internal error has occurred.<--- <---
does anyone know how can I fix this?
i have done it
i used face punch and built the rest
You have to spawn it on the server for it to be replicated
I need some Photon Pun 2 advice. So I am using Edy's Car Physics and I am setting it up to work with pun. To try and avoid having to go through all the scripts and add the IsMine check on everywhere input is added which would take awhile, I am just grabbing all the player objects before the player connecting is instantiated, and im disabling all the scripts for control, damage, etc and the camera on any player that is not the player connecting, so when they connect they just see the other players positions but because all the scripts are disabled they would only be controlling themselves. However, this does not seem to be working, from what I can tell even with the scripts disabled on the other user, the two users are still controlling eachother. Does anyone have any other ideas?
Also when player 2 spawns in, player 1's location changes to the same location as player 2 and they both go flying lol.
Which has me confused a bit but im assuming it has to do with the scripts. I know the flying away from eachother is from rigidbodies and im gonna disable the other cars rigidbodies as well. But idk why 1's position changes to 2's position when 2 spawns in
Looks like its time to just go the manual route and add the check in the scripts lmao
for photon:
i need the masterclient to send rpc with target: newPlayer[i]
so to visualize: photonView.RPC("NewPlayerData", RpcTarget.newPlayer[i] , string newData)
this doesnt work.
Cool.
Drop the RpcTarget. There is a another overload that just takes in Player.
Again, it can be either Player or RpcTarget. You can get the Player's can be gotten through photonviews
I am having this issue with PUN 2 where if player 1 is already in room in game, and then player 2 joins the room, player 1 seems to be re-instantiated at the same time player 2 is.
so basically anytime a new client joins the room anyone in the room already shoots back to their spawns
How are you spawning things? Odds are it's something you wrote
Some of the car scripts could be reacting oddly or doing some kind of initialization that both clients react to
Perhaps change your player objects to be simple cubes to rule things out
I think its because im calling LoadLevel when OnJoinedRoom() is being called
so anytime someone joins, PhotonNetwork.LoadLevel(1) is being called and its reloading the scene for everyone maybe?
im testing to see if thats maybe it rn
Yea that seems to be the likely culprit
hmm so then what would be the appropriate way to call LoadLevel
I basically want users to be able to create a room
and just be in it
and people can join
without it like reloading everyone everytime someone joins haha
The current scene can be automatically synced through PUN, so PUN would make sure that the level is loaded
Only the masterclient should have to call that
Yeah I just tested it and I have that part right
{
if (PhotonNetwork.IsMasterClient)
{
PhotonNetwork.LoadLevel(1);
}
}```
not running on every join
so thats not issue
I think I may have fixed it tho
my unity is frozen tho 
lol yeah I need to pay more attention to when things are running I didnt think about the fact my gamemanager does not run on every player spawn
I needed to add some stuff onto a script on the player object itself
I am a little rusty lol its been like 2 years since ive used unity and c# lol
Maybe the recompile failed due to an error before that one or your file wasn’t saved since the suffix was added.
What can I do to fix this? I restarted Unity (and deleted csproj snl Libraries and obj folders)
Is this the only error you get?
yes
it's also the only script I have
https://docs-multiplayer.unity3d.com/docs/tutorials/helloworld/helloworldtwo I'm following the docs tutorial
Tutorial that explains adding scripts to objects, editor modes (Host Server and Client), basic player movement,Permissions and basic RPC use.
Using Unity 2021.2.13
Maybe reimport the script (via context menu)
Hmm.. should I install com.unity.entities (cuz i think you an enable full stack traces on there
)
still need help 🙂
How come sometimes you use customProperties and other times CustomProperties?
Haven’t done much with these since I’ve used Photon, so I’m gonna try my best to help
I think using SetCustomProperties may be better for you in the scenario since it tells Photon what to update
Man it is so hard setting up PUN with Edys Car Physics
Shit does not want to work lol
Players still controlling eachother even tho I added the IsMine check everywhere I could
I shoulda bought a car controller with pun 2 support already added lol
I’d buy another one but then this would be the second one I wasted money on so gonna try and get it working lol
Does anyone have any tips for getting it working? First I tried just disabling all scripts on other players when a player loads in, to try and avoid having to go through and edit all the scripts with ismine but that didn’t work, then I went through and edited the scripts with ismine and it still doesn’t work lol
I tried reaching out to the dev of edy's car physics to see if they had any tips but no response and all their websites are down, wish I saw that before purchasing.
Hoping someone here maybe knows some trick I can do to get it working, I was hoping disabling the scripts on other players would work lol
Using Netcode:
I find that the speed of the client is lower than the speed of the host. I'm using FixedUpdate with Time.fixedDeltaTime
Hi, do you have an idea on how to test a steam P2P based game on one computer or I have to at least have 2 to separate Steam account ?
Hmm
I was more thinking about having 2 steam accounts on the same computer but thanks for the repo did not know about it 😮
Might be very useful for the console messages and all this stuff
I do have 2 types of inputs -> effects on my game:
-
rotation = Quaternion.RotateTowards based on mousePosition (with rotationSpeed * Time.deltaTime);
Works Great For Host Player. Same Speed as Offline -
position = Vector3.MoveTowards(MoveTowards(basePosition, basePosition - _tfBase.right, moveSpeed * Time.deltaTime);
_Client Player Very Slow _
Both are Input, applied and sent to ServerRpc to apply to NetworkVariables in the same method
Hi guys, a C# tcp socket question here: when send data (object or serialized byte[]) with a message(define the data), what is the best way to send both of them?1: send two times one for message one for data. 2:pack the message into the byte[] using array combine at the begining of data or the end of the data,and break the array when receive it. 3:pack the message and object into a struct and serialize the struct.
4 use IList<ArraySegment<byte>>
Does anyone know how to send an integer made by the master client to all the other clients? I'm using Photon and I have the master select a random integer, but I need that integer passed onto the other clients
RPC with the appropriate RPCTarget option
can't figure out why my client movement and rotations are much slower than the host's
Tried that. Maybe I’m not setting it up right
Could you explain to me how I’d make an RPC send from the master to a regular client
I can pass int, string, bool...but I can't pass a class as a parameter in my RPC method call. I get an error when I pass in a class as parameter: Write Failed. Custom type not found.......
I upload the new game as a "beta" to one of my existing games on steam. Both player then play the beta version of that game.
Ok thanks
Send the game object or view instead
Hello. I am building a multiplayer game with a dedicated server and I have built the server as a console application. Is there any way to input into it?
You could scan a folder for new files and read them.
Also, you could send data via the network.
Don't ask to ask, just ask
@glass steeple ok sure
I want that my camera should follow the photon instantiated player
Cool
@glass steeple so do you have any idea about this
Do you have a script to follow a target?
Yes
Then set the player as the target
Are you sure your script is working?
Yes
Are you sure you are assigning the correct target?
Yes
How are you sure?
can i show you the script
You can try
Ok
GameObject target = PhotonNetwork.Instantiate(playertosp.name, spawnpoint.position, Quaternion.identity);
and here this.b = instplayer.target; //isntplayer is other script ehich takes the value of instatiated player
@glass steeple
I was following the Fusion 102 tutorial on the website, but I am getting an errors on the client's side, when I try to start the game
those are
[Fusion] ## Code Threw Exception ##
StartGameException: ServerInRoom
[Fusion] Failed Operation with Reason: ServerInRoom
so when my player rotates the gun and hands rotate with it, but this only syncs on the x axis. how would i make it so that it syncs on the y axis too, so that players can see each other looking up and down? i have a transform view on the player controller object which is the parent of the hands and the guns
When should I use Client-Prediction vs Client-authoritative?
My guess is that the first one is used for physics games?
You see client prediction in server authoritative games where server has the final say of the state, whereas client authoritative you are giving control over the game state to the client, more popular in physics games I would say.
I don't mess with physics intensive stuff but I would imagine it's because physics game are much heavy and erratic, input is not as predictable
Server authoritative if you need to worry about cheating or cannot trust the data a client sends for any other reason. Client authoritative if the state of an individual client has no negative effect on other clients or if you can trust all clients to be reliable and cooperative. Usually you end up with a mix of the two based on what the needs of the individual networked features are.
So it has nothing to do with physics?
if physics is non-deterministic (like unity physics) you can’t trust the individual client to produce the same outcome as another given the same inputs. So if physics results matter, you would want to sync those with a simulation on an authoritative server and use local physics only for high frequency prediction between ticks or for effects where minor differences don’t accrue enough to matter.
Hello guys, is there a way to synchronize a serverside tilemap with MLAPI?
Anyone ever made a random weapon/item spawner in Photon? Basically, a crate that a player would open and it would have a random item or items in it synced across for all players. I think I have a general idea of how I want to accomplish it, just wondering if anyone has so I could hear how they pulled it off.
Hi everyone,
Anyone know how can I sync all movements of the clients with the server?
I tried with clientrpc but no work, the client no move and no does anything
Best regards and thanks advanced
Do you need a separate build for the server and the client of your game? By the way, I'm referring to when your running dedicated servers (Playfab with Mirror Networking in my case). Based on MPSSamples provided by playfab it shows that it they used a seperate build for their client and server. Yet I've had a game work with just 1 build in my testing. If you need 2 seperate builds, why? What needs to be different in the server build and the client build
its mostly a choice, maybe you'll do a build with different flags and optimizations even if client & server are essentially the same app. Generally servers that are decoupled from an engine are easier/cheaper to host, scale and integrate with other services. If a game has very complex shared/sync state and many details tightly integrated with the engine (effects and fast paced action) the development benefits of client/server being the same app might outweigh the operations benefits and more limited scalability.
Mirror has its own discord...link is in the readme, asset store page, and a log msg when you enter play mode.
One project, two builds. Server build is a headless console app, typically stripped of UI, textures, sound, etc. that server doesn't need to care about so it take minimal resources on a PlayFab instance.
@verbal lodge - I am consistently getting a crash when I've put a templated unmanaged struct into a ClientRpc, I imagine the code gen is causing a crash somewhere. Should I file a bug report on the repo?
using photon:
when i connect 4 players its fine, but as soon as the 5th player joins, it says his buffer is full.
Got DisconnectMessage. Code: -11 Msg: "SendBufferFull". Debug Info: {}
when my players join, they all send data to the new player, including heavy stuff like their avatar png bytes.
is it possible to spread this "welcome package" out over time, or is there a better solution for this?
An example of a client-auth game is GTA V. If you've ever played that game, you'll know that there are cheaters in every single lobby, manipulating the game state to their desire
if a user says "I just killed every person in the lobby" (in the form of a packet) the server will say, "👌" and kill every player in the lobby
In client prediction, each client only sends their inputs to the server. So like "request to walk forward", "request to jump", attack, etc. They predict what they're going to do and then reconciliate the state with the server when the next packet comes in. The server runs the same simulation as the clients, in order to verify the game state.
In client-auth, the client tells the server "im at pos x,y, z, doing x" and the server will essentially just believe you without much accurate checking going on
If you could file a bug using the Unity bug reporter that would be great. As for fixing this for now if your struct implements the INetworkSerializable interface it should work and not crash anymore.
So would it be fine to just work with 1 build for now and then when I deploy the game for real, strip a server build down?
How do you guys handle canvases with networking? Are your canvases part of the scene, or part of the player prefab, or what?
it makes little sense to spawn a camera and UI for all players, it is usually a good idea to have only one per app.
Hmm, I think I can get away with one UI but I’ve been spawning camera with all my players
Main Camera is generally already in the scene and the local client uses that when the player object spawns. There may be a scene canvas that has its own game data and/or gets fed data from player objects, and player objects may have their own attached canvas for name over their heads and such.
But the you can’t have 2 players use the same main camera, can you?
In my case I’m using Cinemachine Virtual Camera. I only use 1 main camera but each player spawns with there own virtual camera
Idk if that changes anything
a camera is something that projects the game world onto a player's screen, if you do not have more than one set of eyeballs in front of that screen there is no point in ever spawning more than one main camera (unless you have a very innovative game concept that works differently than 99.9% of all games), you can keep your virtual cameras if you disable them while unused. Note that a virtual camera is something very different from an actual camera, so it makes a huge difference.
Ok so, let's say I'm using mirror, p2p, and need the client to send some data like, updated avatar, to a Firebase database
How can I validate that data
And make sure the database is not exploited
I just really don't understand networking
Or for example, if I wanna retrieve some data from another player, but they have a setting for privacy on, that needs to prevent me from accessing it
Where and how do I verify that
Another question is, how do I know my networking code is optimized?
The database would have twp profiles, containing for example the avatar and a bool for "allow others to see"
So I would need the client to request that data, the server would retrieve it from the database, and then check if the bool is true or false, and return it's value to the client
Right?
@late swallow Im thinking:
client -> backend -> database
client requests "get me the profile pic"
What is backend?
backend can respond with the image or return null
I was told I need to use a dedicated server if security is important
Yes, should backend just be a server then?
Using a server build?
unitys server build can host the game
and the realtime information related to your game, like positions, healths damages etc
You might also wanna have a http server
Thats connected to a private database
To handle your profile pictures, player stats

Inventories maybe
If I would do it, I'd host the backend in the cloud
I know how to use azure cloud services
I'd just go there and create a function app
And also find myself a database
Could be anything
Connect to your database via some secret key from the backend
I'm using Firebase rn
And you can have a nice backend app
Could I use AWS?
I think firebase can be both backend and the database
You should be able to do something there that will prevent users from seeing non-public profile pics
Yeah but I need some form of anticheat
And the host to not be able to run server commands
Meaning I need some dedicated server for the game logic
Not just for the database
Right?
Thats a way different topic though
Uhhhh
That would be your realtime game server
Imagine these two connections:
.
client -> game server (udp/tcp based realtime connections):
game states and inputs are exchanged here
client -> backend (http requests)
profile information, friendship requests, trade requests etc exchanged here
One issue I had witu Firebase is that
I never used firebase, i just know what it is vaguely
When making an account, people usually add another field in the client for verify password and I don't think that's a feature in Firebase
So I wouldn't know any firebase related details

