#archived-networking

1 messages · Page 114 of 1

summer tapir
#

Yeah, thank you very much for the reply.

frozen sail
#

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;
    }
}
frozen sail
#

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 ?

topaz vault
#

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?

topaz vault
#

fixed it

#

had to reimport all

verbal lodge
acoustic lodge
#

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?

lofty sage
#

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?

somber drum
#

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.

lofty sage
#

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

gleaming finch
#

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

mighty snow
#

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?

acoustic lodge
#

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?

somber drum
warm pulsar
#

What is the best solution to networking right now. I'm a beginner and I see that Unity has released a new MLAPI:

  1. new MLAPI
  2. Photon
  3. Mirror
verbal lodge
#

For what use case? Photon also has a variety of different solutions (Fusion, Quantum, PUN etc)

warm pulsar
#

I want to make a third person arena like game

#

It will have swords, bows, arrows, queue system, loby system, party system

peak robin
#

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?

acoustic lodge
#

Why do i have tons of internal errors due to photon engine?

azure oriole
#

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.

median aspen
#

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?

shadow spoke
#

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

cobalt folio
#

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).

glass steeple
#

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?

glass steeple
#

actually now I'm considering hazel pepereally

mortal horizon
#

hazel has little to no documentation, mlapi or mirror for turn based would be a good fit, it really doesnt matter which

glass steeple
#

yeah

#

Now I'm trying to think if I want to just manage everything myself (hazel) or fight(learn) systems

mortal horizon
#

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

glass steeple
#

alright

#

sounds good

#

also quick question, any easy way to serialize/deserialize C# objects?

mortal horizon
#

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

shut yarrow
#

Avoid BitConverter if you're doing serialization for sending over the network. BitConverter is made for convenience but it does a lot of allocations

mortal horizon
#

yes personally i would use unsafe code and pointers to write directly to the buffer, was just suggesting something simple

gleaming finch
#

can anyone help me?

open path
#

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.

stiff ridge
stiff ridge
stiff ridge
gleaming finch
#

Ok thanks

#

^^

frosty crystal
#

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

acoustic lodge
#

as well as hinting the class description and stuff

weak plinth
#

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);
}

}

gleaming finch
#

Hello

#

I was wondering how to sync 1 gameObject across every player in photon

tired trail
#

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.

stiff ridge
#

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...

grave ice
#

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 🙂

glass steeple
#

ouhhh that's pretty cool

#

was looking into that stuff recently

#

What do you use for the networking? @grave ice

warm pulsar
#

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?

mortal horizon
mortal horizon
warm pulsar
#

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 🙂

mortal horizon
#

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

grave ice
#

But the physics engine and the rollback handler are network independent

glass steeple
grave ice
# glass steeple 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?

verbal lodge
grave ice
glass steeple
#

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

austere yacht
#

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.

glass steeple
austere yacht
#

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

glass steeple
#

Aightttt

#

Thx for your input

#

@austere yacht have you used it a bunch?

austere yacht
#

have done two projects with mlapi/netcode and three with mirror

glass steeple
#

Is netcode the same as mlapi?

austere yacht
#

quite

glass steeple
#

Oh

austere yacht
#

netcode is essentially mlapi with some minor improvements since the rename

#

netcode for gameobjects that is

glass steeple
#

Ok so netcode is the newest thing?

#

I thought mlapi was the new thing enough

celest halo
#

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

cinder sorrel
#

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

somber drum
#

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

somber drum
#

last I used pun was doing the read/write for AI positions

glass steeple
#

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

somber drum
#

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.

somber drum
glass steeple
glass steeple
somber drum
#

solid choice. 🙂

glass steeple
#

I keep switching back and forth lmao

#

the more I read the more I cry

#

I should just get started

somber drum
#

yeah you'll know which you like as you get your hands dirty.

#

mirror definitely has that community support that can't be compared.

glass steeple
#

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

austere yacht
cinder sorrel
slim merlin
#

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).

stark rover
#

Hello, any ideas why it shows warning? I'm using netcode with relay

#

Multiplayer is working fine btw

stiff ridge
bright mauve
#

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.

gleaming finch
#

I have used transform view but am not sure if it is only for position,scale,rotation or everything

bright mauve
#

potentially yes but I never used photon

gleaming finch
#

ok thanks for the help

#

😄

stiff ridge
# gleaming finch so if say I enable that object in one (players) scene view Every scene view will...

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.

