#archived-networking
1 messages · Page 1 of 1 (latest)
whats great?
i solved it btw
thats weird did u make sure to hide the camera and controller when the view wasnt yours?
I have created an XR project via MRTK that incorporates ML-Agents. I would like training of the agents to be done live when the project is built to the HoloLens. I need to build the project to the HoloLens and run the machine learning training via an external computer--how can I facilitate communication between the two to run ML training in real-time?
Do I need to run ML-Agents training on a headless server and build the project in server mode? Or do I have to look into C# socket scripting? I'm new to networking so any guidance is greatly appreciated. Thank you.
Pun question:
{
int viewId = gameObject.GetComponent<PhotonView>().ViewID;
float currentHp = _player.CurrentHP;
photonView.RPC("SendUIClaimNetworkHPBarMessage", RpcTarget.OthersBuffered, viewId, currentHp);
}
[PunRPC]
protected void SendUIClaimNetworkHPBarMessage(int viewId, float hp)
{
if (photonView.IsMine)
{
Debug.Log("Whats the view id: >>>>" + viewId);
_controller.SendUIClaimNetworkHpBarMessage(viewId, hp);
}
}```
My understanding is that I should get a call from everyone else and get THEIR viewId, but for some reason the only viewId I get is my own.
I'm looking to setup a game just for fun and am wondering if using SteamWorks would be a good idea, and how do I connect this to Unity? I'm currently using Mirror.
Don't know if I should use Steamworks.net or FacePunch
Yeah it all worked fine its just like I said the hosts character was frozen on the non hosts screen.
hmm
r u using pun2 or something newer
?
when someone gets the chance I keep getting thies 2 errors
Error CS0115 'ConnectToServer.OnConnectedToMaster()': no suitable method found to override
Error CS0115 'ConnectToServer.OnJoinedLobby()': no suitable method found to override
eventhough in the vidio i watched it works fine and i followed the steps up until this point where i stopped
btw its in stem 4 of https://www.youtube.com/watch?v=93SkbMpWCGo
edit i forgor to change MonoBehaviour to MonoBehaviourPunCallbacks
I started working with Unity's mirror plugin and the networking features today and I am having trouble figuring out how to destroy objects server side
i know its probably a fairly simple process but i can find very little information on how to do it succesfully
I think so
Asset:
EXIT GAMES
PUN 2 - FREE
And I have it linked to a pun server, using photon views and transform views to photon network instantiate prefabs from the resources folder, and I made sure to disable the other players camera but it still doesn't work both ways
Do you think getting Pun 1 would help?
i follow this tutorial https://www.youtube.com/watch?v=kld9sINMLGw and i done everything it dont work idk why mu playerlistitem dont spawn
In this video I will be showing you how to display members who join your lobby. I will show you how to make this modular so no matter how many people join your lobby will look neat and nice. I will also go over how to display steam usernames and profile pictures and how to get it all setup so no matter who joins and leaves it works. Finally I wi...
Can someone help me with netcode for gameobjects how ownership of the player object works
I'm working on player movement when I build and run to test I launch host in editor and client on the build and the client doesn't have ownership of it's spawned player object.
The host has ownership of its playerobject and can move around probably just because it the server tho
I have tried to assign ownership via clientid but dint seem to work I don't know what am doing wrong lol
noo bro, its so outdated
but i would recommend photon fusion or quantum (i just dont know them)
but they are new so try em
is it not possible to send parameters to a serverside void?
im trying this simple script but keep getting the object reference not set to an instance of an object error
it lets me convert the gameobject's name to a string and print that but not just get the name from teh gameobject itself
i finally got it to work 🥲
trying to use the new netcode library, does NetworkList<T> actually work? it doesn't seem to trigger change event on client
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Could anyone help with my Multiplayer issue trying to get movement to work my code has the host move and sync transform but the client on the built game cant move dont know what im doing wrong
It is your just looking at the logs of the client
It’s in the logs of the server since it’s a command
im having touble following this video and the comments arnt much help https://youtu.be/y69wBS13wwA?t=1085
here is the code i have with the error as a comment on the line that the error apears at https://hst.sh/eqifugegap.cs
Xsolla: https://xsolla.pro/Blackthornprod_PN
PART 2: https://www.youtube.com/watch?v=D28Drg9MCi4&t=1s
In this unity tutorial we will use Photon 2 and the C# programming language to create a multiplayer lobby system!
This is a fundamental part of any multiplayer game project. The lobby enables players to connect to a server, cre...
I am trying to code an item in unity mirror, so that when it is picked up, its transform is changed to match the player's
this works fine for the host client
but no matter what I do, the other client's item will not change transform on the server
I have tried everythign for two days now, I think I narrowed teh issue down the being that on the host client, the item is marked as isServer, which it is not on the other client, how do I change this?
I guess teh better question is, server authority sucks, this is a game Im sharing amongst friends so i could care less about handling cheating, how do I switch a game to client authority?
(photon pun) if anyone wants to help me please hit me up in the dms, its a lot of typing work to exactly explain what i want. if someone has some spare time and can help me, please. its about destroying objects, switching cameras, and raycast. (more complicated than this but ok)
and i just cant get it to work damnit
will the netcode documentation on the unity website still work for 2D?
yes, most of it
haha
i think im gonna follow this
video
because my brain doesnt process most info unless its being told to me
@naive rapids have you tried checking the mirror discord, I believe this question has occurred a few times
Which one of these services is better for multiplayer?
Netcode, Fishnet, Photon Fusion, Mirro, etc.
Neither, they're all made for multiplayer and do so successfully.
Your job is to research the pros and cons of each and make an informed decision.
don’t worry i fixed it
thanks though, i didn’t know there was a mirror discord
Google it
Hi everyone,
I would like to ask you what networking solution do you suggest to a game which has
- players as hosts (no dedicated server)
- rts-like gameplay (2-4 players per room)
- game rooms to join
(In terms of architecture, its almost like Warcraft 3)
What I found is Mirror or Photon Quantum would be the best options, but i dont have a lot of infos on Quantum. On the other hand, Mirror would require additional solutions for lobbies/rooms, and I am not sure about the performance
whats a good free multiplayer network for an fps shooter?
Nothing is free. Free to try, sure. Photon and Mirror are popular options.
I’m looking into networking at the moment, take a look at the EPIC solutions. They provide a suite of free tools (lobby, relay etc) https://dev.epicgames.com/en-US/services
isnt it only for UE?
i just want to make it when
u create a room
if its not a private one
it appears on the servers list
using photon
I'm using Netcode for gameobjects - we got Exception: Server Scene Handle (-422) already exist! Happened during scene load of EmptyWorld with Client Handle (-450). Any idea what this could be? We were using a built version of the game
Made a few tutorial videos for Fish Networking and Visual Scripting. The exact same concepts apply to C# scripts so it should be easy to get started either way. I will be making a few dozen videos so check the playlist if interested. Thanks!
Getting started with Fish Networking in Unity Visual Scripting.
Goal of this video is to get people up and running with the basics of Fish Networking. More videos will follow showing more specific examples of how to network multiplayer games effectively.
Scripts mentioned in video
https://github.com/WelfareCheckVS/FishNetworking/tree/main
...
does anyone know how to change Unity Transport IP Address and Port during runtime? I'm using Netcode for Gameobjects
https://i.imgur.com/6Z43TRA.png
nvm got it, needed namespace "using Unity.Netcode.Transports.UTP" , then NetworkManager.GetComponent<UnityTransport>().ConnectionData.Address="someString";
Hello !
I have a question
i'm using Unity Netcode for Gameobject and i'm trying to disconnect my client.
Basically; it's giving me this error :
NullReferenceException: Before using the library you should call Init() and do not forget to call Shutdown() afterwards
I searched on google, and it's telling me to use this :
Networktransport.Init();
Now the problem, is, as you can see in the screen : I do not have this function.
I'm heritating from NetworkBehaviour in my script, not Monobehaviour.
Would someone know how to fix that please ?
Someone told me I had to get an instance of Network Transport but can't figure out how
I'm sorry, I'm pretty new at networking. Thank you ! :)
It’s referenced by the network manager but to disconnect your client you don’t need to access the transport. You’d just call shutdown/disconnect on the NetworkManager, the same for connecting and startup. It should init the transport for you. Usually you need to only deal with the transport for setting up things specific to its implementation, remote address and port.
It's what I'm doing basically
I'm starting the client at the start
And disconnect it when I want to later
But it's giving me this error
can you post relevant code for it?
Alterntatively you can try to not call StartClient() immediately when starting the game but instead wait a second to give the library time to initialize
Sorry I was eating
Here it is :)
It's long so I couldn't send it in a discord message i'm sorry
use a paste site
Does anyone know the optimal way to use Netcode for LAN multiplayer?
I've only used Photon in the past and it was server-based, so I am a little disoriented with the new documentation and how to use it. I think I need to use the Unity Relay services, but I'm not sure if that's the right direction.
You don’t need relay for LAN
Oh, I see. For reference, I was following this tutorial https://docs-multiplayer.unity3d.com/netcode/current/learn/dilmer/dilmer-video/index.html and me and my friend couldn't connect to each other without the Relay for some reason, that's why I got confused.
This section aims to collate a series of Multiplayer Unity Networking tutorial videos that teach various concepts of the new Unity Official Multiplayer solution Netcode for GameObjects, all made by Dilmer Valecillos. Learn more about Dilmer Valecillos and his Youtube channel and don't forget to click the subscribe button.
how would i go along making a code based lobby system ?
How do you guys manage your ccu tests? Is there any reliable way of doing it autonomously(without humans)?
most times people just do a public stress test
Fair.. thanks 🙂
- create headless client just for that and run thousands of them.
- capture what tpc connection your game sends, create script on java, phyton or anywhere else which dupolicates the same TPC packages and sent alot of them. depends on game, transport and etc.
200 player cap fast paced udp-based shooter, nothing extraordinary in numbers I'll do more research with the above info provided appreciate it^^
for 200 headless clients will be enough. and it is a bit easier to make. you will need to create fake controllers but thats about it.
yeah, it's really just testing the aoi across the map and seeing how it all goes down in concentrated numbers.. way more freedom than organizing public tests. Sounds easier than I thought
anyone experience with photon dedicated server?
I did research it was something with fusion
What is the actual question?
does anybody here work with netcode for gameobjects?
Im trying to access the connected clients so i can sync the data for all clients but I get an error saying that connected clients can only be used on the server. Anybody know how to fix this? Using IsServer does not allow the clients to send the data which is what I want.
Sounds like a misunderstanding how sync works in netcode
You need to send the data to the server and have it then send the data to all interested clients. This is done via Server/ClientRPCs or custom messages with custom handlers.
Yeah.. I'm kinda confused about how that even works. For example now I want to have a scoring system which is two players that move around and touch a ball and if the ball becomes the color of the player he starts gaining points. However I cant figure it out. I have two network variables player1color and player2color and they are compared to the ball color to see who is controlling it right now. I think my logic is completely wrong right?
its hard to say, one thing i'd do is abstract this notion of "a player controlling the object" and not use the netcode directly do do that.
but to explain how exactly is tedious and wont help you, i'd recommend reading the netcode docs in their entirety (they aren't that long) until you fundamentally understand how stuff is supposed to be done, and from there it is somewhat obvious how these kinds of systems are implemented
okay thank you for your input!
does anyone know how to destroy an object on collision using photon as the client
You can call PhotonNetwork.Destroy(go) on one of the clients. In best case, the client which currently controls the object, will do the Destroy.
how can I make this work on other players over the network. right now it only works on monsters or other players on a local build.
caster.combat.DealDamageAt(candidate,
caster.combat.damage + damage.Get(skillLevel),
stunChance.Get(skillLevel),
stunTime.Get(skillLevel));
Heya, quick question, how is shooting usually handled in online shooters? They wouldn't be client side cuz cheating and stuff but most shooter seem too accurate to me to not be clientsided, is there some trick to that?
yes, there are a bunch of "tricks" to it, you can get the primer on all of those here: https://www.gabrielgambetta.com/client-side-prediction-server-reconciliation.html
you can also have a look at Photon Fusion and Quantum for specific, opinionated ways to implement them
you can put 0.0.0.0 in there to accept all incoming requests, localhost only responds to 127.0.0.1
{
// candidates hashset to be 100% sure that we don't apply an area skill
// to a candidate twice. this could happen if the candidate has more
// than one collider (which it often has).
HashSet<Entity> candidates = new HashSet<Entity>();
// find all entities of same type in castRange around the caster
int hits = Physics.OverlapSphereNonAlloc(caster.transform.position, castRange.Get(skillLevel), hitsBuffer
);
for (int i = 0; i < hits; ++i)
{
Collider co = hitsBuffer[i];
Entity candidate = co.GetComponentInParent<Entity>();
if (candidate != null &&
candidate.health.current > 0 && // can't buff dead people
candidate.GetType() == caster.target.GetType()) // only on same type
{
candidates.Add(candidate);
}
}
// apply to all candidates
foreach (Entity candidate in candidates)
{
if (candidate != null)
{
// add buff or replace if already in there
candidate.skills.AddOrRefreshBuff(new Buff(this, skillLevel));
// add buff or replace if already in there
// deal damage directly with base damage + skill damage
caster.combat.DealDamageAt(candidate,
caster.combat.damage + damage.Get(skillLevel),
stunChance.Get(skillLevel),
stunTime.Get(skillLevel));
// show effect on target
SpawnEffect(caster, candidate);
}
}
}``` I have this code but it doesn't work on players, only monsters. any ideas why?
nvm I think I just use mirror instead
anyone got any advice?
Use debugger to step through it.
and debug. log in your line to check your current action
you you mean like only able to trigger on enemy well player hit enemy? if that it mind be something with naming for example tag = enemy will only run this script
cause seem was network gameobject won't work cause even object will be spawn from server object id you need to let the project to know where your object id was at
this only happens on login with a remote server, not server and play
does anybody know hot to check ms ping on all clients through netcode for gameobjects?
@zinc marten Not familiar with netcode particularly
But I believe you should be able to have a "round trip time"
That you can access like you access a network time
Allright, I made it work
I think I wasn't waiting long enough for the first msg to arrive
And I wasn't using a correct clumsy expression
Any recommandation for a good ressource to start learning how Multiplyer works ?
gafferongames.com is often suggested for this question here @mild shell
Looks like a plaace to start 🙂 thaank you
np
what has a steeper learning curve, photon or mirror?
how can i use different player prefabs for people on different teams?
idk if it should suppost to be here, but I have a question about the google Authenticator function.
How do you get this pop up to sign in with google after clicking a button?
Every other youtuber makes an e-mail login and register theirself, but not like this.
This might not be the right channel, but is there anyway to make network variables changeable in the inspector?
this is using the most update netcode for gameobjects btw
movement only shows on 1 of my clients for some reason, i already have the Networking Transform on the player prafab and the spawning and everything works, except the fact that u can only see movement on one of the clients
thoughts?
can someone please help me
@thick valley are you sending the inputs to the server, or are you moving directly on the client?
Oh I completely moved to photon it’s 1000x easier lol
Mirror is so much more confusing
Can someone help me fix this? this script gets the server time from playfab (in utc) the coverts to my local time zone (est) , then displays that in the scene.. Everything works fine on pc in the editor but when i build for internal tesing on google play and download to my phone it does not work
my script
https://pastebin.com/PXGe6ybf
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Question if i wanna put my game build out from webGL to my own website how ya? using mirror
That's a little vague, sorry.
No movement at all? Does that mean you can't even control your local character? If so, check your input control scripts. They should be accepting input for one character.
This is covered in some detail in the PUN Basics Tutorial, so maybe it helps reading that once more?!
Hey, I have a problem with NetworkVariable. I am using a NetworkVariable<FixedString32Bytes> and it looks like the game throws this error:
Exception: Type Unity.Collections.FixedString32Bytes is not serializable - it must implement either INetworkSerializable or ISerializeByMemcpy
This error appears on the host side when a client connects, but host itself has no error like that happening. I am using FixedString32Bytes for player nickname, so if there is a better way to handle this, please enlighten me.
EDIT: Fixed, turns out I was just using a wrong version of Netcode. A rookie mistake.
when someone can help, can someone tell me how to make my player invisible to me in first person but still visible to others
ive tried puting my player in a layer not seen by the first person camera but i cant see others and they cant see me when were in firsty person
if(IsClient && IsOwner)
{
GetComponent<MeshRenderer>().enabled = false;
}
@fringe pasture this should work if you put it in the start method or something
ok ill try it
i couldent get to work the way i wanted but i found a new way, thanks anyways
np
when someone gets a chance when ever i click the menu button i have it gits rid of the player but it dosent load the menu and leaves me on the lobby scene this is in my player controller
my code
public void Menu()
{
if (view.IsMine)
{
PhotonNetwork.LeaveRoom();
}
}
public override void OnLeftRoom()
{
PhotonNetwork.LoadLevel("MenuM");
}
is there a way to call a clientRpc only on the localplayer in netcode for gameobjects? I know I can probably run a (isOwner) check inside the rpc function but im trying to avoid that
It’s described in the docs https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/message-system/clientrpc
A ClientRpc can be invoked by the server to be executed on a client.
thankyou, I did find it after a bit. I have one more question, I can't seem to get my networklist values from client side, is this intended? I try to run .count on client even as a clientrpc and consistently 0. when running .count on server side it returns the actual count though.
Yea it's common for servers to not broadcast that information.
can you help me out with this case, I have a solution but just trying to make sure it's the best.
Lets say I have a networklist<Vector3> called occupiedPositions.
whenever a new player joins the game, I make a local copy of those positions to a List<Vector3> localOccupiedPositions.
the way I do this is by running a
CloneOccupiedPositionsToLocalServerRpc()
{
foreach(Vector3 pos in occupiedPositions)
{
AddToLocalListClientRpc(Vector3 pos);
}
}
AddToLocalListClientRpc(Vector3 pos)
{
localOccupiedPositions.Add(pos);
}
i tried passing a list of vector3s to my client rpc first but doesn't seem to like it, I get the following error:
Don't know how to serialize NetworkList1. RPC parameter types must either implement INetworkSerializeByMemcpy or INetworkSerializable. If this type is external and you are sure its memory layout makes it serializable by memcpy, you can replace Unity.Netcode.NetworkList1<UnityEngine.Vector3> with ForceNetworkSerializeByMemcpy1<Unity.Netcode.NetworkList1<UnityEngine.Vector3>>, or you can create extension methods for FastBufferReader.ReadValueSafe(this FastBufferReader, out Unity.Netcode.NetworkList1<UnityEngine.Vector3>) and FastBufferWriter.WriteValueSafe(this FastBufferWriter, in Unity.Netcode.NetworkList1<UnityEngine.Vector3>) to define serialization for this type
I tried passing both List<Vector3> and networkList<Vector3> basically get the same error for both, right now it works fine as long as i pass one by one
CloneOccupiedPositionsToLocalServerRpc()
{
foreach(Vector3 pos in occupiedPositions)
{
AddToLocalListClientRpc(Vector3 pos);
}
}
AddToLocalListClientRpc(Vector3 pos)
{
localOccupiedPositions.Add(pos);
}
reformated my code
I don't know if this would cause that error, but you do need [ServerRpc] and [ClientRpc] in front of the methods respectively
for sure, i left it out of the code, i got it working, im just wondering if theres a better way to clone a networklist to a local list
public struct NetListVector3 : INetworkSerializable
{
public List<Vector3> list;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
for(int i = 0; i < list.Count; i++)
{
Vector3 value = list[i];
serializer.SerializeValue(ref value);
}
}
}
this will probably be better
@crisp quest
Appreciate it!
ive been trying to find a way to make push to talk with photon voice but i couldent find much, anyone know a good tutorial to get some sort of push to talk set up?
I am trying to send a file containing level data from Unity to my (currently local) flask server. Can anybody point me to the right direction? The main problem is interpreting the data that is arriving at my server.
levelData = request.data.decode("utf-8")
does not work.
file = request.file
tells me there is no file.
Ok I got it. This is the C#-part of the script that converts my data to a wwwform:
WWWForm form = new WWWForm(); form.AddField("name", in_levelData.name); form.AddField("data", in_levelData.text);
and this is how I interpret it on the other end (flask):
levelForm = request.form levelName = levelForm.get('name') levelData = levelForm.get('data')
Its always the same. You fiddle around for 60 minutes without progress, then ask on the discord only to solve it 5 minutes later. 😅
Short question, is there something like a Client Network Transform within the Netcode for Gameobjects package? Im having trouble letting my clients control themselves, host can move fine, scripts are accordingly disabled/deleted, so I'm wondering if I got the wrong network transform on the prefabs
Use NetworkTransform https://docs-multiplayer.unity3d.com/netcode/current/components/networktransform
and when moving the player you can move it offline however you want but use if (is owner https://docs-multiplayer.unity3d.com/netcode/current/api/Unity.Netcode.NetworkBehaviour#isowner)
to check if you are the one moving the player.
Thats exactly what I'm doing already and thats not my question at all xD I'm trying to figure out how to give a Client ownership of its network transform, shouldn't there be a "make Client have authority over this object" kind of setter?
when someone gets a chance, i use photon voice 2 and i am trying to make a voice indicator for my push to talk, this is my script (playerController)
void Update()
{
if (view.IsMine)
{
// push to talk
if (Input.GetKey(KeyCode.LeftShift))
{
recorder.TransmitEnabled = true;
micOn.SetActive(true);
micOff.SetActive(false);
}else
{
recorder.TransmitEnabled = false;
micOn.SetActive(false);
micOff.SetActive(true);
}
}
}
but it dosent change on the other players screen only on the players screen who holds shift, and i even gave both images their own photon view but still nothing
when someone can help, once i switch levels, the ui in the level i switched to stop working
are there any tutorials or blogs or anything on how to use mirror with webgl? cause I can't find anything
anyone know how to teleport all players each to a random x and z position when host clicks a start game button in photon multiplayer
i want to send camera with parameters. how can i do.Mirror
when someone gets the chance RPC is not affecting all players just the host who calls them. my script: http://pastie.org/p/0ASXpa1iEYOrTrpQhX8Aux
ok I kinda fixed it but now i just get this error RPC method 'ChangeBounds(Single, Single, Single)' not found on object with PhotonView 1001. Implement as non-static. Apply [PunRPC]. Components on children are not found. Return type must be void or IEnumerator (if you enable RunRpcCoroutines my new script: http://pastie.org/p/2Hw6Hw8vmqwdnTeDYjIFmD
anyone have a kick script
Hi can anyone help me with Photon Pun2?
Im using Photonview.IsMine to make sure all characters dont move at same time
It works for all except host
The host isnt able to move
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class PlayerMovement : MonoBehaviour
{
public PhotonView view;
public Rigidbody2D rb;
public float speed;
private void Update() {
if(view.IsMine){
float inputDirX = Input.GetAxisRaw("Horizontal");
float inputDirY = Input.GetAxisRaw("Vertical");
rb.velocity = new Vector2(speed * inputDirX, speed * inputDirY);
}
}
}
could anyone help?
when someone can help, I keep getting this long errors when i try to execute code in OnTriggerEnter. the errors: http://pastie.org/p/3fSltOAmeiB7kSK6CFB8wI the code: http://pastie.org/p/2udlLfMlqdCASdIReEwgnQ my only issue is that it does not destroy the flag.
L:18 you try to access a gameobject of a param that is already a gameobject ? That might be a typo, but even then, I'm pretty sure you can't send a gameobject through RPC
That's what the error message is trying to tell you : it can't serialize a gameobject to send through the network
I don't use PUN but I'd assume you're have to send via RPC the network id instead, then find the matching gameobject on the server side
@fringe pasture might be other ways to achieve that with PUN but that's the first naïve approach I'm thinking about
(Using Mirror) I need to set up a system using either proximity or collision, so that I can call events when two objects get close to each other. Does anyone have any recommendations for how to do that? 😦
You just described OnTriggerEnter and OnCollisionEnter callbacks
Are they what you are looking for?
Do those work with Mirror? 😮
That's Unity engine
I'll give those a try and see what I can do, thank you 🙂
Not sure if mirror have network-aware equivalent
You'd have to sync data yourself if need be
well how could i have a gameobject that gets destroyed when any player touches it
Like I said, I would pass the network ID instead of the GO in that RPC, and see if PUN provides a method to find GOs by id. Then you're back at the same point
There's also seem to be PhotonNetwork.Destroy() variant for networked objects
ok
Is using NetworkVariables a good idea of handling player inputs, or should I perhaps use RPCs? I was thinking about making it so the client can set the NetworkVariables (basically floats, for horizontal and vertical input), and then the server can read those and use them in the controller script (apply throttle, brake or turn). This way I can replace ClientNetworkTransform with NetworkTransform and have nice, realistic collisions
Looking at my case, I think it makes sense, but maybe someone more experienced can enlighten me
network variables are just wrappers around messages to make the more convenient, same as RPCs, the difference is just that network variables retain the state of the last message received and enable delta compression (only sending a network message when the value has changed). Based on that property (retained state vs ephemeral state) you decide which one suits your use case better. another point of view is that RPCs model events, variables model state. Naturally you can manually convert one into the other at any time. Whether you sync inputs with either one depends on how you receive inputs. On the server you will likely want to retain some sort of input state between ticks. @sharp pawn
Hm... I guess this confirms my idea. I read the input using ReadValue<float> when an input is performed. I think NetworkVariable will be better, since otherwise I'd have to send RPC like every frame (or, just send them on change, but then I think this is what NetworkVariable actually does)
I can try, we'll see how it works out.
when someone gets a chance how could i destroy all objects with a tag and have all players see it (i use photon for multiplayer)
It looks like NetworkVariable based player movement serverside works, but there are some problems. Aside from small issues like being unable to read speed from rigidbody (because it's kinematic), or the obvious (but small) input lag, there's a thing that on the client side, the vehicle seems to be moving in a very shaky way, as if the interpolation was having some problems. On the server side, as expected, the movement is smooth. Any idea on how to fix that?
Ok, apparently for this kind of issues there is client-side interpolation, like written here: https://docs-multiplayer.unity3d.com/netcode/current/learn/clientside_interpolation/index.html
Guide covering the basics of lag mitigation and a way to produce smooth gameplay.
How do i fix this??? (Using mirror) Ping me with answer
Hey all, general question if I may (I'm new to this stuff). I set up a client and server using riptide networking and a video guide on YouTube. The issue I'm having is that, while i can connect the client from my own network, I cannot connect from outside my network. The issue seems to be more with my computers personal ip address because even with port forwarding and adding exceptions to inbound and outbound ports I cannot connect. The issue seems weirder since I csnt even ping my own public ip in the cmd.
I believe I've set the server and client side connections correctly and its an issue internally with the PC or network settings.
My question with all that said, should I be okay to continue working on my project with the local connection working or should I fix the issue with my public ip first?
anyone here use lite net lib?
Is there any way to know when Netcode is about to reach the next tick?
any events I can subscribe to or something?
hey, I missed this, noted for the next time, thank you 🙂
Hello,
I was working on some api calls and wanted to keep a separate cs file for all the network based commands.
Sould I use a normal cs class or go for something like a singleton or something else
I want to make sync movement which means movement per tick.
Idk why but this doesn't guarantee me sync movement
Delay between clients 100-600 ms seems like server work for them individually
hi, so i'm making a multiplayer fps using steamworks. i made it so that when a player gets hit, the function DecreaseHealth() in this script https://gdl.space/apicuropud.cpp gets called. the amount is the damage variable of the gun. for some weird reason though, the health doesn't decrease, but the function gets called. does someone know what could be wrong with this?
The amount should get decreased on this instance of the script
But I see no code to broadcast this to any other clients or the server
There's a lot of Mirror tutorials online, some covering this topic
The Mirror does have a synchronisation section too I think
thanks
Is Netcode for Gameobjects "safe" to use in a commercial project? Thinking about a co-op type of game.
Hi all! Can someone point me in the right direction please? I'm trying to learn more about Netcode, almost all of the links are broken: https://docs-multiplayer.unity3d.com/netcode/current/about. I have tried looking for tutorials, the ones on YouTube are a year out of date and half the code they are using is deprecated. I'm considering using Mirror, but I would really rather use Unity's official networking solution.
the network manager wants a player object controller, i assume thats a script? does the object you drag in have that script?
There were a lot of changes between versions 0.1.0 (MLAPI) and the newer release 1.0.0 (Netcode for GameObjects), so tutorials for MLAPI might not match up 100%
They have a Discord pinned in this channel if you're not already in it, might be worth letting them know about that docs page
hey, does someone know what this error means?
FieldAccessException: Field 'UnityEngine.RaycastHit:m_Point' is inaccessible from method 'Mirror.GeneratedNetworkCode:_Write_UnityEngine.RaycastHit (Mirror.NetworkWriter,UnityEngine.RaycastHit)'
im making a command to run when a player gets hit, and give it the raycastHit thing, so it can detect which player was hit and decrease their health. for some reason i get this error tho and i have no idea what it means
nvm fixed it
@olive vessel thank you for the info!
hey i have trouble spawning a object as a client on the server. I watched a few tutorials but it does not work. It would be great if someone would help me out. ( Using unity with the mirror asset)
I am making a multiplayer game with my friend, and the game works when your on the same computer twice (ie one in the built project, and one in the unity editor). however, when i try to join a server created on my friends computer, it doesnt work
Has your friend done the necessary port forwarding
what is that? all i know is that he is using photon
Well it’s different for Photon PUN, should have said that in the initial message
You’re joining the same room?
yes same code, although when you click the join button nothing happens
we fixed it idk how tho
does anyone know how to fix this
nvm
I'm not sure if this goes in networking, but I want to use the player in the screen to do some stuff, but I can only put the prefab in the inspector? how can I overcome this in code
How are RPCs handled when there's many instances of one script (like, one per player object)? If I call a ClientRPC like firstScript.DoSomethingClientRPC() then will it fire only for that one given script? Or should I use ClientRpcSendParams to specify the client? Sounds obvious but I'm asking to make sure.
call the subscribed function from OnNetworkStart or whatever it is called in your library
Generally the default is that the RPC is fired on every remote instance unless otherwise specified by a parameter like ClientRpcSendParams.
Oh and multiple instances are generally separated by some sort of ID that is automatically handled by the networking library.
anyone know how i could teleport all players to a random piosition when the host hits start
The server/host can always move everyone. So you just need to set everyone‘s position in the server/host‘s NetworkStart() method (assuming you have Network transforms of some kind on all of them)
ok
this is in my player controller and it wont open the menu scene when i leave the room
public override void OnLeftRoom()
{
if (view.IsMine)
{
PhotonNetwork.LoadLevel("MenuM");
}
}
how would i fix this
(photon PUN2) how i could teleport all players to a random position when the host hits start, ive fiddled with my code all sorts of ways to no avail
I have a question, I made shooting, but it doesnt show up on the other client, the other client also cant shoot. I basicly shoot a raycast from the player and check if it has the PlayerTarget script i made
any help is appreciated
my code is:
This is my hotbar logic script: https://paste-bin.xyz/73949
this is my player movement script:
and this is my player target script
I doubt anyone is going to download your code just to see it, so you should put the hotbar logic in a paste site as well
Well, for one, you SetIsShooting to true at the top of the Shoot function, but then you set it to false at the bottom. This code runs instantaneously, so basically it's just as if you never set it to true in the first place...
Does the damage get dealt though? Only the visuals aren't working?
You want to use RPCs for stuff like this, not SyncVars
Remember, this only runs on the server since it has the [Command] attribute
So of course other players wouldn't see muzzleflashes
Only the host player can!
@still hare it shows the muzzle flash now but it doesnt register shooting each other
Well, look at what you do when you call Shoot. You try and Raycast, but you are doing it from the server's Camera.main, not the players.
Remember, anything tagged with the [Command] attribute will only execute on the server, and it will use any references from the server's scene.
It knows nothing about the client's scenes.
So every time a player shoots right now, it's trying to shoot from the host's camera position and direction.
Hi, does anyone know how to let enemy target player in multiplayer mode please?
I just know drag the prefab into target slot.
But once in multiplayer mode, player name will be change
eg: player connid=0 , player connid=1, etc....
Is it possible to use ServerRpc/ClientRpc without inheriting from NetworkBehaviour? I'm using Netcode for Gameobjects
Doubt it, pretty sure that's the point of a NetworkBehaviour
no
Have another class, you can call it something like "CommunicationObject"
Make it accessible from anywhere, like a singleton
And call the rpcs there instead
If you don't want to inherit from NetworkBehaviour, I assume you already have a plan to keep track of this particular gameobjects reference over the network
Yes, all my spawning is syncing is manually handled via RPC. I don't want to use scene management, so I disabled it but that means I can't have pre-existing NetworkObjects within my scene, meaning my GameManager that handles all RPCs cannot have a NetworkObject, meaning it can't send RPCs anymore....
I tried using the prefab/hash override but it doesn't work right. All it does it create a clone of my existing GameManager on game start, then disables all scripts on it.
You could just remove netcode and just build your own thing on top of ENet
Why are you trying so hard to remove all benefits and convenience of netcode?
I want to spawn Addressables in my Netcode project, but Netcode does not support Addressable spawning. So therefore all my spawning and syncing must be without NetworkObject components on them. Which is fine, I have the code for that, but my scenes are also Addressable, and Netcode SceneManagement doesn't work with Addressable scenes either. So I disable Scene Management, but turns out disabling SceneManagement throws errors if you have any pre-existing NetworkObjects in the scene. I have one pre-existing NetworkObject, and that is my GameManager, the sole GameObject that sends/receives RPCs. So if I remove NetworkObject from my GameManager, I can't use RPCs
Anyway, currently trying out Fishnet.
can anyone good with photon help me with getting a function to go off for master client? i have a maze type thing made by photon.instantiate and now im trying to destroy it all when game wins and make new maze
it works if master wins but if anyone else does it throws errors
my rpc wont work```
public void WinGame()
{
PhotonView pv = this.gameObject.GetComponent<PhotonView>();
//GameObject.Find("ThreeOfClubs").GetComponent<CreateThreeOfClubs>().DestroyGame();
pv.RPC("MasterDestroy", RpcTarget.MasterClient)); //player1 = PhotonView.Find(1001).gameObject;
}
[PunRPC]
void MasterDestroy()
{
if (!PhotonNetwork.IsMasterClient)
{
throw new InvalidOperationException($"Only master can perform this action");
}
DestroyGame();
}
public void DestroyGame()
{
GameObject[] walls;
walls = GameObject.FindGameObjectsWithTag("Wall");
foreach (GameObject wall in walls)
{
Destroy(wall);
}
Destroy(GameObject.Find("Win(Clone)"));
}```
im just trying to destroy and make a new maze when the game is won
Why games separated into room like battlefield or cod have different ping for different room? Even though they connect to the same server?
I'm trying to use unity's Relay solution on top of my Netcode for gameobjects. When I was using just Netcode everything was working fine. With Relay the host can join just fine but when the client joins with the relay code I get a lot of errors. Is there a way to find the specific gameobject with that hash? And also why would the host be able to join no problem but the client cant?
Hi, sorry for the longread 🙂
I have an app, which is easiest to describe as an imitation of a webpage: you have a vertical ScrollRect with a bunch of interactive elements (Image Gallery, Text, Video, etc), all of which are generated from an input from an external CMS. All this is done with regular Unity UI objects.
Now I'm trying to implement a "Group Mode" for this app, that is: a "Teacher" uses his device to interact with the content, and then all "Students" are seeing a duplication of what the Teacher is doing on their devices; sort of as screen mirroring (across the LAN network).
I see the implementation of this Group Mode in 2 ways:
The example of a ScrollRect on a Canvas:
In both Server and Client I would have the following:
|— Canvas
L—— ScrollRect
when the Server scrolls the ScrollRect, I need to send its normalizedPosition to all the Clients.
Option 1:
- make Canvas and ScrollRect NetworkObjects
- synchronize NetworkObjects:
-- on Server: AddListener toScrollRect.onValueChanged, which would update aNetworkVariable<Vector2> ScrollNetworkVariable
-- on Client, listen to that NetworkVariable changes:ScrollNetworkVariable.OnValueChanged += (..., Vector2 currentVector2) => { ScrollRect.normalizedPosition = currentVector2 }
problem:
this requires both Canvas and ScrollRect to be NetworkObjects, which means I need to Intantiate() and Spawn() them separately one by one, and then re-parent ScrollRect.transform.SetParent(Canvas.transform). This is already annoying, but also ScrollRect’s RectTransform gets broken in the process of re-parenting, because Unity UI changes its coordinates before I reparent. This principally sucks because there are no nested network objects in Unity, and therefore this Instantiation+reparenting needs to be done.
Option 2:
Canvas and ScrollRect stay just regular GameObjects.
I add some “Synchronization Manager”, which does the following:
ScrollRect.onValueChangedemits a Vector2EventSO calledOnServerScrollValueChanged- SynchronizationManager (is a NetworkObject) has a Vector2EventListener, which,
if (IsServer)— listens for theOnServerScrollValueChangedevent, and then updates SynchronizationManager’sNetworkVariable<Vector2> ScrollNetworkVariable - SynchronizationManager’s
if (IsClient)subscribes toScrollNetworkVariable.OnValueChanged, and when that changes, it emits a different event calledOnClientScrollValueChanged - Client’s ScrollRect has a Vector2EventListener, which listens for
OnClientScrollValueChanged, and then updates the Client’sScrollRect.normalizedPositionbased on the value it receives
problem:
I have this “retranslator/synchronizer” that creates a large chain of actions (Server ScrollRect Emits event —> SynchronizationManager (Server) Listens —> SynchronizationManager updates NetworkVariable —> SynchronizationManager (Client) Listens for NetworkVariable —> SynchronizationManager (Client) Emits event —> Client ScrollRect Listens)
I'll appreciate any comments on these 2 solutions, or a different one altogether, since I might be thinking wrong about this whole concept
hi, im going to start a game that uses networking with 2-4 players, should i use Photon pun or fishnet, or something else, thanks
bruh
I'm not sure if this is right section for this, but I want to be able to catch network connection issues in my application and bring up a popup to notify the user, but in the editor when ever i get a connection error unity closes. Has this happened to anyone, its only really started a few weeks back.
I was building the external api so I didn't have time to check it out anymore. As this haven't happened to me in the past i'm not fully sure where to start. I am using 2019.2.15f1 (I kept using this version because this is an old project that we're working on).
The built out project show the connection error, but inside the editor unity just closes.
I'm currently developing with Relay and Netcode for gameobjects (Both are unity's brand new multiplayer solution which came out of beta a few months back). I wouldn't recommend it that much especially if you are brand new at networking because the documentation is poor (Except if you want a very basic result) and there are next to none tutorials about it. Although it is an interesting solution and I can see it catching on in the next few years. @limber sparrow
K thanks
Question.
Hi guys, I'm create a multiplayer pacman.
is it possible to bring network netid to another gameobject transform? Coz that's not local which mean unable to drag and drop it.
My aim is to make ghost will detect the player once they join and chase them.
Welcome for any suggestion. Tqvm !!
Here is my code.
public class Ghost : NetworkBehaviour
{
private GameObject pacman { get; set; }
public Transform target;
public Transform target_Mirror;
private void Awake()
{
target_Mirror = Instantiate(pacman.player_Mirror);
}
}
public class Pacman : NetworkBehaviour
{
[SyncVar]
public Transform player;
public Transform player_Mirror;
private void Awake()
{
player_Mirror = GetComponent<Transform>();
}
}
I unable to perform the function in Ghost script (awake part)
I think I encountered a basic bug in netcode for gameobjects, if someone could confirm before I open an issue, as it's fairly straightforward:
- start Server
- start Client (connect to Server)
- Server: spawn Canvas ->
canvasInstance - Server: spawn Image ->
imageInstance - Server:
imageInstance.transform.SetParent(canvasInstance.transform, worldPositionStays: false)
result:
On Server: imageInstance is a child of canvasInstance with correct UI coordinates
On Client: imageInstance is a child of canvasInstance with incorrect UI coordinates, which would be result of worldPositionStays being set to true
Additionally, a warning is produced on both Server and Client:
Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues.
how to get header in response of UnityWebRequest using post API ?
quick question
who here know how to make an object disconnect you from the server then reload the server and make you join back the server? and when you grab the ball it doesn't end up disconnecting you
im using photon btw and unity vr
Does anyone know where to find good info comparing photon fusion netcode mirror and just all the possible multiplayer networking possibilities in Unity?
there is no way to make a meaningful comparison without looking at them through the lens of your specific project
so best make a list of what you need and check which of them support those things (stuff like server authority) so you can eliminate those that are incompatible with your goals and then read the docs and talk to the communities to see which one seems more fitting. You are gonna marry that library for the project, so you probably don't want second hand info and a casting show to find the right match.
Did you turn off Scene Management on the Network Manager? I had this exact issue, and turns out that if you disable Scene Management, your level cannot have any pre-existing Network Objects inside the level, the Network Objects must be spawned in manually after the level loads. This means any script that inherits from NetworkBehaviour is a NetworkObject
And I got that exact error message when the client tried to join the server with Scene Management off, except my hash was a different valu
Anyway, I gave up and used LiteNetLib instead. Much better. You need to manually spawn and sync stuff between server and client, but the code is much more light weight, and easy to use. I'll be honest though, the Documentation for LiteNetLib is kind of barebones... no real descriptions, just lists of commands
In Photon Unity Networking (aka PUN Legacy, now), is the best way to send inputs across to other players PunRPC? Or is there a better way.
Welp I dont know that could have worked. I fixed it after closing unity and deleting the projects Library folder. After reimporting the project it works perfectly..... Idk why but I aint complaining
I am trying to use steam credentials to log into mirror
I can get their user name with this command, auth.loginAccount = SteamFriends.GetPersonaName();
I was hoping SteamID would handle all account info, but I don't know how to utilize it
well I can get the steam id which stores all their credentials
but it's like this huge number
I dunno how to use it
Okay
Well if you were able to get there password that's a HUGE vulnerability for steam
Becuase then random people can get random passwords.
Oh
in ummorpg you can just make a username and password and it will create an account for you
I'd rather have steam handle all that
steam is way cleaner than ummorpg imo
it's a game engine using mirror that uses about 6000 lines of code to handle 1000 ccu
Okay
very powerful
to make it more convenient for them
I've been working on this project for about 2.5 years and have to login everytime. but now I have a steam license so I just wanna use that to login
Oh
I see
So make a login
Then make an auto fill
So you have control but it's still more convenient
I just took out the autofill for the name
they still need a password tho
I bet there's a way to transmit the entire steam credentials into mirror directly, I use fizzysteamworks so I'll continue looking through their documentation
Okay
Hello guys.
I'm currently looking into the level organization for my game world. Project will stay single player for a while, but I take steps to make every system multiplayer-friendly, so I don't need to make massive overhauls in the future. And I want to make game world level traveling compatible with multiplayer. I read that unity doesn't support multiple scenes running serverside, with players traveling between them independently of each other.
What would be the best architecture for a game with several levels that allows players to be dispersed throughout all of them simultaneously ?
Initially I planned to make a separate scene for each of the levels, and pass the world model and the player between them. But seems like this approach would require some serious overhaul for multiplayer to be added.
i have a lobby above my game and when a player gwets a game over they get sent to the lobby, how could i check if all players are at or above y 25 so i can run some code to clear the game so it can be started again
nevermind i found something that suits my needs
what is the best way to execute some code when a player joins a photon room, including the host joining?
?
Afaik, there's a callback OnPlayerJoined or something. If I remember correctly it's called for the host as well.
for some reason nothing is working
Actually OnJoinedRoom might fit more in your case.
https://doc-api.photonengine.com/en/pun/v2/class_photon_1_1_pun_1_1_mono_behaviour_pun_callbacks.html#adac50cc8725ba8802b9c8a42a673bb00 @inland pier
i tried it but nothing wants to work
Might want to share your code then.
all i had to do was add that into update :)
anyone know any good tutorials for a scroeboard that expands when someone joins for photon multiplayer?
how can I setup a dedicated server on steam, it says look for this link but I can't find it on the website. "All Associated Packages, DLC, Demos and Tools" section for your app and clicking "Create new Tool" button.
did they change the website? where should I go?
Job/collab posting is not allowed on this discord. There is a section on the Unity forum for both.
I mean if you make it a layout group
It forces the children to expand passed the designated size
I think
Pun or Fusion. Fusion you can use a [Networked] variable but Pun honestly idrk, you could get the “Player” out of the OnPlayerJoined callback, and directly send an rpc to that player with you health
Inputs?
Very broad
Like gameplay inputs like shooting?
Like key presses.
Specifically, I am having two players, in a rhythm game, play different parts of a track at the same time in a cooperative manner. How would I have the players sync each other's inputs?
Yes
If you send it in the csllback
Callback
Not at the start of your game
When a player joins
Send it directly to that player so they are up to date
No
Each player rpc them the health of themselves
No
That’s why fusion is predominatly better
20ccu and then payed
Same as PUn
But steeper learning curve
If you have barely started networking
Then I recommend switching
Sort of, but with net variables it doesn’t require any other work, and player props it requires extra complicated code
Hi, I've made an online fps game using photon and for some reason Joining someone else's lobby only works if both players have the game open, for example if someone hosts a lobby and the other person didn't open the game yet. once opened he can't see the lobby
how can I fix that?
Photon have multiple services they offer, which vary in functionality, your problem sounds like you are only listening for games that are being created, when you should be asking the server for games that already exist
How can I access the Network Transform from the current Netcode for Gameobjects version by a script? GetComponent<XXX>() does not seem to know Network Transforms as a valid component even if that component is on that object
OnNetworkSpawn is clearly valid so the Netcode libraries are accessible
Hi, I am trying to connect to a TCP server (written in Java) with TcpClient and receiving data in a thread. When the data is received, I invoke an Action and try to change the transform of a UI Button. When I try that, I receive an exception saying get_transform can only be called from the main thread. How can I overcome this situation?
is there too much of a difference between networking solutions that makes one better than the others, or is it all based on what you're trying to make?
That method is coming from inheritance, so you aren't necessarily including everything you need. Try right clicking on the type and seeing if quick actions and dig up the namespace for you. Alternatively check the documentation to see which namespace it's from.
There are engineering differences, but often they also are targeting different use cases. For example, Photon Fusion, Photon Quantum and SpatialOS are used for different purposes.
I will try that, although it would be absolutely baffling to me if a Network Transform is not included in the standard Unity.Netcode import, which should include everything you need for multiplayer especially something that essential
The documentation mentions something about a ClientSide Network Transform which I supposedly can add via a Git-Link, but if I do, nothing happens... The package manager does not download/import it
ah i see. Im just trying to figure out which multiplayer networking solution i should use for my game, in which each player has their own playspace (they dont share the same playspace) and they can see the playspaces of all other players in a match
so i just kinda need help in finding out which one would be best suited for my needs
Hello all, fairly new to Unity, been using it a few months for taking some general gaming development classes for my graduate degree. I've been tasked to create a game that I have pretty much completed, but I'm having issues with mirror networking. It's a basic PONG game, and all I want to do is synchronize the "score" of when a ball hits the opposite wall (goal), it updates the text values on both server and client. Currently I can only get it to work on server. The mirror networking documentation is a little confusing to me as I'm a beginner. I was wondering if anyone would be willing to help?
anyone know how to make or a tutorial to make a loading bar for the progress of this script
void Start()
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
PhotonNetwork.JoinLobby();
}
public override void OnJoinedLobby()
{
SceneManager.LoadScene("MenuM");
}
Greetings everyone, can somebody show me how to add a player prefab through code? The only way to do it that I'm seeing in the documentation is through adding it in the inspector, and I'm looking for adding it through code.
I'm using NetCode for game objects package
what happen to netcode cant find?
Does anyone know any good tutorials for setting up a lobby system for physics games in Mirror - apparently the process is different for 2d and 3d games
I am trying to activate a panel with Unity's new UI, but this panel to be active only on the screen of the player who triggered it and not to the others. I am trying to use photonView.isMine but it is not behaving as it should.
hey i need help with something its urgent. so if anyone here knows photon i was using it it was working fine untell i did something that broke photon its not working anymore and my game has been broken for days now. and the people that play my game are very sad so i need this fixed really fast, so does anyone know photon to help me?
Rather than rambling on and on, you could just ask the question to get a faster response
-_- true
When using the Netcode package I have an empty object with NetworkManager component. I then have a few UI buttons with script attached and I'm using NetworkManager.Singleton.StartHost() and NetworkManager.Singleton.StartClient() to connect. How do I listen to NetworkManager events? For example I want to have a UI script which listens for every time a client connects so that it can update/display the user counter.
Use sync/network variables that automatically propagate their value to late joiners. Absent those you need to build a system to effectively replicate their behavior by hooking into the client-joined event on the server with everything that has state that needs sync
Hey i have a problem player syncing just dont work
i have tried multiple tutorials but they all say the same
its the same with the Photon Transform view and without it
Maybe someone can help 😦
Hey folks!
Trying to plan out a strategy for making Cross platform between VR and PC happen. Not an overly complex project, just a simulation of an environment for users to explore. Does anyone have experience with making this happen? Will more than likely be using Unity with Photon as we have experience with it.
I can't imagine it being too different from a standard multiplayer setup, and is more local checks to see what platform then translating data correctly. But very open the idea that I am completely wrong.
I am having a problem in my mp game players are lagging not a lot but a little bit I'm using PUN 2 free
subscribe to the changed-callback/-hook of those syncVars/networkVars
Anyone knows how I can fix this?
photon is a company, do you mean PUN ? if so, why? and maybe use something that supports what you need.
photon fusion, mirror, netcode for gameobjects, fishnet, ... lots of options
who told you to use PUN? how did you find it?
photon is a company
not a product
Anikki cloud you maybe help me if you know how to fix it I'm desperate
is there an event that gets triggered when connection happens
like when connection to server is approved
I imagine whatever networking library you use has this yes
oh yeah I'm using netcode
I tried to look for it
couldn't find the event
or at least name of it
Called on the client or server?
client
when client's connection is approved to server
There probably is, you might be best asking in their Discord, it's pinned here
If i call my command it just cuts the client
does anyone know why
public void updateMap()
{
Debug.Log("Update");
if (!hasAuthority) { return; }
CmdPlaceObs();
}
[Command]
public void CmdPlaceObs()
{
Debug.Log("Cmd");
RpcPlaceObs();
}
this is the only code that pertains to it that i can think of
the line to call gets caled
and then the client ends before Cmd is printed?
Anyone please?
client side
Assets\Script\Launcher.cs(21,26): error CS0115: 'Launcher.OnJoinedLobby()': no suitable method found to override
how i can resolve this?
I'm having a hard time understanding how I would have a NetworkVariable of type List<MyClass> (I can't really understand the docs: https://docs-multiplayer.unity3d.com/netcode/current/basics/networkvariable) Can anyone give me a simple example of how I can store a List in a Network Synced variable? (In my case I'm trying to store a list of players)
You need to implement it yourself or use https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@1.0/api/Unity.Netcode.NetworkList-1.html
When I try to use NetworkList<Player> I get this from my IDE: The type 'Structs.Player' must be valid unmanaged type (simple numeric, 'bool', 'char', 'void', enumeration type or struct type with all fields of unmanaged types at any level of nesting) in order to use it as a type argument for 'T' parameter...how can I get the list to work with my own struct instead of just simple types?
they must be structs (afaik) and contain only primitive types, you cannot sync references, which is what that error message says
if you want to sync more complex structures (with references) you need to invent a way to do that yourself. I think NetworkObject references can be sync'd so thats maybe the part you have to leverage if you don't want to create custom messages.
mind that "Netcode for GameObjects" is a mid-level API, as such it does not aim to provide you with readymade stuff that is only useful for a specific use-case or type of project, so things like this are left for you to implement as they are fairly specific to each project.
I see; I'm basically a noob trying to make a game which involves both local and online multiplayer (ie you might have 2 controls on 1 PC and then 2 on another PC and all playing together). Plus you don't control a specific character, you can switch between characters. It seems like it's going to be hard going.
Have a 4 player Mahjong game, for multiplayer play Im thinking of using a server and using Go to write the match making game controller code. Is this a good idea?
Im using Netcode for Gameobjects right now, and for my NetworkManager I tried changing the IP from the internal feedback ip to my own so I could have other people connect. However, I'm now unable to connect to a server/host from a client, but if I use a host it works by itself. Any ideas?
does your LAN forward public requests from the internet correctly to the machine that acts as server and on the correct port? afaik in NFG your server needs to know its own IP to respond to requests, if you want your server to respond to all IP addresses put in 0.0.0.0
I'm not sure, but if its any help I am able to host servers from my computer normally.
what kind of servers and what does "normal" mean?
Should I put 0.0.0.0 as the normal address IP?
and for that question, Im able to host a minecraft server with no problem
0.0.0.0 means "all addresses" by convention
yes but do you mean that for the "address" or "server listen address" box
does minecraft use a relay service?
not sure, but im using unity transport not relay unity transport
maybe read this part of the docs https://docs-multiplayer.unity3d.com/netcode/current/learn/listen-server-host-architecture#connecting-to-a-listen-server
Learn more about creating a game with a listen server and host architecture.
just for reference, this is what my Unity Transport component looks like
i blocked out my ip, but its the actual ip clients would connect to (i assume)
ill look into this more tomorrow, i cant rn, but i appreciate it
idk for sure what the difference is, there was only one field last time i used it, probably combining the two
i suspect the "server listen address" is relevant only for a server/host
"address" would be the address your client connects to
thats what I thought
are you able to connect on your LAN?
I think the server listen address is what the server itself it supposed to listen to (?), but when I set it to my actual ip it failed
wdym by this?
like on my own machine?
i cant even connect between the server and client im running on the same machine
then you probably have specified the wrong addresses / port
maybe
there are only so many options that would make sense
it works with 127.0.0.1 locally, but i assume that wouldnt work for anyone else
try your LAN IP
192.168.x.x usually
or 10.10.x.x
and make sure the port is correct on both ends
I can try that, but then there must be somewhere else to specify an actual IP to connect to right?
the port is almost certainly correct
also make sure the server actually starts (it can fail if the port is blocked)
I assume the server is starting, since the host is able to work on its own
you should assume less and confirm more
then maybe ask again tomorrow
i was able to try the lan ip, and that works
but again, I don't see how it would be able to work for anyone else, seeing as I havent put my IP anywhere else in unity/the code
did you read the docs i linked, its all explained there
TLDR: you can't just have someone from the internet connect to your server, you need to configure your network properly or use a service that eliminates the need
yeah, you need to port forward, but i've done that and I know i have ports open
it might be a firewall thing, but if so Ill have to figure that out tmr
but thanks for the help today
Question when making a multiplayer game using steam, do I have to use mirror? why? and why does mirror do since steam provides the server?
Hi is it generally OK to bombard a server with lots of requests and then await all of them to return or should you stagger requests, even do 1 at a time?
no? steam and mirror are completely unrelated, and steam does not provide game servers
mirror just makes networking in Unity easier to do
steamworks allows access to the steam api to invite friends, display active servers, create lobbies, etc
sorry i was away and yes... I understood it after research for an hour
Looking for some help with PUN 2, is anyone here familiar with it?
very basic unity code question - how do I say "if this is a player, but not THIS player" ? (like for multiplayer)
if (someObject.TryGetComponent(out Player player) && player.SomeIdProperty != excludeThisID)
{
// do something to player
}
What do you need help with?
How would you go about sending audio clips over an rpc?
Assuming regular unity multiplayer context. You would not do that. You‘d send maybe the info where to download or stream them and then process that info in a separate system. If you had to do it, you’d serialize them like any other data.
Hm, I might have to reconsider how I handle sound syncing then
this is because streaming data like that saturates the servers bandwidth immediately, degrading all other sync (of gameplay) and it does not scale.
are they dynamically created?
No
You would not even send the clips to another method if it were a local thing without networking
It's from a gun class which pulls it from a scriptable object
Can't have a photon view because it's a parent of another object
So I'm a bit stuck on how i could sync it
then everyone already has the sound. Only thing you need to sync is which one to play
Would you be able to source a photon view from a parent object?
or maybe not even that. All clients might just play it in response to an action the sound is already associated with. So you sync only the gameplay action
Sorry, can’t help with PUN
It only syncs the damage taken on the player that is hit
Photon is a company, not a product
Apparently pun is deprecated now
And i need to move to fusion
Thanks though
That was helpful
does anybody have any experience with VR multiplayer? Netcode and Relay in particular
Im trying to sync the head and hand movement over the network but since it is a package script i cant really edit it. Any ideas?
How can I edit an instance in real time so it syncs to all the players in the same build? Like if I spawn something in my editor instance how can I make everyone to see everything I do in real time from their builds, even if an object is not actually in the scene? Like those sandbox games that spawn things and it does for everyone.
Ping when reply pls
I'm using photon
Should I use Mirror or Netcode or some other network library for a simple pvp/pve (cube enemies) game?
- Only physics the game contains is box colliders
- I have no experience in networking
@halcyon heron I'm learning Netcode for my job, I gotta say tutorials are pretty rare to find given the full release came out a couple of months ago. Documentation is okay, covering the most basics of stuff without many examples. I would say find a network library that has more tutorials if u are a beginner. Its not like Netcode is terribly hard to implement. Its fairly simple and using it alongside with relay is pretty flawless not gonna lie. But yeah documentation and tutorials are my main issue with Netcode, especially now that Im doing an online VR prototype... there is almost nothing online.
Does anyone have a written tutorial of FIsh networking? I'm getting tired of videos because they don't explain stuff
Hi! I'm trying to make a multiplayer 2D top down game using Photon, but I have some issues. My game has a soccer ball and I can't make it so it doesn't bug on different clients, can someon help me?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallMove : MonoBehaviour
{
private Rigidbody2D rb;
private Vector3 lastVelocity;
public float speed;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
lastVelocity = rb.velocity;
}
private void OnCollisionEnter2D(Collision2D collision)
{
var speed = lastVelocity.magnitude;
var direction = Vector3.Reflect(lastVelocity.normalized, collision.contacts[0].normal);
rb.velocity = direction * Mathf.Max(speed, 0f);
}
}
you could delete the script on the client side with something similar to
private Start()
{
if(!isServer)
Destroy(this);
}
and then just use photon's version of a Network Transform component to update its position and rotation.
Hi guys, I have a question here.
public Transform target;
List<GameObject> PlayerObjectsList = new List<GameObject>();
public void UpdateUsers() {
if (PlayerObjectsList != null)
{
PlayerObjectsList = packManNetworkManager.PlayerObjectsList;
foreach (var item in PlayerObjectsList)
{
//Assign GameObject in PlayerObjectsList in target slot.
}
}
}
I'm going to assign the data in list playerobjectslist to target. Can someone help me please?🙈
Welcome for any advice, thanks ~
PlayerObjectsList store the player joined game.
Anyone used Unity with Laravel & session-based security? And did you base code on some existing API?
Easiest networking tutorial?
if anyone is familiar with Photon multiplayer in unity, I'm having an issue where pretty much all movement works fine except jumping. the player jumping will be fine but on the other screen its like the player is jumping and snapping to the ground at the same time.
I have photon view and photon rigidbody 2d view as well with synchronize velocity on as well. I'm using velocity to have them jump. can i not use velocity to jump?
Do any of u know if its possible to change roomOptions after creating the room (eg. closing it after starting the game)
can anyone tell me the best way to make a first person multiplayer game with netcode
when someone gets a chance, I have a couple problems in changing values and deleting objects for all clients with photon Pun2, I cant seem to find what is wrong, the bounds dont change when the rpc changes them, the flag dosent get deleted when a client other than master collids with it, and when all the cops get deleted it somehow triggers one more to spawn, I cant find out what is causing it, any help would be nice
my scripts: http://pastie.org/p/5L1OHMmjdujod6HMueOBfg http://pastie.org/p/67rBDJaDbpGZDDY5SVtbst
Might want to add some debugs to see if the RPCs are getting called on the client and on what objects.
i did and what it said is that the bounds had changed from 25 to 50 but i still am confined to 25 by 25, and for the objects being spawned i dont know what causes it still nothing sets spawn enabledd and spawn cops to true when the host goes to lobby or when everyones out, and i know the problem with the flag and im trying to figure out how to use the ownership transfer stuff i need to do
Make sure to output the object name with the other info. Seeing how you have several, the changes might be applied to a different object than you expect.
Otherwise, I can only guess that it resets locally to the other value. Might want to turn the field into a property and print log in it's setter to troubleshoot that.
well ill try
is it possible for 100 people to join one lobby because im going to by photon pun+
how to check if a player connected to the room in photon
is canvas, camera, audio, listener part of the prefab player in netcode
i mean
or i need it to be out of it parent to be local because i think this happens when gameObjects are out of player prefabs they turn into local
not sure what you are asking exactly, but no, you generally shouldn't have your camera or audio listener as part of your networked player prefab
if you have all of those on the prefab, you will have to manually remove them for every other player when they spawn in
ok thx
when someone can help, i am slowly fixing the problems i said w hile ago, I found the issue for the flag destroying and i found a diffrent way that destroys the flag but i still get this error i know it functions but it would be nice to fix this error
the error: Failed to 'network-remove' GameObject. Client is neither owner nor MasterClient taking over for owner who left: View 1002 on Flag(Clone)
the new scripts: http://pastie.org/p/6l2UbfK5pZsKx2zJOAjLxK
edit: i changed stuff and i cant find a way to change the owner i just keep getting errors
i might be able to get it working if i can figure out how to transfer ownership of the flag to whoever it collided with, any one know how
I have a NetworkManager prefab setup. Normally when playing the game you'd go through various menus, hosts/clients would get started and then carried over to the next scene. However when developing I want to be able to jump straight into a scene. So I have added the NetworkManager prefab to every scene; but I want to add a script to it so that on Awake it checks to see if the NetworkManager already exists (if so use existing one) and also check to see if we've jumped into game midway though and need to start host. Here is my script (below). The problem is that Unity is saying that I cannot add a NetworkBehaviour script to my NetworkManager....so what should I do to make this work?
using Core;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;
public class NetworkManagerScript : NetworkBehaviour
{
public static NetworkManagerScript Instance;
public NetworkVariable<NetworkString> thescene = new NetworkVariable<NetworkString>("MainMenu");
void Awake()
{
if (Instance)
{
DestroyImmediate(gameObject);
Debug.Log("NetworkManager was already started in previous scene");
}else {
DontDestroyOnLoad(gameObject);
Instance = this;
if (SceneManager.GetActiveScene().name != thescene.Value)
{
Debug.Log("We have jumped into the game midway so start the host");
NetworkManager.Singleton.StartHost();
}
}
}
private void Start()
{
thescene.OnValueChanged += (value, newValue) =>
{
CheckScene();
};
}
public void CheckScene()
{
if (SceneManager.GetActiveScene().name != thescene.Value)
{
Debug.Log($"Load new Scene: {thescene.Value}");
SceneManager.LoadScene(thescene.Value);
}
}
}
anyone know why my rpc for changing the menues only works for the client who called it but no the others
code: ```cs
public void StartGame()
{
// code not nessecary for my question here
// sets canvases
view.RPC("RPC_ChangePauseMenues", RpcTarget.All, false);
}
[PunRPC]
private void RPC_ChangePauseMenues(bool isInLobby)
{
pauseMenuLobby.SetActive(isInLobby);
pauseMenuGame.SetActive(!isInLobby);
isPaused = false;
SetPaused();
}
Hello everyone, how ya doin'?
Does anyone have any experience with Rollback Netcode Implementation in Unity?
More specifically, Determinism in Unity?
I already know that the Unity Physics system is non-deterministic, but are the animator and Navmesh also non-deterministic?
(I'm not sure I'll use Navmesh, but I'd still like t know if it's deterministic or not).
There ain't enough info on determinism in unity, so any help would be appreciated.
Hi! I am currently trying to try making multiplayer games with Photon, but I have an error and I don't know why, could someone help me?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Realtime;
using Photon.Pun;
public class Scoreboard : MonoBehaviour
{
[SerializeField] private Transform container;
[SerializeField] private GameObject scoreboardItemPrefab;
private void Start()
{
foreach(Player player in PhotonNetwork.PlayerList);
{
AddScoreboardItem(player);
}
}
private void AddScoreboardItem(Player player)
{
ScoreboardItem item = Instantiate(scoreboardItemPrefab, container).GetComponent<ScoreboardItem>();
item.Initialize(player);
}
}
i get an error like Observed scripts have to implement IPunObservable. after i added IPunObservable to a script for something, got rid of the thing that needed it and then getting rid of IPunObservable after, how do i fix this
edit fixed
I have a function which i want to run once when two players join the room in photon
is unity netcode for objects out of beta and recommended to use?
can i ask how can i awake or anything to make it into [conid=0]?
i am looking for something like
awake or update
pacman = netid
instead of getting my prefabs name i wan to get network id name as well
(photon pun2) i have an rpc called RPC_ChangeBounds, everytime the host hits start or lobby they call the rpc, my problem is that the other clients bounds dont change, the debug i put in the rpc itself says the x and z bound are 50 but the bounds somehow are still 25 which is proven when i try to go past -25 or 25 on the x or z and it dosent let me and the debug there says its 25, I am truley stuck and cant find the cause. any and all help is appreceated.
my code: http://pastie.org/p/1RlYX9gJCvPm8mrBC9pTrq
i forgot to mension that with the execption of in one function and the rpc, i have no other places that the bounds get set and yes ive tried taking out the part where they get set in the one function and it had no effecthave some rpcs that wont
I building a multiplayer pong game and need help with a thing. The ball isn’t on the same position on client and host, the client is behind. How can I solve the problem?
im just making a new script for my player, the old one is broken, but i still cant change a variable for all clients, anyone know how i can do this (photon pun 2)
Command Function System.Void ReadyUp::CmdReadyUp() called without an active client. what is this
bro does anyone know how to make ready up thingy in unity pls help
This looks like you tried invoking a Command on the server without even being a client
bro idek what that means
It's pretty self explanatory, you must be a client on a server to invoke a [Command] on the server
what if i am host
You must not have been hosting at the time
But it's the same explanation, you're both the client and server
i still dont get it
but what is an rpc and can i use for this
A [Command] is literally an RPC
hey do you know any good tutorials for unity netcode for beginners? except docs
How can I edit an instance in real time so it syncs to all the players in the same build? Like if I spawn something in my editor instance how can I make everyone to see everything I do in real time from their builds, even if an object is not actually in the scene? Like those sandbox games that spawn things and it does for everyone. I'm using photon. Ping when reply please.
Anyone know what is <spriteRenderer>k__BackingField ?
artifact of serializing an auto-property iirc
Ermm okay thanks
Let me go google for this 🙈
If simply adding a gameobject with a network identity component doesn't work, you likely need to tell the networking system to spawn the object for other clients. These things should be laid out pretty clearly in documentation
it probably has a .value or something
try putting a dot and seeing what your IDE gives you as potential options
why do i get these errors after i install "Photon Unity Networking Classic" to my unity project?
hello?
i just deleted it now
Exactly what it says, any method marked [ServerRpc] must have the name of the method end with ServerRpc.
i didnt understand
As in, you still don't understand?
Because you have UpdateClientPositionToServer() marked with [ServerRpc] you have to change the name of it to UpdateClientPositionToServerServerRpc()
Which is a little long, but that's what it is
You have to include the words ServerRpc at the end of the method name, is what it's telling you.
in the update?
The name of the method, which of course includes any reference to it.
oh thx
i think worked
is returning me thix exception
is this because of my variable ?
write permission
?
the right way to transform a networkObject is transform first in the client and send the network variable position to the server and server to all clients - owner (you)
or client dont transform it and just send the network variable position to the server and the server transform it in all clients including the owner (you)?
Hi, sorry, I didn't want to interrupt anyone's question or anything, I've just been struggling with some problems implementing Photon and I figured I could come here for some guidance. Basically, I'm trying to create a 3d ultimate frisbee game, but having the frisbee successfully go from one owner to another and back again has proven to be tricky. I'm able to successfully throw the frisbee from the host player to the other player, but when the other player throws it back, it ends up in a totally different position in both instances of the game. I've basically just been making random minor adjustments for the past few days to address the problem, but honestly I'm pretty stuck. If someone could provide me with possibly a blueprint for how they would approach this problem, or this idea in general (throwing an object back and forth in Photon), that would be really, really helpful. I can provide code also but I've been really slacking on readability and the general tidiness of the code tbh in an attempt to get everything to work. Thanks!
how to instantiate GameObjects in multiplayer netcode?
In Unity, you typically create a new game object using the Instantiate function. Creating a game object with Instantiate will only create that object on the local machine. Spawning in Netcode for GameObjects (Netcode) means to instantiate and/or spawn the object that is synchronized between all clients by the server.
hi,
if, as a server, you subscribe to OnClientDisconnectCallback, and try to check the ConnectedClientsList.Count, you will get a number WITH the disconnecting client still being in the list
so if you had only 1 client, who then disconnects, you will get the ConnectedClientsList.Count == 1 on the disconnect callback
if you run a routine with like 2 second delay, and check the ConnectedClientsList.Count again, it would then be == 0
is there any way to get a callback/event when the ConnectedClientsList.Count == 0, to avoid the ambiguous waiting routine?
(this isn't a bug, since it has been addressed in issue #1156 https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/1156)
Hello, does anyone want to make 2D Multiplayer game with me, I have already started but I need someone to help me with some mechanics. This project will help us learn more and have great fun. DM if someone is interested!
#📖┃code-of-conduct Job or collaboration postings go on the forums
I assume you are using PUN 2. I would recommend looking into Fusion, which is our state of the art networking solution.
In PUN 2, one player is the "controller" of any networked object. This client sends where it belongs to. If you throw the frisbee from A to B, you possibly want to pass control to B as well. Else, B can't just tell everyone where the frisbee belongs and this will complicate matters.
In Fusion, you could do something similar and it is better suited for games with physics aspects (such as throwing).
This is somehow an issue of Unity generating the .sln and .csproj files properly. Some Unity versions do this infrequently.
Check if you could update the "Visual Studio Editor" package in the package manager. You could regenerate the files from the panel Edit->Preferences->External Tools. There is a "Regenerate project files" button.
Unity is not deterministic.
Quantum is a deterministic multiplayer engine which runs in Unity (and uses it for audio, visuals, etc). It's a full implementation of predict rollback netcode.
So .. there are options.
oh alright, imma do it in some time, also is there a way i can downgrade a version of a package?
like the pun 2 and photon unity networking classic
The Asset Store only provides a single version of the packages. No way to pick another.
I would not recommend using PUN Classic. Actually, PUN 2 is a bit dated (if usable), too. Of the Photon products, my recommendation is Fusion...
Hi, I made a game using photon engine but only 2 out of 3 of my friends see the room to join it
how can I fix this?
I am making a LootLocker Leaderboard. Here's my code
{
LootLockerSDKManager.StartSession("Player", (response) =>
{
if (response.success)
{
Debug.Log("Succsess");
}
else
{
Debug.Log("Failed");
}
});
}
public void SubmitScore()
{
LootLockerSDKManager.SubmitScore(MemberID.text, GameManagerScript.Score, ID, (response) =>
{
if (response.success)
{
Debug.Log("Succsess2");
}
else
{
Debug.Log("Failed2");
}
}
);
}``` Basicly my problem is I get a "Failed" and if I try to submit a score this error:
In your class you could store a bool value on wether of not LootLocker has been initialized properly. Than check before trying to submit your score
hey does anyone got that error? I'm getting it everytime when I want to change scene via server (I can't track where the problem in my code is, because I'm not using "ConnectedClientsList" from network manager)
what does the stack trace look like?
okay nevermind I fixed that, by changing scene on my destroy function I shutdown my netcode connection, I'm dumb lol
how can i make a button leave a normcore room?
So I follow all the series about steam multiplayer by zyger and I added pause menu with a button to go back to menu but when I try to host lobby again I can't because the first lobby I created still exist.
How can I delete lobby?
I tried Do this
public ulong CurrentLobbyID;
private const string HostAddressKey = "HostAddress";
public void DeleteLobby()
{
SteamMatchmaking.DeleteLobbyData(CurrentLobbyID, HostAddressKey);
}
but it require CSteamID and now ulong
Create a new CSteamID(), you can probably pass it a ulong in the constructor
This code delete all the loobies in the game and i want the delete only the lobby that i hosted how can i do this
When using unity NetCode; when I load a scene (using SceneManager.LoadScene) which contains NetworkObject component the network object does not "Spawn" automatically. So I have to add something like this:
private void Awake()
{
if (!NetworkObject.IsSpawned)
{
NetworkObject.Spawn();
}
}
Is there a way to have NetworkObject always start by itself, without having to do this on every NetworkObject?
But I just wouldn't work, right?
I also got this message, but in the tutorial I was told, I should use IOS
Use the NetworkSceneManager
Not sure what you are saying here sorry. I would check if that sdk support desktop environment or if it only works on iOS itself which could be the case as to why its not initializing for you.
Nevermind I got it working but thx
Thanks
Hi, I have a multiplayer game made with Photon but I want to switch it to steam. I already got a main menu & lobby going, what's the easiest way to import all the files to the new one?
Hello! Is it okay to post Photon Quantum related jobs here? (Paid)
We have no job or recruitment posts here, you can use the forums for that. Links are in #📖┃code-of-conduct
Hi what do you guys use to read JSON data out of a web request result? Do you use Unity's JsonUtility to deserialize into a class representation or a simple JSON library like SimpleJSON (Bunny83's) or something more complex...?
ok yeah I have to get onto that but a thread on the forums was discussing issues with different newtonsoft libs. Feels a bit like overkill when you look at the code size
That’s a misperception. Especially since it is already part of almost every unity build because everything relies on it
dealing with a HTTP/REST api in itself is the biggest bloat/overkill you incur
true
So what is NGO and MLAPI? What is their difference? I don't get it :/
NGO is the new name of MLAPI, difference is: NGO is a newer version of MLAPI
Hello, i am using unity netcode multiplayer, and i need to set 2 variables of a networkObject on spawn, and i am actually spawning the netWork object on server side, but when i try to set local variables or networkVariables on it, it never changes
so i need help
i call this spawning function on client side to be done on server side
How and when do you check if the values are correct? If the variables don’t change on the server, this code does not run on the object you are inspecting or something else (not in this code) happens between setting the values and you checking them.
You could set the network variables before you spawn the object
With Unity Netcode is there any built-in way to get a clients ping/latency?
you can just send a timestamp from the client in a ServerRPC that immediately sends back the same timestamp in a ClientRPC in which you compare the actual time with the received timestamp
float _roundTripTime;
void UpdateRTT() {
ToServerRpc(Time.time);
}
[ServerRPC]
void ToServerRpc(float ts) {
ToClientRpc(ts);
}
[ClientRPC]
void ToClientRpc(float ts) {
_roundTripTime = Time.time - ts;
}
are network variables constantly being syncd or only when they change on the server are they reflected on the clients?
(in netcode)
I would expect it works sort of like rpcs, and whenever you set the networkvariable value on the server it does a clientrpc which passes the new value to the clients? I just want to make sure having many network variables that dont change much are not making heavier packets unnecessarily
hello i am getting missing reference exception when i try to despawn a gameObject from netcode, some help?
i call this function in a client that is not the server
on the server you need to assign some network object to the field called networkObject, if you want to refer to the NetworkObject component of the GameObject that your NetworkBehaviour with this method is on, then use the this.NetworkObject property to access it.
im trying to add these lines
where do i find the packages/manifest.json files
i get an error every time i try adding the URL
Right click assets folder in project explorer > show in explorer > packages folder> manifest.json
i want to make online games. How can I do it?
Hi, i want to try make a fps pvp game with photon do you guys know good tutorials on how to set up photon?
I'm really new to multiplayer
I'm having an issue where "Late joining" clients are not getting a synced copy of a NetworkList? They only get synced once the NetworkList has been changed after they join (so they get an empty list as the initial value even though it is not empty)
How can I force new connecting clients to sync the networkvariables?
hey im trying to make player 2 spawn with a different prefab than player one but they both spawn on player 1 prefab can i change this?
Id suggest having your player prefab as an empty object with a script
It will be like the players "soul"
It will possess the character and control it
can i PLEASE call you your the first person to try and help me with this
its the biggest yet simple prblem i have
my games already done i just cant set up the second player
im going to sleep in a few mins
Or you'd know from the spawning of the player prefab
if player count is 1 spawn second character????
yeah
im using photon you think it will still work??
you can keep track of joining characters using the callback
this goes for phoron and mirror
im not sure how to use callbacks
probably all other options
they are not too different afaik
You should be able to call an RPC method
couldnt i use SpawnPlayers : MonoBehaviourPunCallbacks
If you call an rpc in your gamemanager amd your gamemanager inherits from networkbehaviour or its photon equilavent, has the network identity component and all
The rpc you call on servers gameobject
Will be called on clients with same parameters as well
Thats how mp comminication works
hmm not sure about that callback
are override voids like update voids?
In a component that implements photons class
yeah
yeah
you should also be able to access the clients id somehow
if its 0, you can spawn prefab0
if its 1 spawn prefab 1 maybe
ok ok
there should be an id going in order starting from 0
at the start is when player 1 joins
once they join player count becomes one
id someone else joins room and player count is 1 they get the second prefab and position
i just gotta test it now
yeah
it just spawned a thousand prefab 2s
So for work I'm trying to introduce agents to play in place of players when the player count is low.
We are using PUN 2.39, going by the documentation, and I'm kind of at a loss on how to do it properly.
How do I get the Agents to exist server-side and then be shown client-side during play?
Because far as I can tell, PUN2 does not have a method with which to make "fake" players or basically AI players.
Hello
how can I make a matchmaking system with photon based on the level of the player
To join people of same level and ability in the same lobby
You could look into using the SQL Lobbies:
https://doc.photonengine.com/en-us/pun/current/lobby-and-matchmaking/matchmaking-and-lobby#sql_lobby_type
Right, there is no bot framework for PUN 2 (Quantum has one but it's likely too late to point out).
In the cheapest case, you'd run the AI on a client. It you just spawn units/characters accordingly, it is not a proper separate connection and player but this leaves room for others to join (as the AI doesn't use a seat in the room).
In theory, you could invest more effort and make AI that properly connects to PUN rooms with separate connections but that will eat CCU and be quite some effort.
To the suggestion is to let one player do more work. Sync which players are faked and let them be controlled by AI running on the Master Client or so.
hello, I wonder how could I host my little game: I would like my game server stay online even when no players are online. Do you have clues ?
Rent a server and host it from that
Anyone experiencing weird jittering of PlayerObjects when using the new 1.0.1 Netcode for Gameobjects (compared to the perfectly working 1.0)?
That is easy to do??
Is there any tutorial?
Hey guys, what is the easiest way to play websocket media stream?
can someone help with extremely bad way of downloading files
Has anyone here had massive issues with the NetworkSceneManager in full builds?
can someone add and call me i really need help with some of my networking code using photon, screenshots and chat arent enough
Is there any repo that contains best practices for a simple turn-based netcode for gameobjects game? esp. if it has any kind of test framework integration?
In this particular case, the master client is a server, so the effort would not be run on an actual players computer
@olive vessel thank you, but I looking for some information about doing that and don't really find how can I do that 🙂
So you would run PUN instances on servers and make them create the rooms / become the Master Client per room and take over extra duties, yes?
Ok, that's possible too.
I was told recently that PUN2 is just some prototype stuff and that we won't use it anyway for the product so it seems I don't have to care about it at all hah
I appreciate you wanting to help though @stiff ridge
Glad to read that. It's not our favorite solution anyways. Unlike Fusion, PUN is not built with running on dedicated machines in mind...
Yeah it would be nice to use Fusion
Though it seems we have some proprietary thing we have to use instead so
I guess we'll see
I'll probably be back with vague questions again in the future, don't you worry
Lol
i'm using webrequest to download images from api. I'm downloading around 500 images and displaying them in raw images as textures. but the problem is when this is happening cpu and ram usage are very high so high that some times the game crashes any way i can reduce the cpu usage in this part
Im beginner but In my game I use something for just load images clientside
<iframe width="560" height="315" src="https://www.youtube.com/embed/SMHjvKqUO6I" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
sorry for this weird link
not the json and php /sql part of the video
Dude 500 images at once ? I don't know the images resolution, but I wouldn't try more than 10 at once. Best case, 20 at once. Make a queue and have a loader borrow only X request at a time
This HTML markup embeds a youtube video. And you didnt ask any question. So I don't understand how is it related to image loading ?
Oh damn you wanted to share the link to the video only xD
Looks like I'm tired
ooook and there's no question because it was an answer to the line above yours. That's it I'm off, I need a break :p
yeah sure will try that
but actually not at once
the code is set in a loop
yeah maybe you can say at once
is this something like lazy load
Hi, I am having an issue with Firestore for my webgl build.
I am actually adding documents directly to a subcollection (collection1/document1/collection2), would this be an issue?
eg. AddDocument("Logins/Date/Players", string)
The Date document in the database shows up in italics, not sure why.
Hello, I get the following error when I try to join a host in netcode
HttpException`1: (404) HTTP/1.1 404 Not Found
Unity.Services.Relay.Http.ResponseHandler.HandleAsyncResponse
The room code gets generated from the host
but when I join as a client, it doesnt work
JoinAllocation allocation = await Unity.Services.Relay.RelayService.Instance.JoinAllocationAsync(joinCode);
The code I get from the host is as follows
JoinCode = await Unity.Services.Relay.RelayService.Instance.GetJoinCodeAsync(data.AllocationID);
I get a 6 letter string
and try to join it using a input field on the client
but doesnt seem to work
Referred it from the documentation
has anyone worked with photon and webgl need some help also not sure if this is the right channel to ask
it is displayed by the console to respect the hierarchy, but can't be queried and won't appear in results
so its my first time using photon and I'm using 2 different prefabs 1 for player 1 and another prefab for the player that joins does anyone know how I make the first player that joins the first prefab and the second player the second prefab
I am trying to make a game using photon but when one player presses w it makes all players move
make a Players variable in your script and have it change when a player joins
Wdym by that
Im kinda confused
Could i show u my code plz
Ive been stuck with this for 2 days so it would mean a lot
I know how to fix that
U need the photon view
how
And the
In the script
Do
And reference the photon view
And called it what ever for example view
Im kinda confused
why doesn't this work
void Awake() {
if(!playerPrefab.IsMine){
Debug.Log("DISABLED OWNERSHIP")
this.enabled = false;
}
}```
playerPrefab is the photonview
Add me and il help
Or dm
I need help with the thing tho
I have no idea how to do it
How do you set playerPrefab?
If you'd inherit from MonoBehaviourPunCallbacks class, there is a photonView field already, which you can use. It will look up the local PhotonView and cache it.
Hello, could someone explain how host migration works in Relay?
If the host disconnects, do the clients get a callback that I can use to set them as the new host?
In a 4 player game, I would like the game to continue even if the host disconnects with the other 3 player
Thank you
I forgot to use puncallbacks it’s always the stupidest things that get me
Question: Is there a way where I can know if the server is full. I'm using Netcode for game objects
guys , im getting this error when I try to type on a chat that i just scripted with photon, what does it means ?
Hello, I got an issue where the host and the client cannot see each other. I'm using netcode for game objects
Is there something I could have missed? Any tips?
how to call a function when a player joins the room in photon?
Wait for the callback, OnJoinedRoom or something
Photon PUN has good docs
Can someone recommend a wich networking works the best for the type of game im trying to make ? is a 3d android game wich every person has a character, your own house, social type of game just like "Playtogether" kind of game on android
Which is better to use the netcode for gameobjects of unity or photon?
"Better" is subjective, you should pick a solution that works for your needs
Photon is a company not a product
PUN is only useful for games where you trust all players to not exploit/cheat or where it would not matter
If you want a solid mid level base that you can take anywhere use mirror or netcode
if you want a mmo, just stop now
if you want the fastest way to do a competitive/pvp fps, use photon fusion of quantum
if you feel adventurous (or want to do some deep learning) build your own library on top of ENet or another transport library
Im so confused. if i want lets say, a game people join in the same world with 300 players lets say. They can go to diferent locations on the map to fish, play minigames, etc. Kinda like club pinguin 3d like , social with games or activities to do in the map, collection of clothes, furnature, etc.
How big is your team?
300 people on one server on a shared world is an MMO and it’s 99% likely that you will fail to ever make it work. Especially if you have to ask here how to do it.
is just me , im trying to make at least the core to test 2 players interact with each other with chat, bubble chat on their heads when they type and then in the map like a river to fish
Just use mirror or netcode
Both can potentially handle 300 players. But it’s very dependent on how you design and implement your stuff.
Allright , thanks for the info i will check those out
mirror has a lot more stuff built in to get you going with non trivial player counts (like interest management)
Cool ill go for that then
hey i need help with something
im trying to get this button to be instantiated so it will display room names and join on clicking it
but it wont instantiate
the 1st photo is my scipt that instanitiates the room object
the 2nd one is the script that belongs to the room object
I am making a game with photon and everything syncs except when I shoot. Bullet has a photon transform view on it and photon view is observing it. Also this only started when I added pv.IsMine though the bullet still instantiates which is the function that is protected by ownership. Also I did make sure I was using monobehaivor pun callbacks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class shoot : MonoBehaviourPunCallbacks
{
public Transform firePoint;
public GameObject bulletPrefab;
public float bulletForce = 20f;
public PhotonView pv;
// Update is called once per frame
void Update()
{
if(Input.GetButtonDown("Fire1"))
{
Shoot();
}
}
void Shoot()
{
if (pv.IsMine)
{
GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>();
rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);
}
}
}
I'm using Unity netcode and I'm having a problem where I'm checking to see if client is the owner then doing a ServerRPC, such as this:
if (IsOwner)
{
var movement = CalculateMovement(_movementInput, m_Momentum);
if (movement.DidMove)
{
SendMovementServerRpc(movement);
ProcessMovement(movement.Simple());
}
}
The problem is that I have another ServerRPC call on a different button to remove ownership. So the server might have already removed the clients ownership by the time the client tries to run the movement RPC....at which point it is correctly being ignored by the server....however the server splits out errors like this Only the owner can invoke a ServerRpc....is there some way to hide these errors...or should i do something else so that these errors don't even occur?
Do you guys know a good tutorial that goes over photon? I want to try make simple multiplayer games
You should go on the Photon website, choose a solution (PUN2, Bolt, Fusion) and pick one that fits your needs. For simple multiplayer games I recommend PUN2 as it is very simple to understand, but it is very old and no longer being updated with new features, although it is supported and works fine with new versions of unity
Awesome! If you need any help, consider joining the Photon discord
There is?
yes
I didn't know that :l
I can dm you an invite if you need
Can you, thanks!
does anyone know what the easiest way to implement networking into your game is?
I've found a lot of stuff like mirror but sometimes it works and sometimes it doesnt
I'm looking for something more beginner friendly and easy to work with
Networking is not beginner friendly. Mirror is about as easy as it gets without being oversimplified.
When networking a item that moves, how do you keep everyone on said item?
Can you put a photon game on the web
Hi everyone! Is anyone familiar with Netcode? I've been learning it for a couple of days now and would like to understand better why would someone use [serverRpc] instead of setting the NetworkVariable`s permission to Owner, and just setting the value on the client?
At first I thought that NetworkVariables wouldn't be propagated to all clients if set by the client owner, but I've tested with three, four clients and it still seems to sync fine.
Here's a code snippet to illustrate my question.
Photon Fusion somewhat recently got browser support and PUN has always had it AFAIK. Photon Bolt and Quantum I'm not so sure about.
Halo. Maybe a noob question
Unity runs on 1 thread, but what if i run multiple unity instances? Will they all run on the same thread, or will each instance take different thread?
So yeah basically should my server run multiple instance, or just 1 instance with many room sessions?
I guess a factor is, how much processing each session needs
I only need to host 2 heavy sessions, and the only benefit i can see to combine them in single instance is i can communicate between the 2 individual additive scenes from within 1 instance (i need this)
In the future ill definitely separate them, and have them comm via just Rest
But im just making a prototype for now, so i can ignore scaling
@trail parrot Thread != core
So if your server has to run Unity then multiple instances would be better 🤔 I think.
If I just need a networked messaging system for transferring data between Unity and a different program on the network, should I just use C# networking sockets, or is it still worth getting a networking solution? I just need to read and write streams to a network port like it were a text stream. Would I start to run into issues if I tried to just handle it myself?
I think mirror would be worth a shot since it's free and very open-ended with how you use it @frank meteor
various community made transports etc
I see very little reason to use Unity if all you end up using from it is the .NET runtime, especially considering the progress happening in newer .NET versions. 😄
I'm interfacing with a java program through network messages to control a unity program. Basically taking a bunch of math from a java based simulation program and rendering it in unity with objects and whatnot. It's not connecting separate unity applications so I don't need a full multiplayer suite with things like player ownership, I just need to pass data to and from the Java program on the network
does it involve the internet?
Just opening an UDP or TCP socket on both Java and C# side and sending data through it shouldn't become a problem, though if you are targeting a lot of platforms, there can be platform specific challenges. I don't think it would be an issue on desktop platforms though.
if you can exclude the internet, i'd just roll my own solution for that specific app with UDP (if its realtime)
Yeah, that's what I've ended up doing. It's desktop only.
i implemented photon into my game to make it multiplayer but when i have two players in a game, it moves the wrong character even though i am focused on my chosen screen
it only started doing this when i added my character movement script
here is my character movement script
another weird thing that it does is that it also moves my player's camera based off my normal mouse movements irl, but doesnt actually show it on screen
@amber void Check out #854851968446365696 on how to send large amounts of code.
Hi,I have some problem now, if I want to creating metaverse multiplatform webGL version, what service I can use for networking?
pls, suggest me.
Can someone please help me with this problem i am having with Photon puns RPC? https://hatebin.com/wpyawfcaqt It gives an error
https://hatebin.com/rkcepuarvs (the error)
Hello, I have a question about the Boss Room sample
can it be converted into a server client model?
I mean hosting it using Multiplay that is
The rep says it uses relay
Does the networking logic remain the same?
Only the connection to the server changes?
whats the closest network to unet that i can use on 2021.3.9f1
Mirror
hey! so I am trying to make an online 2d game, I have the spawning working but I am using a CM vcam and I have no idea how to make it so when each player spawns in they have their respective camera
I am putting my player in an empty gameobject and putting all the camera stuff in there to see if it would work
Actually
I think I got it to work
ok
so now I am having trouble with priority
they are both set to one when spawned but idk how to make it so the camera focuses on the character that it spawned with
hey
so i just did the exact same thing, here is how i did it
ok
and if I put this they will have their seperate cameras focused?
like the priority
look, there are two camera in a scene, 1 of A and 1 of B. If B is the owner then A's Vcam gets disabled so both cameras now follow the active one.
so A follows player A and B follows player B
that is what will happen
Perfect!
why doesn't my bullet sync across clients
Component
i imported a flashlight asset into my project but the flashlight and the light emmited dont show up on the other persons screen (im using photon btw)
(PUN, to be specific)
You need to sync that with other clients through one of the methods present in PUN. If you don't know what is syncing something, then it probably isn't, and you need to do it yourself. https://doc.photonengine.com/en-us/pun/v2/gameplay/synchronization-and-state
Hey,
Im trying to make a multiplayer car game. I initialize the car controller from the Network manager. and here is the script for the car controller:
but only the host can control the car for some reason
the clients wheels turn and all but it doesnt move.
this is the prefab:
anyone?
😦
if I turn off interpolate in the network transform, it starts moving in the client window but the host player does not update in the client window
For A* and mirror is there any plugins that would sync movement or do I need to all movement events on the master client?
Or just say fuck it and let each client handle their movements?
Anyone know how to use Unity Gaming Services Lobby with dedicated game server instead of relay?? Im desperately searching for tutorials but theres none, almost all tutorials using relay instead of dedicated server
@elder umbra it won't let me use Unity.Netcode or NetworkBehaviour