#archived-networking
1 messages · Page 114 of 1
Hello I'm a network beginner and I wanted to know if there was anything wrong with my code (aside from what's already commented). Can I be sure the ServerRpc method can only be called on the object by the client that's supposed to call it for example ? In other words how can I make sure that one hacked client cannot set the player speed of another client ?
public class Player : NetworkBehaviour
{
public const float PlayerSpeed = 5;
// This variable does not need to be accessed by the client, how should I fix that ?
public NetworkVariable<Vector2> Speed = new(Vector2.zero);
public NetworkVariable<Vector2> Position = new(Vector2.zero);
private void Update()
{
if (IsOwner)
{
Vector2 moveBy = Vector2.zero;
float vertical = Input.GetAxisRaw("Vertical");
float horizontal = Input.GetAxisRaw("Horizontal");
if (vertical > 0) vertical = 1;
if (vertical < 0) vertical = -1;
if (horizontal > 0) horizontal = 1;
if (horizontal < 0) horizontal = -1;
moveBy += Vector2.up * vertical;
moveBy += Vector2.right * horizontal;
if (moveBy != Speed.Value)
{
SetSpeedServerRpc(moveBy);
}
}
if (NetworkManager.Singleton.IsServer)
{
Position.Value += Speed.Value.normalized * PlayerSpeed * Time.deltaTime;
}
transform.position = Position.Value;
}
[ServerRpc] private void SetSpeedServerRpc(Vector2 by)
{
Speed.Value = by;
}
}
In the unet thingy it says "For security, Commands can only be sent from YOUR player object, so you cannot control the objects of other players." does this also apply for ServerRpc ?
im working with netcode for gameobjects, and in one of my scripts I am unable to use the "using Unity.Netcode" even though the namespace exists, im using unity version 2020.3.24f1, is this a bug, or a stupid mistake on my part?
Same goes for netcode for gameobjects RPCs unless you manually disable the security checks with [ServerRpc(RequireOwnership = false)]
I need networking with photon help, Is there a way to create stuff like bots and server-controlled logic on Photon Cloud? if not, then can someone tell me how to make a simple Photon Server?
Could someone clear up how networking in Unity is handled, its clear that you can use an API such as Steamworks, but steamworks itself doesn't handle multiplayer logic such as key gameplay aspects like movement. Steamwork only handles the Steam side of things. So what can I base my network code on if steamworks doesn't have its own networking solution?
"Netcode for gameobjects" is what unity provides for multiplayer.
With steamworks you could couple it with a multiplayer library (like above) to string together matchmaking or whatever is needed on that front.
Mirror is also a very popular choice with its own server community and based on the original unity multiplayer solution, which includes channels dedicated to custom transports for steam, whatever is needed.
Ahhh I see, using Unity's Multiplying Networking I can simply couple that together. Thanks for the heads up I was just overwhelmed with all the other networking solutions and what one to best fit my project. Thank you so much :D
Hello I wanted to ask in photon
Exception: cannot serialize(): UnityEngine.GameObject
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, System.Boolean setType) (at <777d394ee91a4f2b8a63dcf0742e13c7>:0)
ExitGames.Client.Photon.Protocol16.SerializeObjectArray (ExitGames.Client.Photon.StreamBuffer dout, System.Collections.IList objects, System.Boolean setType) (at <777d394ee91a4f2b8a63dcf0742e13c7>:0)
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, System.Boolean setType) (at <777d394ee91a4f2b8a63dcf0742e13c7>:0)
ExitGames.Client.Photon.Protocol16.SerializeHashTable (ExitGames.Client.Photon.StreamBuffer dout, ExitGames.Client.Photon.Hashtable serObject, System.Boolean setType) (at <777d394ee91a4f2b8a63dcf0742e13c7>:0)
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, System.Boolean setType) (at
......
Bullet.OnTriggerEnter2D (UnityEngine.Collider2D collision) (at Assets/Bullet.cs:65)
What does this error mean?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : Photon.MonoBehaviour
{
public bool left = false;
[SerializeField] float moveSpeed;
[SerializeField] float destroyTime;
[SerializeField] float damage;
[HideInInspector] public GameObject player;
void Awake()
{
StartCoroutine("DestroyByTime");
}
IEnumerator DestroyByTime()
{
yield return new WaitForSeconds(destroyTime);
GetComponent<PhotonView>().RPC("DestroyObject",PhotonTargets.AllBuffered);
}
[PunRPC]
public void ChangeDir(bool dir)
{
left = dir;
}
[PunRPC]
public void DestroyObject()
{
Destroy(gameObject);
}
void Update()
{
if (left)
{
transform.Translate(Vector2.left * moveSpeed * Time.deltaTime);
}
else
{
transform.Translate(Vector2.right * moveSpeed * Time.deltaTime);
}
}
void OnTriggerEnter2D(Collider2D collision)
{
if (!photonView.isMine)
{
return;
}
PhotonView target = collision.gameObject.GetComponent<PhotonView>();
print("GG");
if (target != null && (!target.isMine || target.isSceneView))
{
print("AAAAA");
if (target.tag == "Player")
{
print("MMMMMMMMMM");
target.RPC("ReduceHealth", PhotonTargets.AllBuffered, damage, player);
}
GetComponent<PhotonView>().RPC("DestroyObject",PhotonTargets.AllBuffered);
}
}
}
My script that seems to be causing the error
Would making a multiplayer game in unity scale well? like will the performance be good even if I have like 5k players playing at the same time for example?
I need networking with photon help, Is there a way to create stuff like bots and server-controlled logic on Photon Cloud? if not, then can someone tell me how to make a simple Photon Server?
It scaling well is entirely on you. There are examples of MMOs made in unity scaling thousands, yes. How that is achieved and what sacrifices need to be made you will have to research yourself
What is the best solution to networking right now. I'm a beginner and I see that Unity has released a new MLAPI:
- new MLAPI
- Photon
- Mirror
For what use case? Photon also has a variety of different solutions (Fusion, Quantum, PUN etc)
I want to make a third person arena like game
It will have swords, bows, arrows, queue system, loby system, party system
Hi i have a question for yall
So i am using photon
And the thing is there is only a few object sync in photon view but all the process are going on in OnPhotonSerializeView
ex: player pos, player rot, player anim, player hp, etc. What im trying to say is there is a big load on OnPhotonSerializeView or should i create a photon view for every single data?
Why do i have tons of internal errors due to photon engine?
i am working on a school project, could someone help me with an issue im having? i have a multiplayer game where there are 2 players (using Mirror, LAN multiplayer). player 1 is a different character from player 2, how can i make them seperate so that they run scripts seperate. for axample, if playerone moves, player 2 stays.
i have tried IslocalPlayer, it did not work. hasAuthority also did not work.
I attached a Photon Transform view in the Child of a Photon view object. I can see that is is observed in the parent under Photon view. However, it is not working.
Any Ideas?
isLocalPlayer is what you want, sounds to me your implementation is bad.
Easiest way to do that is if(!isLocalPlayer) return; after the function being declared
Otherwise, paste bin your code, and someone can assist you further
Does anybody here have experience with Photon Networking for Unity? I'm having an incredibly aggravating problem and the official Photon Discord is somewhat... quiet.
https://pastebin.com/Sq8udDh6 and https://pastebin.com/khgLQGJH - about 200 lines of used code between them. My problem is that I keep getting a generated code starting with 04 (eu), even when the user is living in a different region of the world (eg. Aus, China, the US, etc).
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.
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.
ty!
Wassup people! I'm working a simple 2D turned-based game with physics and I'm starting to look into networking. I'm hesitating between going with Mirror and MLAPI. Anyone with a bit of experience to help me figure out which one I should go with?
actually now I'm considering hazel 
hazel has little to no documentation, mlapi or mirror for turn based would be a good fit, it really doesnt matter which
yeah
Now I'm trying to think if I want to just manage everything myself (hazel) or fight(learn) systems
if your stuff is turn based you probably dont have to fight anything, you could just use mirrors llapi network messages and be fine
im sure mlapi has the same thing
alright
sounds good
also quick question, any easy way to serialize/deserialize C# objects?
there are many ways to do that, most netcode solutions have built in methods that write default types to a byte array buffer
you can probably use bitconverter for most things but it probably isnt the fastest
but all the netcode solutions you listed have this stuff built in
Avoid BitConverter if you're doing serialization for sending over the network. BitConverter is made for convenience but it does a lot of allocations
yes personally i would use unsafe code and pointers to write directly to the buffer, was just suggesting something simple
can anyone help me?
Anyone know a reliable (or reliable-ish) way to have every player execute an action at the same time or nearly at the same time with minimum difference between the other players?
I am trying to have each player execute a function upon every player readying up, but I must have it be at the same time as possible since it is a rhythmic multiplayer game and players can see other players inputs.
Likely the import didn't go well or the generated project (for VS) is not OK. You could delete the generated .csproj and .sln files and generate them again. The VS integration is a package in Unity, so you could check if there's an updated variant.
Usually there is some sort of network synced time / ticks. Send an event to announce at which future time/tick everyone should start the game.
PUN supports a range of Types that can be sent via the network. It does not support sending UnityEngine.GameObject.
If you want to refer to some networked object, send it's PhotonView.viewID instead as reference.
Hey people!
I wonder if it is a good practice to store json file as string in a relational database?
I have to use RDS for my project but at the same time, I must store some data that vary each other
ok, because code suggestion and completion wasn't properly working too.
as well as hinting the class description and stuff
okay so im trying to get the basics of multiplayer with photon. is this right so far? ```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class NetworkManager : MonoBehaviourPunCallbacks
{
// Start is called before the first frame update
void Start()
{
ConnectToServer();
}
void ConnectToServer()
{
PhotonNetwork.ConnectUsingSettings();
Debug.Log("Trying To Connect To Server...");
}
public override void OnConnectedToMaster()
{
Debug.Log("Connected To Server.");
base.OnConnectedToMaster();
RoomOptions roomOptions = new RoomOptions();
roomOptions.MaxPlayers = 4;
roomOptions.IsVisible = true;
roomOptions.IsOpen = true;
PhotonNetwork.JoinOrCreateRoom("room 1", roomOptions, TypedLobby.Default);
}
public override void OnJoinedRoom()
{
Debug.Log("Joined a Room");
base.OnJoinedRoom();
}
public override void OnPlayerEnteredRoom(Player newPlayer)
{
Debug.Log("New Player Has joined!");
base.OnPlayerEnteredRoom(newPlayer);
}
}
Hey everyone, I'm using the new preview Unity package "Netcode For GameObjects". The issue I'm having is when spawning in a network object (in this case firing a projectile) the client has to communicate with the server using Rpc, this causes a noticeable delay for the client which ruins the experience. I'm wondering if there is a way for a client to spawn in a NetworkObject and then for it to be synced to the host/server.
I have tried a couple of solutions mainly experimenting with the client network transform (Which worked brilliantly for the player movement), but everything I try seems to always require the server to spawn the object.
Just wondering what approaches other people would take to tackle this issue.
With server authority, this behavior is the norm. The server does the spawning.
What you need to figure out (and I don't know how it's done in NfGO) is if you can predictively spawn something locally. To show the object until it's confirmed by the server. Ofc, if the server does not approve, you end up with an object that existed a few frames then needed to get removed...
Hello everyone
I created a deterministic lockstep networking system with rollback
for 2D physics only
if anyone would like to see it as a free resource let me know 🙂
ouhhh that's pretty cool
was looking into that stuff recently
What do you use for the networking? @grave ice
Hi everyone, I have a really simple question. Ignore the example, I know it's not the best practice to do it this way.
What went wrong with my code is that when i spawn the bullet, his target Attribute is reset to (0,0,0)
Why is that happening? Why is Spawn() reseting my attribute? What if I want, for example, instantiate a spear, set its dmg attribute and spawn it on all the clients, will my dmg attributes be reset to a default value?
if you did this for mirror (i recognize your name), please share!
if you want it to sync on spawn it needs to be syncvar
Oh, I understand now. Thank you so much for the answer, it's been bugging me for 2 days :D!
Can I ask you one more question about the spear.
I want to shoot a spear with my player, so In order to make that feel "right" I will first spawn it on Client side, by the player that shoots it, I will send the coordinates and the data for the spawning of the spear, and then I will spawn it on all the clients.
Next, in order to detect the collision and deal the dmg, I will say something like:
//OnCollisionEnter(){
// if(!isServer)
// return false;
//}
So the collision checks only on the server?
And btw, I'm making a third person Arena game, is Mirror a good choice? Is new MLAPI a better choice to learn for the future?
Thanks to anyone that provides the answers 🙂
mlapi and mirror are pretty similar, if you're using mirror you should just stick with it, also we have a big discord server where you can get questions answered faster (link is on google or in unity console)
you can use a client rpc and just send to everyone else while also spawning it locally
using excludeOwner = true
Mirror for networking
But the physics engine and the rollback handler are network independent
have you tried MLAPI yet?
I actually haven't. The only downsides I can find about Mirror vs MLAPI are:
a) non-official support in Mirror vs official support.
b) Mirror uses Weaver which, under the hood, uses Reflection and isn't preferable.
c) Mirror's flagship TCP transport, Telepathy, does not use native networking code (transports written in C#) and it uses one thread for each connection (KCP may be a better solution)
Did I miss anything?
Both Mirror and Netcode for GameObjects (MLAPI) use a mono.cecil based weaver.
I did not know this! Thanks! I guess b) is a non-concern then.
Some people are saying that mlapi isn't finished and I'm trying to hear from someone with actual experience if it's good enough for most use case or not
depends what you expect from it, its perfectly fine to create your average multiplayer game but it definitely isn't a turnkey solution, has fewer high level components and requires you to know a little bit more about architecture and netcode principles than other packages out there. I'd expect any multiplayer project to eventually requite a good chunk of DIY no matter what framework you choose.
That's what I want actually, I'm thinking of managing everything myself anyways
i'd say netcode/mlapi gives you a lot of room to work on the details but gives you a robust set of the usual abstractions you'd want in any case, but no more than that
have done two projects with mlapi/netcode and three with mirror
Is netcode the same as mlapi?
quite
Oh
netcode is essentially mlapi with some minor improvements since the rename
netcode for gameobjects that is
Does anyone know how to implement loading screens for the entire lobby? Like for example fall guys where everyone is put into the same map
I'm using photon 2, what's the best practice for using and synchronizing navmesh agents and their animations? My first try was putting a photon transform view on the parent object, and then using rpc's to update his position for all players, but this caused some lag on secondary players. My second attempt, I put a transform view on the actual mesh, but there are issues trying to update his position with RPC. I'm thinking instead of leaving the transform view on the mesh render object and instead letting only the master client update the navmesh agent and call functions like hitboxes
mlapi was the new thing, then unity bought it or whatever happened there.. if you want official support go with network for gameobjects.
and I would imagine if you want support from the hobbyist who created it go with mlapi
but who knows how available he is now after that whole deal
you generally don't want to use RPCs for movement you're spamming the network with stuff that should be streamed I feel (but I have no idea best practice for pun..)
last I used pun was doing the read/write for AI positions
oh ok
but it's legit to use netcode?
it's good enough to be used right now?
I mostly just need low level apis anyways
idk why but the Unity Transport seems sus
maybe it's just the name
between me you and the trees I'd run from it, full sprint
photon just released their replacement of pun/bolt as a state transfer sdk and it's fabulous.. beats them all imho
simplicity might be your target, whatever you like
I know mirror has a large community, been around for ages.
just that, looking at unity's timeline.. who knows where it'll end up during your dev cycle you know?
meh, I'd rathe run my own servers
I guess I'll go with mirror then
I get that, understandable. I hope they make that more accessible in the future as they've discussed.
solid choice. 🙂
I keep switching back and forth lmao
the more I read the more I cry
I should just get started
yeah you'll know which you like as you get your hands dirty.
mirror definitely has that community support that can't be compared.
thing is, I already know that I'm going to hate it no matter what lol
I might just ignore everything and just send strings
do all the serialization/deserialization myself
then, at least its your own mess and nobody to blame 😉
Thank you for the response, I think I'll look into that since I kind of want to use rootmotion anyway, and that might be much tighter
Does anyone know of a good Photon Fusion tutorial for VR? Photon's documentation on Fusion is awful (I followed their tutorial, but their sample VR project is totally different than what was taught).
Hello, any ideas why it shows warning? I'm using netcode with relay
Multiplayer is working fine btw
Is there any specific step you are stuck at? The VR Dragon Hunt should not be drastically different. Is it? Feel free to DM me or follow up on the Photon Engine Discord.
Help?
does anyone know why am I getting this error? (Rpc)
Unity.Netcode.NetworkBehaviour.get_NetworkManager () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.4/Runtime/Core/NetworkBehaviour.cs:219)
rpc.MessageClientRpc () (at Assets/rpc.cs:51)
rpc.Update () (at Assets/rpc.cs:24```
```csharp
[ServerRpc(RequireOwnership = false)]
private void MessageServerRpc()
{
if (NetworkManager.Singleton.IsHost)
Instantiate(SpawnThis, new Vector3(3f, 6f, 3f), Quaternion.Euler(new Vector3(0, 0, 0)));
else
Instantiate(SpawnThis, new Vector3(-3f, 6f, 3f), Quaternion.Euler(new Vector3(0, 0, 0)));
//Debug.Log("Ive Got This Running In My Server");
}
I did reference SpawnThis and serialized it.
so if say I enable that object in one (players) scene view Every scene view will be updated?
I have used transform view but am not sure if it is only for position,scale,rotation or everything
potentially yes but I never used photon
This sounds a lot as if you should follow the PUN Basics tutorial once.
https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial
Enabling/disabling of objects is not automatically synced.
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
that's why I asked, I have read a lot of the docs and watched a lot of tutorials
I am a beginner (in multiplayer)
But the thing isn't just about disabling the object I want to treat it as a single entity across multiple scenes where any action of one scene is synced in every other
To be more specific I have a canvas that needs to sync if it is enabled or not, a text which is the same story
Well, if you don't plan to track some object / transform, don't use a PhotonView. It's easier to have some key/value pair in the Custom Room Properties for stuff like this.
Ok looking
This state is independent from GOs and scenes. It simply is part of the room's values, so anyone can make use of it anytime.
You can set multiple key/values in one step. Keep the keys short and don't use very long variable-sized values and you're fine.
Ok thanks!
Also, do these custom properties are synced in just one lobby or every lobby?
tobi?
Cause in the docs it isn't that clear (or maybe something is wrong with me)
What line is the NullReferenceException occurring on?
line 219
@bright mauve Did you add the NetworkObject component to the GameObject that you're running your script on?
you are the king who brought me the idea.
i tried having the function being called on the NetworkManager gameobject.
i tried moving the code from there to a new Manager Asset and than added a NetworkObject component to it and it fixed it.
thank you so so much!!!! really!
@bright mauve Oh, I see. I received the same error before, so I understand. I'm glad I could help in some way, good luck with your project!
The spawner object in the Hello VR project does not implement INetworkRunnerCallbacks like the tutorial does. I have not looked at VR Dragon Hunt because I thought Hello VR would be more basic. I'll take a look at it.
Thanks you legend
hi guys 👋🏻
i dont have any idea about networking but i will make my game multiplayer but on LAN network not online is just local network but i didnt found any good tutrials about LAN networking is that hard like online networking or its easy to learn ?????🤔
it's pretty much the same thing
the difference is that you don't have to provide a server, you'll need an interface for your users to put an IP and port
Might not be necessary in every case if you get LAN broadcast to work
But these things are pretty trivial, nothing compared to actually making a game multiplayer, and that process should be pretty much the same
networked things are always considerably more difficult than things that aren't networked. it is all learnable depending on your tenacity and your tolerance for frustration. Networking is easier when you do not have to build the entire stack yourself, when it is not realtime and when you can trust all participants in the network.
whether its lan or internet, technically, doesn't matter for how hard it is, the main factor in the end is: "how much do i trust the messages i receive from the network". The other annoying thing with networking is that you cannot make assumptions about the presence of your resources, all messages and resources can go away at any moment and expected state may be different from actual state for all participants of the network... so depending on how big/public/robust/safe you want that network project to be... networking can be trivial, or worthy of multiple PhDs.
Hey, I have 2 players (running on the same computer) playing the game but it is so disconnected what should I do?
Do you want me to send any movement and shooting scripts?
I am using photon
Like every action happens in every window but the difference is usually about 45 seconds
how can I serialize GameObjects so I can send them through Rpc?
adding [SerializeField] still gives the error:
Assets\rpc.cs(59,55): error - Don't know how to serialize GameObject - implement INetworkSerializable or add an extension method for FastBufferWriter.WriteValueSafe to define serialization.
are you joining through your local router/network or are you trying this on localhost?
test your game in the unity editor. if it works smooth there, than the device you got is probably too weak to run unity games in the size that you made.
does anyone know?
it is running smoothly on both windows and individually but the multiplayer aspect is really out of sync
isn't [SerializeField] used to add a field to unity window?
is it also out of sync in the editor?
Yep everywhere
As the error suggests the network stack doesn’t know how to serialise it. What network stack is it?
Just ask, someone may be around who knows Photon
Anyone here good with Playfab/fbapi errors?
If so, When trying to log in using facebook I encounter two problems. One is Pipe name not passed to application on start. and the other is that FB.Init() initializes but straight after it says it isn't initialized. Any help would be great as I'm stumped on how to sort it out. I have tried looking online however it comes up with old solutions which don't work
What do you mean by "network stack"?
@bright mauve the netcode framework you're using
Network framework, network stack, network library, same thing
I solved this anyways after changing it to a "sendablenetworkobject" or something like that.
However i am also getting this error when trying to serialize a strinf array...
Netcode for gameobjects / pre4?
Or unet tranport for the protocol
i think NGO dropped support for strings
someone else can chime in here
Or at least, in its current state, it doesnt support strings
A string is an array of chars kinda, and also its not an official c# type i think
Or it is an official type but not an official memory tool?
I know strings are a default type, i'm saying NGO/MLAPI recently removed string serialzers from their code, i assume they will add them back eventually
Anyways, how should i send a string array through Rpc? @mortal horizon @shadow spoke
I don't use NGO, you're better off joining the official discord for it and asking
Being unable to send strings is a dumb move
Why would they do that
They told me just make a char array
Yes that is so dumb though
Or maybe just go to byte array
welcome to unity lol
They also said i could use a fixedstring but its very inefficient
Yea, only today i posted an answer to my 1 week old question on the forums and found out 800+ people were following it. I was the first reply😂
How would that work?
Uhh
A byte array would maybe save a string but not an array string
Oh right
Because I CAN send a normal string. Just not an array one
For some reason
An int array can be serialized if that helps
perhaps there is a better way to serialize what youre trying to send?
A list of player names
List<string> ?
From the server to all clients through clientRpc
Sorry, i meant an array of strings, that contains all player names
A string[] names;
Move all names to list, send the list, move the names back to a new array?
Just use the list for play names and change your code to do that?
Otherwise you introduce garbage collection and potential frame hiccup
Maybe i should just use dictionaries if already rewriting data structures
They are binary already and very easy to work with
You’re welcome
@mortal horizon also thank you
Although I find it really stupid you can’t send a string[]
That’s like… why the fuck would you not want that
I can understand that though
Because
In c# the built in data types are all the ones we know (char int double) but string isn't a part of it.
I mean, it is, but in the memory it is not
Unity just went and probably wrote the serialization with their own serialization tool, so they already did everything with the same one and did not add one for string
Since string is just a char array
And an array of strings is an array of a char array
Also that would still be very useful and still dumb there isn't one
u can just encode it yourself, example a = 1, b = 2, c =3, then cast number as byte, insert into array, boom lol
(this is a joke but it would probably work lol)
Ever heard of ascii?
hi guys, semi network related question...
im trying to add modifiers to player when theyre hit with a projecticle, the modifier is applied correctly but everytime a modifier is added to theplayer even if it is the same one a new entry in the list is created, i think because it is a different instance of the modifier
when the same modifier is applied to a playerthat already has that modifier active it should just refresh the duration rather then add a new modifier it to..
im doing this atm ...
{
localActiveModifiers.Add(modifier);
modifier.OnCreate();
modifier.ApplyModifierEffect(gameObject);
modifier.durationRemaining = modifier.duration;
RpcOnModifierAssignedToPlayer(modifier);
Debug.Log("modifier doesnt exist, creating it " + modifier.name);
}```
Congratulations you got the joke 🤣
general question; do yall have any good resources on learning about setting up networking? (such as for an mmo for example, being able to join "rooms"/"worlds"/"servers" that are separate.
saving and loading to.. somewhere. etc.)
I'm still quite aways from doing this sort of thing, but would love if someone could point me in the right direction. cheers.
https://dev.epicgames.com/en-US/services anyone here running an online game, use this?
if so, how is it? are there better free options out there? what sort of limitations are there?
What would be the difference in having my serverrpc change a neworktransform, and it changing a NetworkVariable<Vector3> Position and then in the next Update function assign transform.position to Position.value?
Mirror? Not familiar with that, but I suspect using the NetworkTransform giving you stuff like interpolation. Since network updates usually are low (like 10 ticks per second) you will get choppy movement if you change the position without applying interpolation
with Netcode for gameobjects
Also not familiar with that but the answer probably will be about the same. Best is to either read up a little or maybe wait for someone else who knows that library to answer
soudns good thanks
I'm using photon, using navmesh agent enemies that will follow certain players
What's the recommended way to set destinations to certain players? I was thinking of not using transform views on the agents and just setting the destination to each player, to prioritize smooth animation over exact position, and then using an observable transform, but the tricky part is getting the variable for a particular player
guys where do i go to learn about the pricing of a multiplayer game's server rentals
Plenty of options, here are some popular ones:
easy to use: https://www.digitalocean.com/
complicated big boy: https://aws.amazon.com/
complicated big boy: https://azure.microsoft.com/
cheap virtual-server: https://www.hetzner.com/
photon-specific: https://www.photonengine.com/Server/
Helping millions of developers easily build, test, manage, and scale applications of any size – faster than ever before.
Amazon Web Services offers reliable, scalable, and inexpensive cloud computing services. Free to join, pay only for what you use.
Invent with purpose, realize cost savings, and make your organization more efficient with Microsoft Azure’s open and flexible cloud computing platform.
Redistributable cross platform multiplayer game backend for realtime games and applications. Develop authoritative logic with SDKs for android, iOS, .NET., Mac OS, Unity 3D, Windows, Unreal Engine, HTML5 and others.
Bump
Hi to everyone, if someone could be so kind for tell me or show me how can I do a lobby system with MLAPI, because i'm searching and thinking but i don't know how i can do it.
Thank you advanced
the netcode (=MLAPI) demo project "Boss Room" has a lobby (sort of) https://docs-multiplayer.unity3d.com/docs/develop/learn/bossroom
Learn more about installing and running the Boss Room game sample.
in any case, a lobby is just some rules applied to players on a server. Same as any other gameplay rules you'd implement.
I watched the video is exactly like i have made in the project, but i want it with a list where the user can see the room that are playable, and just clicking with button can join without put the ip of the player. I don't know if i explain good xd
sounds like what you want is a relay https://docs-multiplayer.unity3d.com/docs/relay/relay
Netcode for GameObjects (Netcode) allows you to connect to a host by its IP and port. However, if the host is not on the same network as you (i.e. somewhere over the Internet), you will need some extra services to achieve a successful connection and thus a successful game.
Sorry for the bad design, but it's a quick design to explain.
Ok, I'll try to explain it clearly:
When a player presses the button to create a server, I want that when that happens, the rest of the clients can see that room has been created and they can join by pressing the "Press for join" button and then the player who presses the button can connect to that room without putting the ip of the room, just by pressing the button he can join the room.
I need to know how I can get a list of the room made for the users and list the rest of the players there.
I am thinking about this, but MLAPI has nothing about lobbies.
I hope you can understand what I want to do. (It is not a relay).
Best regards
its either a lobby (handles as regular gameplay rules via RPCs and such on a single server) or it is a separate interface that makes use of a relay service (main purpose is publish/discovery of server addresses).
whatever a room is, depends on your particular game/app's architecture
been getting "Could not get NetworkObject for the NetworkBehaviour" errors for hours now
I have my server build running outside unity, and whenever I join as client and I spawn my player (barebones spriterenderer, networkobject, a script inheriting from NetworkBehaviour), as soon as it spawns I get spammed with that error. I have tried everything I can think of.
its using mlapi1.0 (netcode for gameobjects)
It does not happen when my server is running inside the unity editor
Hey guys wanted to ask does Unity MLAPI have p2p
if not, are there any other p2p networking solutions for unity
Been trying to implement Knockback/Explosion into my Photon FPS, I'm using RPC calls to the client to tell the player when to get hit by knockback, but the player is unaffected by any explosions.... and there is no knockback for the player...
You can have player hosted games (listen server model). If that's what you mean by p2p.
no. I mean completely p2p
like steamworks.NET
No it doesn't support a direct p2p model. There's always a host client which acts as the server.
look what TIL https://unity.com/products/lobby
I'll need to pay for this service in a future? Because in the web say "cost-friendly". Thank you for the help
hi guys 👋🏻
i dont know any thing in networking but i want to make my game playable on local network and i searched in whole youtube and i didnt found any good course for Local Networking IDK what to do ??
please help guys
It's the same as any other networking except you connect to a local IP
I have made a script that changes the materials on a players weapon based on the players playerprefs but how do i make the materials sync over the network and not just show the materials localy?
hi guys, wondering if anyone can give some advice an architecture question. i have a spellmanager (there is one in the scene) that contains all the spells in the game, when each player character loads into the game they look at this list and grab the ones they need for their character (just a string lookup on the name of the spell, then they copy it to their local spell list)
at the moment, i just have 2 spells and 2 of the same characters, both characters are sharing the same instance of each spell, wondering how i can create a new instance of a spell and copy it into my local spell list? or maybe i shouldnt be doing it this way
guys i made single socket program in unity , but its get freeze when client connect
should i use c# prebuilt socket or the library given by unity unet
Hey, does anyone here used photon for mobile games ? And how can i test it on my android device through wifi since it doesn't work with lan??
I have build the game on my android phone and when i try to run it on my phone and the pc editor my objects wont clone even tho the both device are connected to the same internet network ??
Hi everyone,
I am looking to engage an expert in multiplayer server architectures to help with the design of a play-2-earn game.
A successful applicant will be able to articulate the pros/cons of numerous commercial / open source game servers and will be able the help identify project risks and limitations of each approach.
If you are interested, please send me a message with your relevant experience and rate.
thanks
I am using PUN2 and having some sphere colliders 2d with rigidbodies and I am syncing their rigidbodies throught the network with the photon rigidbody view. But when the master client pushes an object he pusheds it much easier than the other clients for some reason. Any suggestion?
Can i ask a question, are you testing pun2 on mobile or localy on you pc ?
I am testing locally on my pc
Have you tried it on android mobile ??
no but I am guessing its the same
Hmmm I don't think so, I'm trying to test on my phone it does connect to the server but nothing clones or sync 😕
It's connected to my device local ip address
I don't think it matters. Have you setup the photon wizard with your appid? The phone will connect with the photon server I think. If you use connect with settings. If you are making lan I don't really know how it works
Hello ! Would love to say I'm here to give answers but I'm kind of a newbie to dev, now I'm looking to know WHAT should I know to choose a good networking solution for a potential game, I already read about Mirror, SmartFox and other
But really I'm not sure I understand that much how it works and what should I be aware of (CCU, low or high level API, compatibility with OS)
Any advice, any link is welcomed
I made it work thanks, for those who also wanna try this you have to download photon-server-sdk and in the controller change (game server ip config) to your own devices public ip
Does anyone have recommendations for a good dedicated server host for mirror
Linode
Hiya, trying to do one of these:
UnityWebRequest.Post("ipgoeshere
/LoginTest.php", form)
And I keep getting a 500 error, which isn't particularly helpful.
Using a google cloud web server, and attempting to pass a username and password to the php file, which compares it in a database
Web server using apache2, php7.4, mariadb, mysql.
Is there something I should be doing on the Unity side for any of these things?
It didn't have any connection errors when I was using localhost and apache/sql running through xampp (instead of an actual web server)
It's kinda weird too because my apache2 access log is showing that unity connected:
hey, nevermind :)) got it working.
hello guys how are you doing, I hope you are doing well. So I wanted to ask about something, I am making a multiplayer game and I'm going to proceed with photon Pun but I didn't make a save system or nothing. So if the player bought something from the shop and equipped it and then restarted the game everything will be reset and nothing is saved. So I'm asking if the save system should be made with Photon like storing the data of the player or something and what it's called ?
is photon pun 2 deprecated, and should i switch to fusion?
is someone can help me with photon 2 pun, i'm trying to destroy an object but I am not the owner of the object. Is that possible to say everyone can destroy object with Photoview ?
hello, i would like to know is fishnet better than the other? and is it harder?
Is there a difference between CCU and current logged users ? Just to know
Same thing
but you would say the users have an "active network connection" with the game rather than "logged in" (but I'm just nitpicking I guess)
Ok, so as far as I know, if I would like to make a MMORPG (just example) with rooms sustaining up to 500 players, I should for servers up to what : 500, 1000 CCU ?
A room with 500 users connected at the same time will hit the 500 CCU limit, yeah
Then you also have the DAU (daily active users) and such to take into consideration
You'd need a game so popular as having thousands DAU to hit 500 players at the same time
CCU works per server or per room ? With a 500 CCU limite can I have 2 rooms of 500 CCU or would it be limited to 500 CCU across all rooms ?
We target an already existing community with at least 6000 ppl active, we just want to try something new and see if it works at a small scale then we'll think bigger
Using which network solution ? One from Photon engine ? I assume that would be per server
The connection is handled from the whole game/server point of view, not per room if I'm not mistaken
Don't know any provider that offers per room quotas, but I don't use the mainstream ones
Well that's why I'm asking ppl who know better than I do because it's not clear on Photon doc neither on SmartFox doc. Now it becomes ... easier to understand ! Thanks.
So far we thinking about 3 solutions, since even if it's not, it would work kinda like a MMORPG. So, we have in mind Photon Fusion (because of its dedicated Unity API), SmartFoxServer2X and, even if my knowledge isn't deep enough yet, uMMORPG solution with Mirror API
Yeah then don't listen to me, that would make sense to me, but can't say for sure 100%. They also have their own discord if you need faster support.
That's a pretty good idea, do you others potential multiplayer solutions I didn't though about ?
I made a trail renderer that flies from one players gun to the raycasthit position. everyone can see the trail renderer ingame as it instantiates as an RPC but the position of the Trail is not syncing across players. I have tried placing a Photon view and a transform view on the trail renderer but that doesnt change anything apparently. Any idea how to make this possible?
is someone is good with Photon pun ?
don't ask to ask, just ask!
is someone can help me with photon 2 pun, i'm trying to destroy an object but I am not the owner of the object. Is that possible to say everyone can destroy object with Photoview ?
Hi, just finished my networking stuff after hours only to find it doesn't work after I build the project :|
Is there any way to check the console output in a webgl build?
Not sure if these could have anything to do with it?
Anyone got any clue?
what is the best Multiplayer host for FREE? i have tried Photon my players LAGS like idk
Let me copy paste my reply
- There are no free hosts. Unless it's your PC.
- Photon isn't a host.
- It will lag if you don't know what you're doing.
then what is Photon
Networking framework.
A framework
and to the 3. idk what i am doing
then how do i make a multiplayer game i am new
Then you shouldn’t be doing multiplayer
You don’t
I'd agree with that. Should learn unity basics first and release a single player game or two.
why i have made it work with photon its my movement script that is broken
i have learned unity basic
But if you're desperate, there are plenty of tutorials online.
yea but idk what is good or bad or Free
If you don’t know what you are doing it’ll lag a lot. As for free-ish multiplayer servers only photon comes to mind. You could try p2p. Alternatively I’ve researched that yahoo games network is free but there is no documentation on it and only one video covering it.
There's nothing good or bad for free.
is it good?
what is p2p (Peer-to-peer)?
Research it.
ok
As I said, there’s no documentation on it, and only one video that covers anything related to it. You’ll have to research it on your own.
https://www.youtube.com/watch?v=4Mf81GdEDU8 is this good?
This Unity Multiplayer tutorial will teach you all about the new official Unity multiplayer solution and how to get it set up quickly in your own project!
Multiplayer Course: https://www.udemy.com/course/unity-multiplayer/
----------------...
MLAPI
oh ok
I barely know anything, just research it on your own
But i dont know what to look after
That's why we research...
You will learn what to look for
Multiplayer is not a walk in the park
ok i will look for NetCode
??????
That's a figure of speech, multiplayer isn't easy
It means that you have to sit at home if you want multiplayer.
Hey there, when i fire up a new project in Unity 2021.2.8f1 and just import the "Netcode for GameObjects" package by name as mentioned on the Unity websites I get the following warning in the console: Script 'Packages/com.unity.collections/DocCodeSamples.Tests/CollectionsAllocationExamples.cs' will not be compiled because it exists outside the Assets folder and does not to belong to any assembly definition file. What exactly does it mean? And how can i fix it to get rid of the message?
Yes I keep getting that warning too actually
ok but i am new to unity came from Roblox Studios(LUA) with multiplayer to unity (C#) so yea
Then you shouldn't even be thinking about multiplayer, you're shooting yourself in both feet
hey i need help trying to make my game multiplayer but im not exactly sure where to start or what to do
ok so DELETE all my hard work from yester day like 5 hours?
You say that like 5 hours is a lot of work, I've deleted more
5 hours is not a lot. Feel free to delete it.
You call yourself a newbie, who can't even Google shit. Yet you want to make a multiplayer game
See the problem?
yea me dumb dumb
Right then, don't even consider multiplayer yet
but i want to play with friends
You're in luck, there's thousands of games online you can play with friends
I have been experimenting with Unity Netcode for Game Object for the past few days and I have to say that I had a blast and in the meantime I am going to be posting videos as I learn more about how to use this new Unity Multiplayer solution when making games or apps for clients.
Some of the things we will cover today are:
- Overview of our Unit...
I would recommend starting by watching this
Tbh I am of the belief that you should have at least one, fully finished singleplayer game before you try anything like this
but they are BORING so i have to make my own
i was about to ik it was not to me
But you just ignore the warning?
Have done so far, it's a little bit annoying though
If you're ready to contribute a few month/years to learning gamedev and developing your game, then perhaps you'll be able to play with friends eventually.
You see the problem here is one a lot of people suffer with, it's called scope
Ok so i wait and learn?
Not wait. Learn and work hard. Learn to research things on your own first.
ok
So I'm having a really peculiar problem with Photon.
I'm setting things up so that when a player joins the game, a Player object is set up as them, with their cards set up and all. The draw button (for now) simply shows the a card for both of these players just to make sure both players are in the game.
Actually entering the game works fine. You enter and it spawns set object. But when clicking the draw button, both game instances show different cards, as if the pairs of players are completely unrelated to each other.
Okay, new question:
does Netcode for GameObjects support room instancing in any capacity?
e.g instancing a private room on a single server instance
Hey um quick question. Im not really good at game development but im really interested in game networking. Will i encounter any major problems while trying to learn networking for games?
I can sort off understand whats going on
You have two options. You can use an existing third party solution, or you can write your own. Unity might have a solution but I haven't heard too many good things about unity's past netcode solutions. Maybe things have changed.
I did the second option for myself. Took around a year to get the core down but I'm a slacker. Huge payoff in the end. I also had no idea what I was doing when I was starting.
Well I’m using unities new networking solutions rn
Do you guys suggest I use a client authoritative system or a server authoritative system
For a simple multiplayer game
I’m struggling to understand how a client authoritative system is better
It depends on what your making tbh
it’s just a basic free roaming multiplayer game but my only worry is if the master client connection affects the game at all
I’m using Photon and basically i’m instantiating NPC game objects to the master client and wanted to know if the client lags will the NPC lag too?
Oh photon is client authoritative
Hmm
I’m guessing yea. Cause it’s the client that sends the data
So if data gets delayed then it’ll be delayed for the others
yeah that makes sense
thanks
You have to synchronize the deck / cards somehow. If the game is not very competitive, you could share a random generator seed in the Custom Room Properties and define a fixed and deterministic logic to deal the cards, based on the seed.
Alternatively the Master Client does this work and tells the other(s) which cards go where. This is something you need to synchronize with your code (it's not done automatically).
https://doc.photonengine.com/en-us/pun/current/gameplay/synchronization-and-state
Hey I don’t know if really anyone would be able to help at all but i’m making a multiplayer project with photon. I’m struggling with RPC functions, im trying to send a message that when player1 presses space it makes it player2 turn and when player2 presses space it is player1 turn, but when i want player2 to do anything it won’t work.
Unity Docs
https://docs-multiplayer.unity3d.com/docs/getting-started/about
Mirror Docs
https://mirror-networking.gitbook.io/docs/community-guides/video-tutorials
Netcode is a mid-level networking library built for the Unity game engine to abstract networking. This allows you, the developer to focus on your game rather than low-level protocols and networking frameworks.
Hello There, I am legends games currently working on a football multiplayer game called yarnball i am calculating the angle between the player and the ball i am trying to get the ball to move inverse of the player's angle
{
direction = target.position - transform.position;
Debug.DrawRay(transform.position, direction, Color.red);
angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg - 90;
//Debug.Log("Angle: " + angle);
Quaternion angleAxis = Quaternion.AngleAxis(angle, Vector3.forward);
transform.rotation = Quaternion.Slerp(transform.rotation, angleAxis, Time.deltaTime * 50f);
}```
```void YeetBall(Rigidbody2D rb)
{
CalculateAngle(personToHit.transform);
Vector2 dir = new Vector2(angle, angle);
gameObject.GetComponent<Rigidbody2D>().AddForce(dir * angle);
Debug.DrawRay(transform.position, dir, Color.green);
Debug.Log("Force: " + gameObject.GetComponent<Rigidbody2D>().velocity);
}```
so it would actually behave like a ball and i didn't want it to be just a rigid body as it wasn't very realistic
it is a little wonky to say the least
this is happening with the current code
and i am having some issues with syncing up the score if anyone could help me out that would be great! thank you very much in advance
How would you make a kill counter? I have a system that does damage to the thing you hit but doesnt take any information of if the player was killed or not so idk how to make a kill counter.
That depends on the networking solution you use. There are plenty.
Hello. I have an issue with NetworkList and couldn't find a solution online, where it keeps adding the same value over and over again. If I have a server and two clients, this issue only affects the first client. Player prefab contains a script Player.cs with NetworkList<int> Hand variable that is initiated inside Awake method and can only be read by Owner. Then I also have a ServerManager.cs script, containing a ServerRpc method which (to simplify for the question) runs the following code:
Player player = NetworkManager.Singleton.ConnectedClients[1].PlayerObject.GetComponent<Player>();
player.Hand.Add(3);
Integer 3 is then being added continuously as long as the client is connected, even though it is called only once.
As previously stated, this only occurs for clientId=1, if we call this code for any other clientId it is correctly called only once. Also, if there is only 1 client, it works as expected.
Any ideas what could be causing this?
After playing with the code for a bit I found that what's basically happening is a new deck is created everytime a player joins. My current goal should be that there should be only one instance of the deck available for the entire network (or, well, game, you get what I mean)
Now it is partially working the way it's intended: when a new player joins, their hand is filled from the same deck, but now I'm getting these errors, where it doesn't seem to be able to access the same object as the master client
You‘d have to show more code to get an answer
That's pretty much the entire code. Had a method listening to changes, e.g. Hand.OnListChanged += HandChanged, which only contained a Debug.Log call. The only further thing I found out was that ReadDelta kept being called by Handle, which invoked the changes and triggered HandChanged method.
I changed the approach since then to achieve the desired effect, so (atleast for now) I avoided the problem.
ok i'm really not sure where to go from here
Hi, I'm a bit stuck. I'm trying make a simple ball-rolling multiplayer game where you control a ball with WASD, using a rigidbody with AddTorque. I tried to use MLAPI and Mirror and I have the same problem with both: When I activate client authority the movement feels great and responsive but there are no collision-effects between the players. It feels like you hit a solid rock. When I disable client authority and add the torque via ServerRpc for example collisions work great but there is heavy input lag, and general jitter/stutter on the client, even when running both, Host and Client on the same machine.
Now I understand why this happens (Server calculates physics so physics are accurate - collisions work - but Client now has a delay) but I don't know what I can do to fix this.
Any help is greatly appreciated!
If anyone knows photon If i want to assign teams to new players like: the 1st, 2nd and 3rd is team 1, is on team 1, 4th, 5th and 6th is on team 2, how would i assign that?
You would need to make your own Team Manager which could be as simple as tracking PUN Object IDs that represent the player.
For example, in my project, I have a dedicated TeamManager singleton that runs on the server for adding/removing/switching players in teams and can load-balance (simple if check to determine which team to put them in
Team Management and stuff is higher level than Photon level, no network library features that out of the box because it can be very specific for your type of game.
If you have an understanding of C#, C# Lists, maybe a few structs and able to hook into the network library then you should have a crude working prototype of such a system within say... 3 hours. It's tricky, but not rocket science.
I asked a few people and that seems like a cleaner solution but they pointed out that i could use RPC to tell players what team they are would that work?
if(PhotonNetwork.CurrentRoom.PlayerCount == 1)
{player = 1;}
Anyone know which network asset for multiplayer (mmorpg) are recommended for production 3d game
hey guys does networkList work rn?
if it does I need some help with it cause my client cant read the values
ummorpg
u mean mirror
ummorpg is a full mmo solution that uses mirror, but yes
Did anyone tried using SocketIOClient package with unity? I've installed it with NuGetForUnity and currently trying to fix this errors:
Multiple precompiled assemblies with the same name System.Text.Json.SourceGeneration.resources.dll included on the current platform. Only one assembly with the same name is allowed per platform. (Assets/Packages/System.Text.Json.6.0.0/analyzers/dotnet/roslyn3.11/cs/zh-Hant/System.Text.Json.SourceGeneration.resources.dll)
Any advice would be appreciated.
Hello!
I have 10 organizations and all of them have courses and students can enroll to those couses
Is this diagram good? or should I bound 'student table' to the 'organization table'
because organizations, too, might possess students.
This completely depends on the reality you are modelling and the requirements of the system
Before we make a schema for a big project, is it wise to map out with ER diagram?
Or could it be done on the way with schema?
@austere yacht
Personally I like making one as it helps thinking through the whole structure… when the initial system is set up that document gets abandoned and has served its purpose.
thanks
If it's okay I'd like to bump my question.
i was doing a multiplayer tutorial when i got this error```cs
photonView.RPC("AddPlayer", RpcTarget.AllBuffered);
NullReferenceException: Object reference not set to an instance of an object
gamemanager.Start () (at Assets/scripts/gamemanager.cs:40)
did you assign photonView and RpcTarget?
they should be assigned with ```cs
using Photon.pun;
so they come from the package? and not your own variables?
yes
and they work on other scripts
but are not working on this only line of code
wait i think i know what is wrong
ok solved
anyone here an expert on rollback / lockstep deterministic networking?
I'm looking for a short (1-2 hours) paid consultation, DM me
for an online mmo, would you typically use multiple scenes for the world or just one?
is it possible for scenes to exist with or without ppl in them?
ex: scene1 is an island, scene 2 is a town by the shore, can the scene(s) coexist in multiplayer? as in, if someone is in scene2, and someone is in scene1, either player could go to scene1/2 and find the other player
or are scenes only used locally (ie for singleplayer)?
Does anybody know how to find a gameobject with a specific photonview.viewId? i tried this:
foreach (PhotonView pv in PhotonNetwork.PhotonViewCollection)
{
if (pv.OwnerActorNr == 1002)
{
PhotonView.Find(pv.ViewID).gameObject.transform.root.GetComponent<playerController>().GiveKill(); <--- this is line 1970
}
}
The error is:
NullReferenceException: Object reference not set to an instance of an object at Assets/Scripts/playerController.cs:1970)
I dont know how to make it right as the error doesnt help me.
Having 1970 lines in a single class is utterly ludicrous
The error is a simple NRE, I imagine a few things there can be null
The photonview.find has a definition that it will return null if it was null but doesn’t that mean it shouldn’t send an error?
Ok so if find returns null, you then try and do null.gameObject.transform...
See how that just doesn't work?
Oh yeah
But how would i make it work then?
Well you should split the line up, the Find and GetComponent can both return null
So if you store them as variables, you can check if they're null before trying to use them
Splitting them up will also let you find out which one is returning null
Well in this case the getComponent cant return null as the transform.root of the photonview always has that component
That is an assumption, which might not necessarily be correct
The best thing to do is to split them up into their own variables, so that you can check what is null
ill test it
So i tried It. It was no problem with the Find actually. It was wierd because sometimes it found the getComponent and sometimes it returned null and idk why
foreach (PhotonView pv in PhotonNetwork.PhotonViewCollection)
{
if (pv.OwnerActorNr == p_actor)
{
int ViewId = pv.ViewID;
playerController player = PhotonView.Find(pv.ViewID).gameObject.transform.root.GetComponent<playerController>();
Debug.Log(player);
Debug.Log(ViewId);
//PhotonView.Find(pv.ViewID).gameObject.transform.root.GetComponent<playerController>().GiveKill();
}
}
I did it like this to test what was null
How does that tell you what's null?
I told you to separate the Find and GetComponent
Because it debugs it.
The debug.log tells me if its null or not right?
Well I dont really understand how i would do that
Does it debug?
yea
You don't know how to make variables, and you're doing multiplayer
Great
Well, because it debugs null and doesn't throw, I would assume the GetComponent is null
foreach (PhotonView pv in PhotonNetwork.PhotonViewCollection)
{
if (pv.OwnerActorNr == p_actor)
{
int ViewId = pv.ViewID;
playerController player = PhotonView.Find(pv.ViewID).gameObject.transform.root.GetComponent<playerController>();
player.GiveKill();
}
}
well is this what you mean by variables?
I told you to separate the Find and GetComponent
Although we now think the GetComponent returns null
Which means the root object has no playerController
well it does
Once you separate the Find and GetComponent, we will see the truth
foreach (PhotonView pv in PhotonNetwork.PhotonViewCollection)
{
if (pv.OwnerActorNr == p_actor)
{
int ViewId = pv.ViewID;
GameObject player = PhotonView.Find(ViewId).gameObject.transform.root.gameObject;
player.GetComponent<playerController>().GiveKill();
}
}
I did it like this and the error was on the last line which means that it doesnt have a playerController
But its impossible
Except this is what is happening, which means it is not impossible
well what should i do then
Evidently whatever object you end up on does not have this component
If that is news to you, you might want to change how you find the object in the first place
foreach (PhotonView pv in PhotonNetwork.PhotonViewCollection)
{
if (pv.OwnerActorNr == p_actor)
{
int ViewId = pv.ViewID;
GameObject player = PhotonView.Find(ViewId).gameObject.transform.root.gameObject;
player.GetComponent<playerController>();
}
}
I tested it to write it like this(without the method at the end of the last line) and I got no errors. Does that mean that the problem is on the method that i had on the line earlier?
No, the GetComponent is the issue
It returns null, just in this case, you're not using it
okay
I debugged the gameObject that i named "player" and it was 3 different gameobjects with the same viewId. I though every photonView had different ids but apparantly not. And i think that the getComponent returns null because it tried getComponent on the other "players" that didnt have that script on it. @olive vessel
well i got it working by doing this.
foreach (PhotonView pv in PhotonNetwork.PhotonViewCollection)
{
if (pv.OwnerActorNr == p_actor)
{
int ViewId = pv.ViewID;
GameObject player = PhotonView.Find(ViewId).gameObject.transform.root.gameObject;
if(player.layer == 7 || player.layer == 8)
player.GetComponent<playerController>().GiveKill();
}
Hey
i have a small problem with Photon
trying to work on it for 3 hours
anyone can help?
Players sync is rly laggy
i have Photon Transform View Classic
on my Player
u tried to invoke a methode RPC not on a Network Object
they have to be inst throw PhotonNetwork
Anyone know why this is happening?
[PunRPC]
public IEnumerator ChangePosition()
{
CharacterController controller = view.gameObject.GetComponent<CharacterController>();
for (float i = 0f; i <= 0.5f; i += Time.deltaTime)
{
controller.Move(new Vector3(x, i <= .2f ? 1 : -1, z) * Time.deltaTime * 100);
yield return null;
}
}
this function makes the correct movements but then snaps back into place once finished, it doesn't happen when I use 1's for some reason, x and z is the Camera.main.transform.forward.x/z
Are you spawning cameras for each player character regardless of whether they are local or remote?
Preferably yea, at least active
how can i make the IEnumerator and/or the startcoroutine line of code not be apart of the pun rpc cuz i dont want to hitmarker to be set active for everyone. i just want it to be setactive for you after u hit a target
how do I fix it then?
Anyone tried "Photon Quantum" for their networking? How good is the deterministic physics/gameplay? They advertise zero lag, is it really zero lag?
I'm making a simple app for use by just a few friends to track character info for their board game. I'm looking at Dropbox's HTTP SDK as a free solution for uploading/downloading a little bit of JSON, so character info is consistent between app users. It seems like it'll work, but before I dive in, has anyone tried using Dropbox HTTP with Unity? Or have another approach for free lightweight JSON storage and retrieval? Thank you in advance for your thoughts.
NVM, just remembered that Unity Remote Config was a thing. lol
Hello. What do you think about Firebase. is it good for indie multiplayer games? Or is photon better, or gamesparrks? thanks
fire base is a database, its not comparable to photon at all
hi guys, im following the direction for projs ive read in this channel from you guys.. but im getting this error... with this code..
ClientRpc RpcOnSpellStart called on un-spawned object: Spell_FireBall(Clone)
https://pasteio.com/xh4a89kt4j75 wondering if anyone can provide some direction, thank you!
using System.Collections; using System.Collections.Generic; using UnityEngine; using Mirror; public class Spell_FireBall : SpellBehaviour { public int damage; public float speed; public float du ...
Ive seen Firebase multiplayer game video on YT thats why I asked here. What about gamesparks?
game sparks is a game backend, again its not comparable to something like photon which provides the actual netcode
How can i refresh the Room List in Photon in real time
the problem Is: when i make a room and my second client Join and then i leave then he leaves. the room desapear for him but for me it is Still appearing.
as u see
it doesnot get Updated
i use the OnRoomListUpdate but it is not Enough
is there anyway to make a refresh button?
Hello there, I am legends games currently creating a game called yarnball and i am having some problems with networking i am getting these errors and only the host can see two players i am using unity 2021.2.6 and photon pun
oh are you also having that problem
Hey, is there any way to send UnityWebRequest GET in OnApplicationPause event? It looks like my coroutine with request is not sended if pause = true. Probably because main thread is frozen while the game is suspended.
Is it okay to use FindObjectOfType in multiplayer?
I've heard that each player has their own scene but idk if it could still collide with others
in local multiplayer?
Yo wich networking solution would work cross-platform supports the game rooms with randomly generated code to join would work on steam and im not giga chad networking multiplayer mastermind like yall here so if there is something like this what im looking for please tell me how its called
there arent any full solutions built with match codes
you could use Photon
filter joined rooms by lobby property
Generally you have some sort of visualization of remote players in your scene, which generally conflicts with things like FindObjectOfType.
In local multiplayer you usually have multiple player characters in the same scene
I’m a little confused by what you mean, I did understand that there could be conflicts but I haven’t really understood why
thx
is it possible to request a value (int, string...) through an Rpc?
Question
how can i share a object and give all players permission to destroy like
example a box
everyplayer could hit it whithout anyone owing it
any soultion?
it is up to you to make the server answer that request with the value you desire. You will need at least 2 RPCs
How can an object be controlled by everyone in the room (photon networking)?
that is a contradiction
i mean like having an object which everyplayer could Destroy
icould deleat Photonview of it but then i will get the Remove-Connection error
and will not get updated
the server manages who is allowed to do what, so just allow all players to request destruction
and how can i do that?
with a RPC to the server RequestKill(objectId)
i will read about it
so if i understand it right
first PhotonNetwork.Instantiate the Object and killing it by the RPC?
i tried that but is it possible on the same code run?
so if i have an array,
and than a new player joins, i want to request that array and in the same code run continue to use that array. is it possible?
( the problem here is that the array doesn't finish updating when it gets to the next line of the code. )
you send a [ServerRpc] that tells the server to call a [ClientRpc] that - tells all clients to Destroy(ObjectId)
you can call an Rpc through an Rpc yes lol
not possible, all network requests are asynchronous by nature
Lol i have no idea, at first i thought this was stupid but after playing with it i realised it works really really well. Rpc's are great here :P
exacly, so how can i wait for it to update?
true
i thought about maybe using an event instead. that runs whenever that code runs but will it always run after?
many ways. maybe you'll need to read up on the basics of concurrent/parallel programming principles
there is no point in giving you some random way to do it... that will fall apart immediately if you don't understand it yourself.
generally you should not frequently transmit data of variable length in multiplayer netcode
i looked at the documention and there was no sign of a good workflow or a way to write networking correctly
i see
its best to only transmit information what has changed
the thing is, i have a problem that every time a new client joins the game, his camera overrides everyone else's camera (2 cameras in the scene now)
so i thought to disable the camera for all the other clients (using a client dictionary)
so your array would actually be better off if it was kept up to date automatically on all clients and the server that care about it... and you do that most easily with network variables
for some reason, only the host can access the client list
is that possible???
no idea if photon has net/sync variables
but in any case they are just an abstraction over some rpc-like messaging
you'll also have no choice but to really understand in detail what authoritative networking means for your code flow. There are many gotchas you probably can't see yet and it takes a while to get to a point where you know exactly how to setup a proper networked game.
you can simplify the whole networking problem by a lot if you make it non-authoritative.
but that naturally relegates it to private network use where you can trust all participants (trust doesn't only come into play regarding cheating and malicious intent... its also a matter of data integrity and resource availability)
im not using photon lol
replace photon with "your network library"
i followed the Netcode For GameObjects Documentation and there was nothing even starting to explain the workflow of working with multiplayer
where should i go learn
nevermind, i will just try to mark important network stuff on a list and follow it.
it seems like network variables are the way to sync it
i guess i can
ok call?
ok
i guess there isn't any easy way to learn that stuff besides what you get in the unity or mirror documentation. you need some theory and then study an example project, and try to build your own on the side...
for the multiplayer networking specific theory, you can refer to this: https://discordapp.com/channels/489222168727519232/885300730104250418/935183620061167636
use a hosted solution like GameLift, PlayFab or Google Game Servers. Pair it with a database that has atomic transactions like Firestore or Cloud Spanner (or just an SQL server) to store and query your codes.
Hi. I've never made multiplayer game yet. can u suggest which one is better Photon or MLAPI?
As I know MLAPI is free
or which one? thanks
Photon is also free
CCU is limited as I know
Mirror is also an option 😛
DarkRift Networking 2 exists too
but yeah i'd also like to know what is best, i have minor experiences with mirror though
Which library?
i mean we cannot pass a Whole Game Object throw RPC in Photon
we can only pass like variables
u k
I think you can pass a PhotonView if I remember correctly. But has been a while since I used PUN
nope
u cannot
we can pass the Id of it
^^
as an Int
we cannpt even pass scripts
And search for it on the other side yeah.
or lists
yea it took me 3 hours to understand that
u k that weird error
PHOTON.UNITY.GAMEOBJECT.PASS is not vaild
XD
does it accessing realtime github would make the process slower ?
other question would be
what is the oposite terms of matchmaking ?
like a random join to multiplayer room
like minecraft
just multiplayer ?
A random join would still be matchmaking. If you directly join to a server that you already know the IP of I don't think there's a specific term for that but "direct connect" or "connect by IP" would do.
nice thanks Luke
anyway can you help me for RPC with Photon tuto ?
means the simplest one
I'm not really familiar with Photon stuff and haven't used PUN in a while. I suggest asking on the Photon Discord.
thanks again Luke
😄 ofc
but isn't it old?
which is most beginner friendly?
and good choice for mobile games
This is probably the hardest option but gives the most customization options. Riptide https://github.com/tom-weiland/RiptideNetworking
Thank you ❤️ is it cheap?
Its free and open source
wow. thank you very much. Hope there will be tutorials on yt
He is currently working on a tutorial series for it, I will dm you the discord
not sure if this is the right channel but how could i add crossplay between a PC and VR
you should be able to pass a "gameObjectReference" (thats how you pass in netcode)
also you can try passing a pointer to that gameObject, and save that object in both Players
you can also try passing a networkObject instead
you mean local cross play or online cross play?
if you are using the oculus Sdk than I remember they had an explanation in the rift S Documentation but it is very old
Generally, if you dealt with online before you should try just creating a network game with the player prefab being also VR and also Pc, and than when running the player you can check if it is VR or pc.
or just check and spawn each Player type when you need it
Ok thank you
How does one code an ingame shop thats server authenticated. I dont want players hacking the currency or items that a purchase only
you just run all the logic on the server
server send to the player how much money they have and what the list of item is
the client can display them and show which one it has enough money to buy etc
When the client wants to buy something it sends a message to the server asking to buy this specific item
the server checks if there's enough money, if there is then they add the object to the inventory and substract the money
Hello, does someone knows solutions to build a game server with Node.js (libraries suggestions ?) that could allow two unity clients to communicate real time on a 2D platformer game style ?
Mirror or Photon
google NodeJS websocket for a serverside websocket library
then u can use anything client side that suports web sockets too
i believe MLAPI, Mirror and Photon all do? Someone correct me
I see, thank for the help !
Never touched MP myself, but after watching DilmerV's playlist on Netcode for GameObjects - he's done a great job at explaining key elements... Network Variables, ClientNetworkTransform, etc. https://www.youtube.com/playlist?list=PLQMQNmwN3FvyyeI1-bDcBPmZiSaDMbFTi
What option do you recommend for this (multiplayer)
Unity MLAPi, Photon, mirror?
Any of them is fine and gets the job done. None is perfect.
yes but what do you use then?
toss a coin if you can't decide
photon youtube tuts make it looks super easy, while Unity MLAPI tutorial in the unity docs isnt too bad either
photon docs... altho i didnt go thru them, make it look more complicated, way more complicated than the youtube tutorial
or to put it another way, if you are just asking what is best, you can toss a coin as you have stated no requirements that would make one option preferable over any other
um. team based game play
nothing about multiplayer is easy, if a video makes it look easy, its a lie
peer to peer
cant do that with any of them
well. if im not coding multiplayer from scratch, using libs for it does take away 90% of the difficulty
wait what? i thought photon was p2p
all (mature/usable) unity networking libraries have a client-server architecture
so the photon server is actually running on their end?
or is one of the clients made a server. I thought it would forward the IP of the host to the client to connect to. p2p. Host aka server. but i barely started looking into this less than an hour ago
photon bolt supports 2 player P2P.... but that is not really useful unless you want a 2-player game
Photon hosting the game server must cost Photon a lot of money. networking is expensive. i dont believe they would do that
oh boy. i dont think my free game would make enough in ads to cover that
are you making an MMO that requires a dedicated server?
no. im just exploring networking options now, and do a practice project with it for any game ideas in the future
you can just have one of the clients be the server and have all others connect to that one
this is exactly what i want. I was hoping photon would just make one of the clients the "host"/server, and connect the other players to the "host"/server
then all you need is for clients to know the ip of the server and you have no additional cost
correct.
photon wants you to use fusion, pun/bolt are legacy systems
if you go with photon, expect their solutions to be optimized towards their paid services
expect Netcode for GameObjects (ex MLAPI) is the official solution by unity and will integrate best with other engine featuers (eventually)
expect Mirror to be the goto-solution for projects that have little to no funding and rely on community support
as i said before, nothing about networking is fast or easy
I see. thanks for the info
it entirely depends on your understanding of the subject, the common pitfalls and knowledge of the libraries
I made a networked game in java last year. so i know it isnt easy but doable. Will have to learn the ins-and outs of the networking. That stuff didnt have a lobby, so I had to create that on my own, pretty much the hardest and most time consuming part. and making sure I removed players and their items from every room they were in, when they quit
photon tutorial on youtube makes it look like a piece of cake, however not everything is covered.
if you need your networking to only work in a private network where you can trust all clients (i.e. the data they send), you can make your networking client-authoritative / cooperative (vs. the default server-authoritative approach)
this would make the setup and development much simpler
good point. yes i dont want to charging me during development process
btw thanks @austere yacht ... to sum it up, im going to look at all 3 of them b4 i decide. good thing getting the idea for which one to pick shouldnt take more than a day or 2
you really can't go wrong with any of them if you have no super specific requirements
team based fps is going to be my standard
if it can do that, then all games are fine
I want p2p since i dont want to pay for costs. 2v2 should be good enough
p2p, well. host/client, one client gets dedicated as server
yes. so that isnt the thing i want
what i want is, one client to be designated as a server
you just want "no dedicated server"
and the other clients forwarded the ip of the server from lobby.
yes. "no dedicated server" thanks for the term
Hello.
People!
Do you have any 'Relational Database' tutorial suggestion for a university or learning management system?
I've used this one: https://www.pearson.com/us/higher-education/program/Elmasri-Fundamentals-of-Database-Systems-7th-Edition/PGM189052.html
Fundamentals of Database Systems, 7th Edition
Is this good? Is there real world examples?
real world examples are way too complicated for any book/tutorial to cover. This book gives you the fundamentals to be able to evaluate, judge and design solutions on your own
i.e. it teaches Fundamentals
thanks Anikki!
How many people usually design a big database project do you think?
our project is huge and I do not want to take all the burden on my shoulders. It is a huge responsibility. Am I right?
at least 2-3 dtabase engineer is important I think! What do you think?
it is impossible to answer that in general
so long as you do not plan to build a RDBMS from scratch it isn't that difficult a subject
if you only want to design a databse on top of an existing RDBMS, thats fairly easy
it gets more complicated only when your data is too big to be stored on one machine or if you need distributed copies of the DB
hmm. we are going to use Azure
it will be handled by Azure
we wont use SQL server as a server
first step would be finding a very good argument why you cant use Postgres
if you cant find one, use Postgres
because it is the best general purpose open source rdbms... its not perfect but if you dont have specific requirements it doesnt support its a safe option to pick
hmm. I'll take it into considiration than!
but the company is willing to use Microsoft's services.
you can run postgres on microsoft servers
hmm. I'll have a look now. thank you for the informatioın.
Thank you so much! this is awesome
For some reason, NetworkVariables return an error in the Visual studio editor but work just fine on the unity editor.
and for some reason, Netcode For GameObjects cannot detect any NetworkDictionaries.
anyone know why? i added all Using Netcode; and its children libraries.
^^ Same happens for int, long, char...
Hello i got a problem in mirror
i would like to unload scene for the host but without removing the level like in the AdditiveLevels example but i can't seem to replicate it. it does work for clients but for host the objects are still visible
how do i hide them? the same as the example. i reread it plenty of times
The issue is that i see the objects from the previous scene. this isn't getting called in the host but still works
{
yield return SceneManager.UnloadSceneAsync(sceneName);
yield return Resources.UnloadUnusedAssets();
}
when I try using this with strings, I get this Error in Unity and Visual Studio: The type 'string' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NetworkVariable<T>
Decleretion:
NetworkVariable<string> NickName = new NetworkVariable<string>();
i also tried this.
but i get this error for every other type.
In the playlist I shared with @bright mauve , check out video #2, at 15:45, DilmerV showed how to work with strings.. ultimately, involved creating a struct implementing INetworkSerializable, and inside encapsulated a FixedString32Bytes (which has options for 32,64,128,512,and 4096 lengths)
https://www.youtube.com/playlist?list=PLQMQNmwN3FvyyeI1-bDcBPmZiSaDMbFTi
@blissful bluff is such a legend
ok, thx
although i still highly doubt our problem is because of using the wrong type or writing it wrong.
for me at least, even after copying the exact code from that video i still get the error...
i think there is a problem with visual studio detecting this specific library.
haha, not me, but DilmerV... had no clue how MP worked, but at least now, have a better understanding of getting something working quickly
because if you check in unity, everything works as expected but in visual studio it shows a compilation error
ONly thing I can recommend, is making sure you're using editor he's using and making sure Package Manager has the packages required, installed..
im using visual studio 2017/2022 usualy which both run smooth. (they give the errors but open correctly)
when trying to open this script with visual studio 2019, it still works but shows up that it is missing access to many network related files:
I bet this could be related to my problem but i have no idea how to fix this
Netcode.Components is holding NetworkVariable so i guess i have no choice but to try and see why this breaks
im using 2021.1.7f and netcode 1.0.0-pre.4
I don't see any option of upgrading to 1.0.1
Enabled show dependencies, new screencap of package manager - my guess (re not seeing v1.0.1 in list is something changed between 2021.1, and 2021.2 . I'm using Rider, not VS so maybe something different there as well..
Sidenote, but it would, especially if we are talking mobile ads.
Is porting your singleplayer game into multiplayer like a really hard job? as they say
If I want to do basically... P2P Connection (IP based/Steam Friends etc.) That is basically couch co-op, where I don't care if there are hackers. Whats the best system to use for that? I was using Mirror at one point or another, but that was about a year ago, so I'm just curious if there are other solutions.
Thats sort of my thought process as well, but I figured I'd throw the question out there just to see if there was anything new and exciting.
Hey guys~
I've been searching a little bit about multiplayer in Unity and it seems we have two options, using Unet or Photon.
What are the pros and cons? Seems like Unity is always upgrading their systems and I'm wondering which way is better to go with.
thanks did indeed changed my perspective, and im in a positive mood about it
hey I have been doing the same. so Photon looks like it is easy to set up, and fast
the only downside is that it has a cap on how many players you can get b4 having to pay.
the other downside is that since the server isn't controlled by the game dev or unity, I wonder if this company will be around and supporting it in the future. if not, all my games would become unplayable --tho i highly doubt this
Thanks!
Totally, I also read somewhere that Photon does not support all platforms so that might be an issue as well.
Photon also seem a more reliable host though: https://forum.unity.com/threads/unet-vs-photon.340165/
I looked at Unity MLAPI. I did not like this one as much, I went thru the docs and tutorials on Unity, and it seems a bit long, and tiresome to set up. photon on the other hand looks like drag and drop, and done from what i was looking at. but maybe once a few video tutorials come out demonstrating it, i might reconsider it
Had the same experience, Photon does look way more easier to use, although I'm wondering whether it's will be worth it once the setup is done 🧐
well im going to learn Ai first b4 multiplayer. that may actually lead to more fun gameplay
See also: Mirror, Mirage and other network stacks. "UNet vs Photon" is like apples and oranges. Both achieve the same thing at the end of the day; one is paid if you outgrow free tier, one is by unity devs
The architecture is what matters. Either classic dedicated server environment or P2P-based host client environment
Also, don't always judge network stacks on "ease of use" - some network stacks might be sharp edged and prickly, but still be a very solid contender
How would i make a SetCustomProperties store an int that adds 1 everytime the SetCustomProperties is called.
Something like this:
player.SetCustomProperties("kills" number++)
But I could not get that working. Any ideas?
Hey people
My attribute in C# is
public byte IsActive { get; set; }```
but in sql server databae it is ' is_active'
so, I can not map them obviously.
is there any feature to use in this case to solve this issue?
I do not want to use that weird small cases in C#
Hey guys, I'm testing Unity's netcode.
I have a singleton PlayerProvider : NetworkBehaviour as a child of DontDestroyOnLoad.
After two NetworkManager.Singleton.Shutdown(); this PlayerProvider gets destroyed... Are NetworkObjects (even these not spawned by network) destroyed when network shuts down?
I'm having a problem trying to get Mirror to reach out to the network. I suspect that this is a firewall issue, but I don't know where else I could look in the player settings. I have tested that it works in the Editor (Using UWP platform), and have previous functional and working code with a different platform (Android/Win Exe). Only the UWP build app will not let me connect.
#💻┃unity-talk message
@barren onyx more information please. You say UWP, but for what? Xbox UWP? Windows Store UWP?
Window Store UWP.
What is your unity version and mirror version?
More specifically, Desktop family.
2019.4 LTS
Mirror should be up to date to 53.0.0 will check on this.
What transport, default, Ignorance or ….?
Telepathy? That’s deprecated/left in for legacy reasons. KCP is the latest default.
KCP is basically a implementation of a reliable UDP protocol
I already have some other application being released into production using Telepathy. Will using KCP break that protocol?
yup... I figured.
I know right 😅
I actually need TCP. I need to make sure the clients receive the package.
I also do use UDP for other things such as audio stream and video stream, but for most part it relies on using TCP connection.
However, how does this affects the way UWP doesn't let me connect through?
I don’t know but it sounds to me UWP is blocking your socket
That's what I thought....
Can you build the runtime as development mode and see if Mirror is emitting errors?
Otherwise, best to report it as a bug in the Mirror issue tracker, and then pop over to the Mirror discord
Funny, I've asked this in the mirror discord, got no response back yet.
Seems to me that this is now a Microsoft issue in regarding of UWP blocking certain ports/socket.
Since it works in the editor mode just fine.
Yeah, maybe you need to set something in a manifest
Kcp uses reliable udp?
KCP is a reliable UDP implementation
It’s a protocol on top of UDP that provides reliability amongst other things.
Never mind I missread something
@barren onyx it could also be telepathy at fault, not Mirror itself. I’ve used UWP, Mirror and Ignorance in the past
Without issue
Anyways my point is that you don't need tcp for reliability
I was building UWP for HoloLens, but for some reason it doesn't work on Desktop mode.
but this is two different project.
The thing is with TCP vs UDP is that fundamentally it’s different. One ensures packets are A B C D while the other is a scatter shot, send and forget by nature, so it might be A C D B or A B D C. That’s where the custom protocol on top of UDP comes in to emulate some of TCPs features
So both protocols will get packets to you, UDP doesn’t care if something got lost, it keeps trucking, while TCP will detect it and resend. Again, Reliable UDP implementation check for acknowledgment and resend if the missed a packet
TCP is just the tried and true method that people use because it works, but it’s not always the optimal solution
It falls down in some aspects
Yeah it depends on your usecase
A little trivia, Mirror was very TCP oriented in the early days until I made Ignorance (since the only other UDP transport at the time was Unity LLAPI) then recently in the last year or two/three/four the project lead switched to KCP. If you look through the git history you can see when KCP became the default one
reliability vs responses. Audio/video would be an great example of UDP. information regarding user and other stats requires TCP. You don't want to lose those valuable informations if your game depends on it.
Ehhh, debatable… but again depends on your usage case.
I won’t argue
After all, it’s your project, your networking implementation 🙂
Sadly UWP won't punch through the firewall. Need to do more research on why UWP is giving me a hard time...
Consider also: a relay solution
Mirror has one, by a developer that I’m friendly with
😇
hey i need help with a certain script i was working on while following a tutorial, what happened was that i had an error after following the steps up to now and i was wondering anybody knew how to help, also the pastebin for the code: https://pastebin.com/KtXvTWAL, also the tutorial i was following: https://www.youtube.com/watch?v=93SkbMpWCGo
Get your next game design project organized - Sign up to Milanote for free: https://milanote.com/blackthornprod0621
Udemy Multiplayer course: https://www.udemy.com/course/beginners-guide-to-multiplayer-game-development-in-unity/?couponCode=86D7C0073D7CD59B6C07
0:00 - Intro
0:3...
i have been at it trying to look for a solution and i was kinda running low on options since the unity forum page was not giving me answers
Kinda need to specify the error
oh sorry ye lemme grab that
Hey, so I am converting a class to a byte[], send it over the network and convert it back to the class on the other end via marshalling. I am now facing problems sending arrays. I tried following attributes for the array:
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
[MarshalAs(UnmanagedType.LPArray, SizeConst = 3)]
[MarshalAs(UnmanagedType.ByValArray)]
[MarshalAs(UnmanagedType.LPArray)]
ByValArray crashes the receiving end, LPArray gives following error: Structure field of type Int32[] can't be marshalled as LPArray
Code references for the marshalling functions and my full class im sending:
[NetworkPacket, StructLayout(LayoutKind.Sequential)]
public partial class SamplePacketData : INetworkPacketData
{
public float Time;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string Name;
[MarshalAs(UnmanagedType.LPArray, SizeConst = 3)]
public int[] Test;
public string Testing;
}
// Marshalling
// TData = SamplePacketData
static byte[] StructToByteArray(TData obj)
{
int len = Marshal.SizeOf(typeof(TData));
byte[] arr = new byte[len];
IntPtr ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr(obj, ptr, true);
Marshal.Copy(ptr, arr, 0, len);
Marshal.FreeHGlobal(ptr);
return arr;
}
static void ByteArrayToStruct(byte[] buffer, ref TData obj)
{
int len = Marshal.SizeOf(typeof(TData));
IntPtr i = Marshal.AllocHGlobal(len);
Marshal.Copy(buffer, 0, i, len);
obj = (TData)Marshal.PtrToStructure(i, typeof(TData));
Marshal.FreeHGlobal(i);
}
sorry for the wall of text 😄
oop
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'PhotonNetwork' does not exist in the current context Assembly-CSharp C:\Users\jonah\game\Assets\connecttoserver.cs 16 Active
this is the one i think is probably important for the script to actually work
But lines 7 and 11 don't have errors?
Do you have Photon Pun installed?
yes
its in my assets i installed it i imported it i put in the apple id i did everything the tutorial told me to do
Maybe try restarting VS and Unity
ye ok ill try it
brb
i restarted you unity but when the project was oppening it told me i should resolve the errors from last time,there used to be 43 but now there are 5, which is better but i still not to resolve
should i send you the errors twc
welsh cow?
actually nvm i got it
hey so ive got this error but i don't quite know what it means and i just need help dumning it down so i can understand it:
Assets\scripts\connecttoserver.cs(13,26): error CS0115: 'connecttoserver.OnConnectedToMaster()': no suitable method found to override
[8:40 PM]
[8:40 PM]
Assets\scripts\connecttoserver.cs(18,26): error CS0115: 'connecttoserver.OnJoinedLobby()': no suitable method found to override
yo anybody online
i just really need help
just like anybody?
I seem to be making a tiny bit of progress, as in the RPC is actually doing stuff across the network. The DealCards at the bottom is supposed to find players in the scene hierarchy and pinpoint who they are. Each player is meant to deal cards for themselves, but when a non-master client deals the cards, they go to the master client.
To experiment, I changed RpcTarget to Others and now the master client's unable to deal cards whereas everyone else deals cards to the master.
Looking at this again, this might be a matter of line order.
Same problem
I found an alternative where instead only the master client can deal cards and does so for both players.
how do i set up a relay server using mirror networking?
i'm gonna bang my head on the desk.
Now it "acts" like it's working but the cards in question are completely different on each end
I'll just make a thread so I don't spam the chat
Trying to deal cards with Photon
How can one make efficient serialization with monobehaviours?
All my serialization techniques have been passing around bytestream and pushing bytes into it
I was iterating gameobject by gameobject
How do I make it so that if anyone presses one button, they all connect to one big server?
who is they?
The people pressing the button
the same way you connect to any server?
have you looked at the doc?
or asked on their discord?
yeah im asking
what did you find in the doc?
Where is the doc?
have you searched for it?
There are some good Photon PUN tutorials online
Learn how to make a multiplayer game with Unity in only 7 minutes!
Make sure to subscribe and turn on the notifications so you get notified when we release a new tutorial or video!
-~--~--~--~
Please watch: "Please Teach Me Kung Fu "
https://www.youtube.com/watch?v=gXjsfkS_xWQ
-~---~-
hot
Where would expect to find the doc?
Probably the photon website
You are correct 😄
I feel like making a bot that detects question where the person hasn't made any effort before asking lol
God the old in-Editor Asset Store
It doesn't seem like you have the skills required to write software for a large server yet
what do you mean by large?
Like just a single server for all players
Idk bro xD, I thought multiplayer would be ish easier but like I can keep trying to learn idc
multiplayer is hard
do you have any singleplayer experience?
a fair bit
2 months
pick one ^^
gotta learn to walk before you learn to run
in any case your first multiplayer game shouldn't be a game where you try to put as many players as possible on one server
hm fine what do you recommend I do?