gleaming finch
#

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

stiff ridge
#

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.

gleaming finch
#

Ok looking

stiff ridge
#

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.

gleaming finch
#

Ok thanks!

gleaming finch
#

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)

kind sundial
bright mauve
#

line 219

kind sundial
#

@bright mauve Did you add the NetworkObject component to the GameObject that you're running your script on?

bright mauve
#

thank you so so much!!!! really!

kind sundial
#

@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!

slim merlin
woven steppe
#

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 ?????🤔

glass steeple
#

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

austere yacht
#

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.

gleaming finch
#

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

bright mauve
#

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.

bright mauve
gleaming finch
#

No no no

#

Just a windows build with a hotspot

bright mauve
#

what do you mean a hotspot

#

you are connecting through your mobile phone?

bright mauve
#

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.

gleaming finch
gleaming finch
bright mauve
#

it also makes it binary

#

so I can send the objects and data through network

bright mauve
gleaming finch
#

Yep everywhere

shadow spoke
#

Just ask, someone may be around who knows Photon

meager crypt
#

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

bright mauve
mortal horizon
#

@bright mauve the netcode framework you're using

shadow spoke
#

Network framework, network stack, network library, same thing

bright mauve
#

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...

bright mauve
#

Or unet tranport for the protocol

mortal horizon
#

i think NGO dropped support for strings

#

someone else can chime in here

#

Or at least, in its current state, it doesnt support strings

bright mauve
#

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?

mortal horizon
#

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

bright mauve
#

Anyways, how should i send a string array through Rpc? @mortal horizon @shadow spoke

mortal horizon
#

I don't use NGO, you're better off joining the official discord for it and asking

shadow spoke
#

Being unable to send strings is a dumb move

shadow spoke
#

Idk, maybe cast to a char array and back

#

Can you send a char?

bright mauve
bright mauve
shadow spoke
#

Or maybe just go to byte array

mortal horizon
bright mauve
#

They also said i could use a fixedstring but its very inefficient

bright mauve
bright mauve
shadow spoke
#

Uhh

bright mauve
#

A byte array would maybe save a string but not an array string

shadow spoke
#

Oh right

bright mauve
#

Because I CAN send a normal string. Just not an array one

#

For some reason

#

An int array can be serialized if that helps

mortal horizon
#

perhaps there is a better way to serialize what youre trying to send?

bright mauve
#

A list of player names

shadow spoke
#

List<string> ?

bright mauve
#

From the server to all clients through clientRpc

#

Sorry, i meant an array of strings, that contains all player names

#

A string[] names;

shadow spoke
#

List

#

That’ll work

#

And you can use a for loop to print the names out

bright mauve
#

Move all names to list, send the list, move the names back to a new array?

shadow spoke
#

Just use the list for play names and change your code to do that?

#

Otherwise you introduce garbage collection and potential frame hiccup

bright mauve
#

Maybe i should just use dictionaries if already rewriting data structures

#

They are binary already and very easy to work with

shadow spoke
#

Then do that

#

🙂

bright mauve
#

Yea

#

Thank you so much! @shadow spoke

shadow spoke
#

You’re welcome

bright mauve
#

@mortal horizon also thank youUnityChanwow

shadow spoke
#

Although I find it really stupid you can’t send a string[]

#

That’s like… why the fuck would you not want that

bright mauve
#

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

mortal horizon
#

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)

crude juniper
#

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);
        }```
mortal horizon
glass steeple
#

Make sure you use if/elses to map characters to numbers

shrewd fulcrum
#

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.

shrewd fulcrum
wet compass
#

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?

shut yarrow
#

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

wet compass
#

with Netcode for gameobjects

shut yarrow
#

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

wet compass
#

soudns good thanks

cinder sorrel
#

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

winter cobalt
#

guys where do i go to learn about the pricing of a multiplayer game's server rentals

austere yacht
# winter cobalt guys where do i go to learn about the pricing of a multiplayer game's server ren...

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/

true hearth
#

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

austere yacht
#

in any case, a lobby is just some rules applied to players on a server. Same as any other gameplay rules you'd implement.

true hearth
austere yacht
# true hearth I watched the video is exactly like i have made in the project, but i want it wi...

sounds like what you want is a relay https://docs-multiplayer.unity3d.com/docs/relay/relay

true hearth
#

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

austere yacht
#

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

wet compass
#

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

mint gate
#

Hey guys wanted to ask does Unity MLAPI have p2p

#

if not, are there any other p2p networking solutions for unity

humble socket
#

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...

verbal lodge
verbal lodge
#

No it doesn't support a direct p2p model. There's always a host client which acts as the server.

austere yacht
true hearth
woven steppe
#

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

shut yarrow
#

It's the same as any other networking except you connect to a local IP

wind hinge
#

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?

crude juniper
#

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

molten dragon
#

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

split sonnet
#

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 ??

wintry lily
#

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

green dust
#

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?

split sonnet
green dust
#

I am testing locally on my pc

split sonnet
green dust
#

no but I am guessing its the same

split sonnet
#

It's connected to my device local ip address

green dust
#

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

edgy grove
#

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

split sonnet
weak plinth
#

Does anyone have recommendations for a good dedicated server host for mirror

rare finch
#

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.

dry iron
#

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 ?

weak plinth
#

is photon pun 2 deprecated, and should i switch to fusion?

round perch
#

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 ?

glass rain
#

hello, i would like to know is fishnet better than the other? and is it harder?

edgy grove
#

Is there a difference between CCU and current logged users ? Just to know

patent fog
#

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)

edgy grove
patent fog
#

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

edgy grove
edgy grove
patent fog
#

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

edgy grove
# patent fog Using which network solution ? One from Photon engine ? I assume that would be p...

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

patent fog
#

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.

edgy grove
#

That's a pretty good idea, do you others potential multiplayer solutions I didn't though about ?

wind hinge
#

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?

round perch
#

is someone is good with Photon pun ?

glass steeple
#

don't ask to ask, just ask!

round perch
#

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 ?

rare finch
#

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?

rare finch
#

Anyone got any clue?

weak plinth
#

what is the best Multiplayer host for FREE? i have tried Photon my players LAGS like idk

wide girder
wide girder
#

Networking framework.

orchid sierra
#

A framework

weak plinth
#

then how do i make a multiplayer game i am new

orchid sierra
orchid sierra
wide girder
#

I'd agree with that. Should learn unity basics first and release a single player game or two.

weak plinth
wide girder
#

But if you're desperate, there are plenty of tutorials online.

weak plinth
#

yea but idk what is good or bad or Free

orchid sierra
wide girder
orchid sierra
weak plinth
orchid sierra
# weak plinth is it good?

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.

weak plinth
#

MLAPI

olive vessel
#

It's called Netcode For GameObjects now

#

MLAPI is the old name for it

weak plinth
orchid sierra
weak plinth
olive vessel
#

That's why we research...

#

You will learn what to look for

#

Multiplayer is not a walk in the park

weak plinth
weak plinth
olive vessel
#

That's a figure of speech, multiplayer isn't easy

wide girder
#

It means that you have to sit at home if you want multiplayer.

tawdry crag
#

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?

olive vessel
#

Yes I keep getting that warning too actually

weak plinth
olive vessel
sullen basalt
#

hey i need help trying to make my game multiplayer but im not exactly sure where to start or what to do

weak plinth
olive vessel
#

You say that like 5 hours is a lot of work, I've deleted more

wide girder
olive vessel
#

You call yourself a newbie, who can't even Google shit. Yet you want to make a multiplayer game

#

See the problem?

weak plinth
#

yea me dumb dumb

olive vessel
#

Right then, don't even consider multiplayer yet

weak plinth
#

but i want to play with friends

olive vessel
#

You're in luck, there's thousands of games online you can play with friends

tawdry crag
# sullen basalt hey i need help trying to make my game multiplayer but im not exactly sure where...

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...
▶ Play video
#

I would recommend starting by watching this

olive vessel
#

Tbh I am of the belief that you should have at least one, fully finished singleplayer game before you try anything like this

weak plinth
weak plinth
tawdry crag
olive vessel
wide girder
olive vessel
#

You see the problem here is one a lot of people suffer with, it's called scope

wide girder
weak plinth
#

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.

cunning stone
#

Okay, new question:
does Netcode for GameObjects support room instancing in any capacity?
e.g instancing a private room on a single server instance

weak plinth
#

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

teal obsidian
#

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.

weak plinth
#

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

weak plinth
#

So if data gets delayed then it’ll be delayed for the others

#

yeah that makes sense

#

thanks

stiff ridge
# weak plinth So I'm having a really peculiar problem with Photon. I'm setting things up so th...

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

weak plinth
#

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.

austere yacht
tidal frost
#

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
wind hinge
#

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.

stiff ridge
#

That depends on the networking solution you use. There are plenty.

sly patrol
#

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?

weak plinth
#

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

austere yacht
sly patrol
# austere yacht 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.

weak plinth
weak plinth
#

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!

weak plinth
#

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?

shadow spoke
#

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.

weak plinth
#

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?

weak plinth
#

if(PhotonNetwork.CurrentRoom.PlayerCount == 1)
{player = 1;}

delicate forge
#

Anyone know which network asset for multiplayer (mmorpg) are recommended for production 3d game

median folio
#

hey guys does networkList work rn?

#

if it does I need some help with it cause my client cant read the values

delicate forge
mortal horizon
steep quartz
#

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.

frosty crystal
#

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.

austere yacht
frosty crystal
#

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

austere yacht
frosty crystal
#

thanks

weak plinth
left jungle
#

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)
storm canyon
left jungle
storm canyon
#

so they come from the package? and not your own variables?

left jungle
#

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

grave ice
#

anyone here an expert on rollback / lockstep deterministic networking?

#

I'm looking for a short (1-2 hours) paid consultation, DM me

shrewd fulcrum
#

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)?

wind hinge
#

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.

olive vessel
#

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

wind hinge
olive vessel
#

Ok so if find returns null, you then try and do null.gameObject.transform...

#

See how that just doesn't work?

wind hinge
#

Oh yeah

wind hinge
olive vessel
#

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

wind hinge
olive vessel
#

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

wind hinge
#
 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

olive vessel
#

How does that tell you what's null?

#

I told you to separate the Find and GetComponent

wind hinge
wind hinge
olive vessel
#

Does it debug?

wind hinge
olive vessel
#

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

wind hinge
#
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?

olive vessel
#

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

wind hinge
olive vessel
#

Once you separate the Find and GetComponent, we will see the truth

wind hinge
#
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

olive vessel
#

Except this is what is happening, which means it is not impossible

wind hinge
olive vessel
#

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

wind hinge
# olive vessel If that is news to you, you might want to change how you find the object in the ...
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?

olive vessel
#

No, the GetComponent is the issue

#

It returns null, just in this case, you're not using it

wind hinge
#

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

wind hinge
# olive vessel It returns null, just in this case, you're not using it

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();


                    }
ebon sequoia
#

this look complex

#

anyway

#

i don't know what is c# and i can't download it

hasty fiber
#

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

sullen basalt
#

does anyone know what this error code means

hasty fiber
#

u tried to invoke a methode RPC not on a Network Object

#

they have to be inst throw PhotonNetwork

digital pecan
#

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

spring crane
#

Are you spawning cameras for each player character regardless of whether they are local or remote?

#

Preferably yea, at least active

candid dagger
#

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

sullen basalt
thin jackal
#

Anyone tried "Photon Quantum" for their networking? How good is the deterministic physics/gameplay? They advertise zero lag, is it really zero lag?

finite tide
#

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

solemn haven
#

Hello. What do you think about Firebase. is it good for indie multiplayer games? Or is photon better, or gamesparrks? thanks

mortal horizon
#

fire base is a database, its not comparable to photon at all

crude juniper
#

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!

solemn haven
mortal horizon
#

game sparks is a game backend, again its not comparable to something like photon which provides the actual netcode

hasty fiber
#

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?

tidal frost
#

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

tidal frost
hasty fiber
#

i got a soultion

#

^^

peak trout
#

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.

mint musk
#

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

glass steeple
#

in local multiplayer?

mint musk
#

or/and online

#

if there are differences

warm pulsar
#

Hi there, why is isServer always false here

quartz plinth
#

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

grave ice
#

you could use Photon

#

filter joined rooms by lobby property

spring crane
#

In local multiplayer you usually have multiple player characters in the same scene

mint musk
bright mauve
#

is it possible to request a value (int, string...) through an Rpc?

hasty fiber
#

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?

austere yacht
hasty fiber
#

How can an object be controlled by everyone in the room (photon networking)?

austere yacht
hasty fiber
#

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

austere yacht
#

the server manages who is allowed to do what, so just allow all players to request destruction

hasty fiber
#

and how can i do that?

austere yacht
#

with a RPC to the server RequestKill(objectId)

hasty fiber
#

i will read about it

#

so if i understand it right

#

first PhotonNetwork.Instantiate the Object and killing it by the RPC?

bright mauve
bright mauve
#

you can call an Rpc through an Rpc yes lol

hasty fiber
#

lol XD

#

why is it so COMPLECTED XD

austere yacht
bright mauve
bright mauve
hasty fiber
#

true

bright mauve
#

i thought about maybe using an event instead. that runs whenever that code runs but will it always run after?

austere yacht
#

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.

bright mauve
#

mhm, i agree.

#

is there a good place to learn unity networking in the right order?

austere yacht
#

generally you should not frequently transmit data of variable length in multiplayer netcode

bright mauve
#

i looked at the documention and there was no sign of a good workflow or a way to write networking correctly

austere yacht
#

its best to only transmit information what has changed

bright mauve
#

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)

austere yacht
#

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

bright mauve
#

for some reason, only the host can access the client list

austere yacht
#

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)

bright mauve
#

im not using photon lol

austere yacht
#

replace photon with "your network library"

bright mauve
#

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

hasty fiber
#

guys i dont get it

#

anyone wanna call 2 min

bright mauve
#

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

hasty fiber
#

?

#

small help

bright mauve
#

i guess i can

hasty fiber
#

ok call?

bright mauve
#

but i'm not using photon so it will be a bit difficult

#

sure

hasty fiber
#

ok

austere yacht
grave ice
# quartz plinth thx

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.

solemn haven
#

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

quartz plinth
#

Photon is also free

solemn haven
#

CCU is limited as I know

mint musk
#

DarkRift Networking 2 exists too

#

but yeah i'd also like to know what is best, i have minor experiences with mirror though

hasty fiber
#

i learned something new XD

#

we cannot Pass Gameobjects throw RPC

verbal lodge
hasty fiber
#

i mean we cannot pass a Whole Game Object throw RPC in Photon

#

we can only pass like variables

#

u k

verbal lodge
#

I think you can pass a PhotonView if I remember correctly. But has been a while since I used PUN

hasty fiber
#

nope

#

u cannot

#

we can pass the Id of it

#

^^

#

as an Int

#

we cannpt even pass scripts

verbal lodge
#

And search for it on the other side yeah.

hasty fiber
#

or lists

#

yea it took me 3 hours to understand that

#

u k that weird error

#

PHOTON.UNITY.GAMEOBJECT.PASS is not vaild

#

XD

rose tulip
#

does it accessing realtime github would make the process slower ?

rose tulip
#

other question would be

#

what is the oposite terms of matchmaking ?

#

like a random join to multiplayer room

#

like minecraft

rose tulip
#

just multiplayer ?

verbal lodge
rose tulip
#

anyway can you help me for RPC with Photon tuto ?
means the simplest one

verbal lodge
#

I'm not really familiar with Photon stuff and haven't used PUN in a while. I suggest asking on the Photon Discord.

solemn haven
#

but isn't it old?

#

which is most beginner friendly?

#

and good choice for mobile games

cold mist
solemn haven
cold mist
solemn haven
#

wow. thank you very much. Hope there will be tutorials on yt

cold mist
tiny matrix
#

not sure if this is the right channel but how could i add crossplay between a PC and VR

bright mauve
# hasty fiber or lists

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

bright mauve
tiny matrix
#

Online

#

Similar to phasmophobia you could say

bright mauve
#

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

tiny matrix
#

Ok thank you

terse relic
#

How does one code an ingame shop thats server authenticated. I dont want players hacking the currency or items that a purchase only

glass steeple
#

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

boreal kiln
#

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 ?

spring crane
#

WebSocket and Socket.io are some likely relevant keywords

grave ice
grave ice
#

then u can use anything client side that suports web sockets too

#

i believe MLAPI, Mirror and Photon all do? Someone correct me

boreal kiln
#

I see, thank for the help !

blissful bluff
weak plinth
#

What option do you recommend for this (multiplayer)

weak plinth
#

Unity MLAPi, Photon, mirror?

austere yacht
weak plinth
austere yacht
weak plinth
#

photon docs... altho i didnt go thru them, make it look more complicated, way more complicated than the youtube tutorial

austere yacht
#

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

weak plinth
#

um. team based game play

austere yacht
#

nothing about multiplayer is easy, if a video makes it look easy, its a lie

weak plinth
#

peer to peer

austere yacht
weak plinth
#

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

austere yacht
#

all (mature/usable) unity networking libraries have a client-server architecture

weak plinth
#

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

austere yacht
#

photon bolt supports 2 player P2P.... but that is not really useful unless you want a 2-player game

weak plinth
#

Photon hosting the game server must cost Photon a lot of money. networking is expensive. i dont believe they would do that

austere yacht
weak plinth
#

oh boy. i dont think my free game would make enough in ads to cover that

austere yacht
#

are you making an MMO that requires a dedicated server?

weak plinth
austere yacht
#

you can just have one of the clients be the server and have all others connect to that one

weak plinth
austere yacht
#

then all you need is for clients to know the ip of the server and you have no additional cost

weak plinth
#

correct.

austere yacht
#

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)

weak plinth
#

do you whats the fastest, or easiest one of the 3?

#

fastest to set up

austere yacht
#

expect Mirror to be the goto-solution for projects that have little to no funding and rely on community support

austere yacht
weak plinth
#

I see. thanks for the info

austere yacht
#

it entirely depends on your understanding of the subject, the common pitfalls and knowledge of the libraries

weak plinth
#

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.

austere yacht
#

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

weak plinth
#

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

austere yacht
#

you really can't go wrong with any of them if you have no super specific requirements

weak plinth
#

team based fps is going to be my standard

#

if it can do that, then all games are fine

austere yacht
#

not really

#

FPS networking is completely different from MMO networking

weak plinth
#

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

austere yacht
#

btw. p2p is not the name of the thing you want

#

P2P means "no server"

weak plinth
#

yes. so that isnt the thing i want

#

what i want is, one client to be designated as a server

austere yacht
#

you just want "no dedicated server"

weak plinth
#

and the other clients forwarded the ip of the server from lobby.

#

yes. "no dedicated server" thanks for the term

frosty crystal
#

Hello.

#

People!

#

Do you have any 'Relational Database' tutorial suggestion for a university or learning management system?

frosty crystal
#

Is this good? Is there real world examples?

austere yacht
#

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

frosty crystal
#

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?

austere yacht
#

it is impossible to answer that in general

frosty crystal
#

yes, I know. just wanted to relieve my self I think

#

🙂 but it worked a bit

austere yacht
#

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

frosty crystal
#

No, its going to be from 0

#

we have nothing now.

austere yacht
#

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

frosty crystal
#

hmm. we are going to use Azure

#

it will be handled by Azure

#

we wont use SQL server as a server

austere yacht
#

first step would be finding a very good argument why you cant use Postgres

#

if you cant find one, use Postgres

frosty crystal
#

hmm.

#

why do you say so?

austere yacht
#

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

frosty crystal
#

hmm. I'll take it into considiration than!

#

but the company is willing to use Microsoft's services.

austere yacht
#

you can run postgres on microsoft servers

frosty crystal
#

hmm. I'll have a look now. thank you for the informatioın.

bright mauve
#

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...

topaz roost
#

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();
           }
fair creek
bright mauve
blissful bluff
bright mauve
bright mauve
#

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.

blissful bluff
bright mauve
#

because if you check in unity, everything works as expected but in visual studio it shows a compilation error

blissful bluff
bright mauve
#

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

blissful bluff
#

I'm using Unity 2021.2.8f1, package manager has versions:

bright mauve
#

im using 2021.1.7f and netcode 1.0.0-pre.4

#

I don't see any option of upgrading to 1.0.1

blissful bluff
spring crane
wild phoenix
#

Is porting your singleplayer game into multiplayer like a really hard job? as they say

sick plank
#

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.

glass steeple
#

I think I would still use Mirror

#

it's easy, mature and reliable

sick plank
#

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.

summer anchor
#

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.

weak plinth
weak plinth
#

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

summer anchor
#

Thanks!
Totally, I also read somewhere that Photon does not support all platforms so that might be an issue as well.

weak plinth
#

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

summer anchor
#

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 🧐

weak plinth
shadow spoke
#

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

wind hinge
#

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?

frosty crystal
#

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#

grizzled dome
#

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?

barren onyx
#

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

shadow spoke
#

@barren onyx more information please. You say UWP, but for what? Xbox UWP? Windows Store UWP?

barren onyx
#

Window Store UWP.

shadow spoke
#

What is your unity version and mirror version?

barren onyx
#

More specifically, Desktop family.

#

2019.4 LTS

#

Mirror should be up to date to 53.0.0 will check on this.

shadow spoke
#

What transport, default, Ignorance or ….?

barren onyx
#

default.

#

Telepathy Transport.

shadow spoke
#

Telepathy? That’s deprecated/left in for legacy reasons. KCP is the latest default.

#

KCP is basically a implementation of a reliable UDP protocol

barren onyx
#

I already have some other application being released into production using Telepathy. Will using KCP break that protocol?

shadow spoke
#

Ah shit

#

Yeah, it will

barren onyx
#

yup... I figured.

shadow spoke
#

Telepathy is TCP based, KCP is UDP

#

The joys of maintaining applications

barren onyx
#

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?

shadow spoke
#

I don’t know but it sounds to me UWP is blocking your socket

barren onyx
#

That's what I thought....

shadow spoke
#

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

barren onyx
#

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.

shadow spoke
#

Yeah, maybe you need to set something in a manifest

glass steeple
#

Kcp uses reliable udp?

shadow spoke
#

KCP is a reliable UDP implementation

#

It’s a protocol on top of UDP that provides reliability amongst other things.

glass steeple
#

Never mind I missread something

shadow spoke
#

@barren onyx it could also be telepathy at fault, not Mirror itself. I’ve used UWP, Mirror and Ignorance in the past

#

Without issue

barren onyx
#

Same...

#

Under different project.

glass steeple
barren onyx
#

I was building UWP for HoloLens, but for some reason it doesn't work on Desktop mode.

#

but this is two different project.

shadow spoke
#

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

glass steeple
#

Yeah it depends on your usecase

shadow spoke
#

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

barren onyx
#

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.

shadow spoke
#

Ehhh, debatable… but again depends on your usage case.

#

I won’t argue

#

After all, it’s your project, your networking implementation 🙂

barren onyx
#

Sadly UWP won't punch through the firewall. Need to do more research on why UWP is giving me a hard time...

shadow spoke
#

Consider also: a relay solution

#

Mirror has one, by a developer that I’m friendly with

mortal horizon
#

😇

fresh dome
#

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

#

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

olive vessel
#

Kinda need to specify the error

fresh dome
#

oh sorry ye lemme grab that

plucky bramble
#

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 😄

fresh dome
#

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

olive vessel
#

But lines 7 and 11 don't have errors?

fresh dome
#

oh no they do

#

they all do

#

there are like 5 of these error

#

s

#

no sctually 3

olive vessel
#

Do you have Photon Pun installed?

fresh dome
#

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

olive vessel
#

Maybe try restarting VS and Unity

fresh dome
#

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

fresh dome
#

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?

weak plinth
#

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

weak plinth
#

I found an alternative where instead only the master client can deal cards and does so for both players.

ionic leaf
#

how do i set up a relay server using mirror networking?

weak plinth
#

I'll just make a thread so I don't spam the chat

#

Trying to deal cards with Photon

high night
#

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

rotund badger
#

How do I make it so that if anyone presses one button, they all connect to one big server?

glass steeple
#

who is they?

rotund badger
#

The people pressing the button

glass steeple
#

sure

#

just connect them to the server when they press the button

rotund badger
#

But like how do I connect them to the server? XD

#

@glass steeple

glass steeple
#

the same way you connect to any server?

#

have you looked at the doc?

#

or asked on their discord?

rotund badger
#

yeah im asking

glass steeple
#

what did you find in the doc?

rotund badger
#

Where is the doc?

glass steeple
#

have you searched for it?

olive vessel
#

There are some good Photon PUN tutorials online

rotund badger
#

hot

orchid sierra
rotund badger
#

Probably the photon website

orchid sierra
#

You are correct 😄

glass steeple
#

I feel like making a bot that detects question where the person hasn't made any effort before asking lol

olive vessel
#

God the old in-Editor Asset Store

rotund badger
#

For one large server do you reccomend photon runtime

#

?

glass steeple
#

It doesn't seem like you have the skills required to write software for a large server yet

#

what do you mean by large?

rotund badger
#

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

glass steeple
#

multiplayer is hard

rotund badger
#

Ik multiplayer is the definition of hell in coding

#

But like idk

glass steeple
#

do you have any singleplayer experience?

rotund badger
#

yes

#

a fair bit

#

2 months about

glass steeple
#

a fair bit
2 months
pick one ^^

rotund badger
#

I want to make a mutliplayer game...

#

xD

glass steeple
#

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

rotund badger
#

hm fine what do you recommend I do?