#archived-networking

1 messages · Page 115 of 1

rotund badger
#

@glass steeple

glass steeple
#

a small game

#

simple

#

easy

#

as simple as you can really

austere yacht
#

pong

rotund badger
#

Im trying xD

#

To make mutliplayer super simple game

mortal horizon
#

multiplayer and super simple dont fit together lol

rotund badger
#

Does anyone here understand how to script with pun 2?

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OnClickFunction : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        PhotonNetwork.CreateRoom("SwordSlashersServer");
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void Clicked()
    {
        print("Clicked");
    }
}

#

How do I make a variable for photonNetwork?

#

@glass steeple I got help from the other server and set up some gui but I just want to make the server now. The issue is I have no idea how to access the variable PhotonNetwork. I just thought you might be of help cuz u seemed like somewhat of a pro xD

glass steeple
#

That's one of the first things they'll show you how to do...

rotund badger
#

Alr bet

#

Yeah I tried

#

But like none are specific to my stuff

#

Ima keep scanning docs

olive vessel
#

Yes because tutorials are made to be more generic, otherwise you'd need millions of varied tutorials

#

You should learn from a tutorial, and apply knowledge back to your own problem

#

Now that code there should error and tell you that you need a namespace, as long as your IDE is configured ofc

rotund badger
#

Yes

#

@olive vessel Assets\OnClickFunction.cs(10,9): error CS0103: The name 'PhotonNetwork' does not exist in the current context

olive vessel
#

So your configured IDE should give you a hint as to what you need to do

#

Or are we still at the point of Schrödinger's IDE with you? Where you say it's configured and it ain't?

rotund badger
#

It is

#

But like how do I get photon network

#

thats all im asking lol

#

@olive vessel

#

Sorry

#

I forgot its late at night i shouldnt bing u

glass steeple
#

how did you configure it?

#

which steps did you follow?

rotund badger
#

I downloaded it with unity

#

Like the ide

#

im using vs code

#

Dude I've shown 100 people at least screenshots of it erroring my code

glass steeple
#

And they all decided that you put too little effort to make it worth it to help you lol

rotund badger
#

@glass steeple

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;

public class OnClickFunction : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        PhotonNetwork.CreateRoom("SwordSlashersServer");
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void Clicked()
    {
        print("Clicked");
    }
}

#

So now I have a error

#

In photon engine

#

And lapinozz no they were just making sure my lord

#

CreateRoom failed. Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
UnityEngine.Debug:LogError (object)
Photon.Pun.PhotonNetwork:CreateRoom (string,Photon.Realtime.RoomOptions,Photon.Realtime.TypedLobby,string[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1782)
OnClickFunction:Start () (at Assets/OnClickFunction.cs:12)

#

wth does that even mean xD

glass steeple
#

Follow a tutorial

rotund badger
#

Ok I keep looking

patent fog
#

You'll need more curiosity and hardwork to achieve a networked game. Getting stucked at "How do I make a variable for photonNetwork?" is a really bad omen. Don't want to be harsh 😉 just setting right expectations

runic rampart
#

I am using MLAPI - is it possible to send a reference to a scriptable object out of the box?

verbal lodge
#

No there's no built in support for that.

runic rampart
#

How come this isn't possible in a steamlined way? Coming from Unreal, you are able to easily send any asset reference over the network

verbal lodge
#

It's possible to do it. We just hadn't had the chance yet to implement it.

runic rampart
#

Can you describe to me how I would implement it? I was wanting to send some kind of unique identifier over the network which lets me easily look up the asset but I don't think this exists in Unity?

#

Look up the asset efficiently*

#

I'm wanting to avoid having to add all my scriptable objects to a list or some container and then look up the object in there.

austere yacht
# runic rampart Look up the asset efficiently*

register the objects in a list that the client and server share (at build time), deterministically generate ids for them and share those. have the sharing mechanism wrap the lookup and return the object instead of the id.

runic rampart
#

This needs to work in editor as well, is there an easy way to update this object every time a certain asset has been created/deleted?

austere yacht
#

that is up to you to implement

runic rampart
#

Sorry - I mean are there hooks for this in editor

verbal lodge
#

If you want something efficient and without having to add them to a list one workflow would be to:

  • Create a class wich derives from ScriptableObject e.g. NetworkScriptableObject
  • Add a private ulong field to it and make it a serialize field
  • In OnValidate assign the field the value of GlobalObjectId.GetGlobalObjectIdSlow(this)
  • In Awake of the NetworkScriptableObject register the instance to a static dictionary using it's id.
runic rampart
#

Also this seems less than ideal. I would have thought Unity itself under the hood uses some mechanism/ID system for looking up assets anyways

verbal lodge
runic rampart
#

I'll go with that approach, sounds better. Why can't Prefabs spawned over the network work in a similar way?

verbal lodge
#

Because the global object id stuff is editor only. You can't use it for runtime created objects.

runic rampart
#

Do you know why that's the case? Unique IDs for cooked assets sounds like an extremely useful engine feature nontheless

verbal lodge
#

Yeah but you are expecting the server and the client to assign the same Unique ID to two separately instantiated objects.

runic rampart
#

Assigning the IDs at build time would fix that

austere yacht
#

you can trivially implement that yourself, it is not something every object needs and should therefore not be a default part of every object

verbal lodge
#

Yeah doing that for every object would not be what most people want.

austere yacht
#

and a network object already has a unique identifier

runic rampart
#

Unless I'm simply lacking knowledge of Unity's hooks, I would have to implement it using inheritance or composition or something purposeful. This is not a valid workflow for designers in my opinion. They shouldn't need to be thinking about these things

verbal lodge
#

And there's an API for this actually but it will only work on actual assets

runic rampart
#

actual assets
Stuff in the Resources folder or in asset bundles?

austere yacht
#

unity is not as focused on a specific workflow and type of project as unreal is, you have to do some form of tooling yourself if you want to recreate a similarly designer centric experience as unreal provides

runic rampart
#

I guess I simple find the lack of APIs to do that frustrating. I can imagine no one has ever complained that you can address all assets in Unreal uniquely out of the box

#

But I digress

austere yacht
#

you can

#

there is the Adressables package

runic rampart
#

I have to set the asset as being addressable right? There's no overarching setting for it?

austere yacht
#

that even gives you extensive control over asset loading and memory

glass steeple
jagged violet
#

I've got this script which is instantiated for every player on server just after they are logged in

#

The problem is with this line ```csharp
taskTexts = GameObject.FindGameObjectWithTag("TaskText").GetComponentsInChildren<TextMeshProUGUI>();

because for server it finds an object with tag "TaskText" but client is getting null reference exception
#

I'm using this code to spawn my players

public class GameManager : NetworkBehaviour {
    [SerializeField] private GameObject playerPrefab;
    [SerializeField] private Transform spawnTransform;
    
    private List<PlayerSurvivor> playerSurvivors;
    private PlayerAttacker attacker;

    private void Start() {
        if(!IsServer) {
            return;
        }

        foreach(var client in NetworkManager.Singleton.ConnectedClientsList) {
            SpawnPlayerServerRpc(client.ClientId);
        }
    }
    
    [ServerRpc(RequireOwnership = false)]
    private void SpawnPlayerServerRpc(ulong clientId) {
        GameObject player = Instantiate(playerPrefab, spawnTransform.position, Quaternion.identity);
        NetworkObject playerNetwork = player.GetComponent<NetworkObject>();
        
        playerNetwork.SpawnAsPlayerObject(clientId);
    }
}```
glass steeple
#

that object exists on client?

jagged violet
#

You mean taskTexts which are null for client?

#

These are on Scene

#

I don't know why server can reference this object but client doesn't

#

this is player code

boreal scarab
#

Hey, I have a Hud element showing the playerhealth in multiplayer using mirror, but it just shows the HP of the last shot person, not my own, and i am unsure how to tell my Client that the Hud element should only display his local health https://pastebin.com/e1kXYuWb

runic rampart
#

Thanks

glass steeple
#

it only looks for gameobject prefabs in Ressources but it could work with scritpable objects too

rotund badger
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;

public class OnClickFunction : MonoBehaviourPunCallbacks
{
    public InputField playerName;
    public Button playButton;
    // Start is called before the first frame update
    void Start()
    {  
        playButton.interactable = false;
        PhotonNetwork.ConnectUsingSettings();
        PhotonNetwork.AutomaticallySyncScene = true;
    }

    public void Play()
    {
        string playerNameText = playerName.text;
        PhotonNetwork.JoinRandomRoom();
    }
    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        RoomOptions roomOps = new RoomOptions();
        roomOps.IsVisible = true;
        roomOps.IsOpen = true;
        PhotonNetwork.NickName = playerName.text;
        string roomName = "Room" + Random.Range(0, 1000);
        PhotonNetwork.CreateRoom(roomName, roomOps);
    }
    public override void OnJoinedRoom()
    {
        print("JoinedRoom");
    }
}
#

Why isn't this printing joined room when I click the button?

#

@glass steeple I actually have been watching tutorials and trying really hard xD

#

But eventually i'll get it maybe

#

Btw its not erroring

glass steeple
#

are you calling Play?

#

should probably check OnCreateRoomFailed as well

rotund badger
#

Yes alr

#

Im calling play

#

Alr

#

Ill put a lot of prints

#

then come back

#

hmm

#

Fixed it was a clicking issue, lemme input the code now brb

glass steeple
#

lol

rotund badger
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;

public class ClickFunctionTest : MonoBehaviour
{
    // Start is called before the first frame update
     public InputField playerName;
    public Button playButton;
    public void BeenClickedAye()
    {
        print("BeenClicked!");
        string playerNameText = playerName.text;
        PhotonNetwork.JoinRandomRoom();
    }
}

#

NullReferenceException: Object reference not set to an instance of an object
ClickFunctionTest.BeenClickedAye () (at Assets/ClickFunctionTest.cs:16)
UnityEngine.Events.InvokableCall.Invoke () (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:68)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:110)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:262)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)

#

Dude I don't know what to do can you just send me a tutorial that you know of or something cuz i've searched for hours

glass steeple
#

did you set playerName to anything?

rotund badger
#

I didn't even run the script yet

#

So how would I? I just saved

#

lemme check

glass steeple
#

how did you get errors without running it?

rotund badger
#

wait

#

It auto errors sometimes

#

way

#

Of fixed

#

u were right it was accidently already running

#

lol

#

mbmb

#

now when I click it though ```d
JoinRandomRoom failed. Client is on MasterServer (must be Master Server for matchmaking) but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
UnityEngine.Debug:LogError (object)
Photon.Pun.PhotonNetwork:JoinRandomRoom (ExitGames.Client.Photon.Hashtable,byte,Photon.Realtime.MatchmakingMode,Photon.Realtime.TypedLobby,string,string[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1663)
Photon.Pun.PhotonNetwork:JoinRandomRoom () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1597)
ClickFunctionTest:BeenClickedAye () (at Assets/ClickFunctionTest.cs:17)
UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)

#

Damn it.. so like the issue is I guess the client hasn't even joined?

#

but like.. even if i add a wait it doesnt fix

olive vessel
#

You need to wait for OnConnectedToMaster before you try to do anything like room joining

rotund badger
#

@olive vessel

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;

public class ClickFunctionTest : MonoBehaviour
{
    // Start is called before the first frame update
     public InputField playerName;
    public Button playButton;
    public bool HasConneted;
    void OnConnectedToMaster ()
    {
        HasConneted = true;
    }
    public void BeenClickedAye()
    {
        if (HasConneted == true)
        {
            print("BeenClicked!");
        string playerNameText = playerName.text;
        PhotonNetwork.JoinRandomRoom();
        }
    }
}

#

So I think that will work lemme test 😛

olive vessel
#

It won't

#

That's not a callback, it will never be called

rotund badger
#

No errors though o_o

#

Oh damn it

olive vessel
#

It won't error

rotund badger
#

What o I put then if its not a callback?

olive vessel
#

Wrong method signature, wrong parent class

#

You really need a basic tutorial for PUN

#

This is like minute 1 of PUN

rotund badger
#

;_;

#

WhereERe do i find this magical tutorial

#

i have searched for hours

#

and hours

#

probably 6 hours today

#

I followed them

#

but like they all have errors and when i ask for help they all say gO loOok FOra TutORail

#

So now I'm just trying on my own

olive vessel
#

I think you're way out of your depth

rotund badger
#

Possibly but I'll still keep pushing cuz thats how you learn...

#

Do you have anywhere that I can find good tutorials

olive vessel
#

Dapper Dino and First Gear Games both have PUN tutorials on YouTube#

#

Connecting to master is one of the first things you actually do in PUN

rotund badger
#

Ok

#

I'll study and then come back

#
#

This dude?

olive vessel
#

No, DapperDino

#

Close, but no cigar

rotund badger
#
#

XD

#

fair

#

First Gear Games looks good

rotund badger
olive vessel
#

He has done PUN videos, you need to find them

#

Most new ones are his own netcode solution FishNet, before that it's Mirror. But I have seen some PUN stuff

rotund badger
#

find them

#

ht

#

hot

#

@olive vessel How do I delete something using pun but with a time variable, because pun doesn't accept time variables. Like with pun you can't do Destroy (whatever, 5); only Destroy(whatever).

olive vessel
#

Coroutines?

rotund badger
#

Aright

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class TestConnect : MonoBehaviourPunCallbacks
{
    // Start is called before the first frame update
    private void Start()
    {   
        print("Connecting to server.");
        PhotonNetwork.GameVersion = "0.0.1";
        PhotonNetwork.ConnectUsingSettings();
    }
    public override void OnConnectedToMaster()
    {
        print("Connected to Server");
        
    }
    public override void OnDisconnected(DisconnectCause cause)
    {
        print("Disconnected from server for reason " + cause.ToString());
    }
    // Update is called once per frame
    void Update()
    {
        
    }
}

#

So now I'm making a connect to server function

#

But the issue is its erroring

#
Assets\TestConnect.cs(20,41): error CS0246: The type or namespace name 'DisconnectCause' could not be found (are you missing a using directive or an assembly reference?)


#

I though this would already of been defined with pun

#

So like in this video

#

They dont define it anywhere, but what else am I supposted to define it as?

#
public override void OnDisconnected(DisconnectCause cause)
``` Is my issue line
olive vessel
#

DisconnectCause is in the namespace Photon.Realtime

#

You can see him add it actually

#

Note: A configured IDE will tell you this

rotund badger
#

holy sh

#

it printed connect

#

LETS GOOO

rotund badger
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MainMenu : MonoBehaviour
{
    // Start is called before the first frame update
    [SerializeField] private TMP_InputField nameInputField = null;
    [SerializeField] private Button continueButton = null;
    
    private const string PlayerPrefsNameKey = "playerName";

    private void Start()
    {
        SetUpInputField();
    }
    private void SetUpInputField()
    {
        if (!playerName.HasKey(PlayerPrefsNameKey)) { return; }

        string defaultName = PlayerPrefs.GetString(PlayerPrefsNameKey);
        nameInputField.text = defaultName;
        SetPlayerName(defaultName);
    }
    private void SetPlayerName(string name)
    {
        continueButton.interactable = !string.IsNullOrEmpty(name);
    }
    public void SavePlayerName()
    {
        string PlayerName = nameInputField.text;
        PhotonNetwork.NickName = playerName;
        PlayerPrefs.SetString(PlayerPrefsNameKey, playerName);
    }
    // Update is called once per frame
    void Update()
    {
        
    }
}

#

First error: ```d
Assets\Scripts\MainMenu.cs(8,30): error CS0246: The type or namespace name 'TMP_InputField' could not be found (are you missing a using directive or an assembly reference?)

#

Second error: ```d
Assets\Scripts\MainMenu.cs(9,30): error CS0246: The type or namespace name 'Button' could not be found (are you missing a using directive or an assembly reference?)

#

What does it mean the type namespace? I'm making a new one...

#

This is the tutorial im following if anyone is wondering

mortal horizon
#

you need to import the references, like how you imported system.collections and unityengine

rotund badger
#

Ah

mortal horizon
#

sounds like your code editor isnt properly setup, it should be saying that in visual studio too

rotund badger
#

Yes I need help

#

I keep following all the steps

#

But like nothing

rotund badger
mortal horizon
#

using UnityEngine.UI;

#

etc

rotund badger
#

@mortal horizon Then what is a TMP_InputField's import?

#

cooper please help

olive vessel
#

You need to get that IDE sorted, it is beyond ridiculous

#

We've had this issue with you for at least a month now

glass steeple
#

I love this guy

#

Somehow has the courage to keep asking questions no matter what we say, still can't manage to read doc or do any of the things we suggest lol

rotund badger
#

Ok ima search for this "doc" you speak of

#

I have no clue were it is

#

And I Can't find it on the pun website, unless im looking in the wrong area

#

@glass steeple Could you send me link to doce?

olive vessel
#

Well for TMP issues, you should use their docs, they're not hard to Google

#

If you struggle to use the internet, you should find a class which teaches you how to use a search engine

rotund badger
#

What tmp issue

#

?

#

That I fixed I just took out the tmp lol

#

I didn't know what it even was used for

#

@olive vessel

#

But whats the docs everyone is talking about?

glass steeple
#

pun doc

#

I guess you are using PUN 2?

rotund badger
#

Yes

#

true

#

Where is the pun doc I've searched everywhere

#

I am going to have a heart attack

glass steeple
#

literally pun 2 doc in google

#

first result

olive vessel
#

So rather than find out how to use TMP, you’d rather just not use it

#

This is why you shouldn’t be making a multiplayer game

glass steeple
rotund badger
#

Ok

#

Ok ok

#

Ill research wth a tmp is (:

#

TextMeshPro

#

So I'd probably have to put Using UnityEngine.TextMeshPro

#

At the start

#

for the text mesh pro to work

olive vessel
#

Wrong, just research it

rotund badger
#

I am

#

Im tryin

#

Its not text mesh pro?

olive vessel
#

It is not UnityEngine.TextMeshPro

rotund badger
#

well its close to it maybe?

olive vessel
#

Not even close

#

It's the first fucking result on Google though

rotund badger
#

Yes see

#

It says text mesh pro

#

Wdym its the first fucking result? Wait u mad at me or at google?

olive vessel
#

Why would I be mad at Google? It had the answer I wanted exactly where I expected it

rotund badger
#

Then why u mad at me xD, I said text mesh pro

olive vessel
#

And that is still not the namespace you needed

#

The namespace you would put into the script to use Text Mesh Pro, is not Text Mesh Pro, it can't even have spaces

rotund badger
#

I'm looking

olive vessel
#

That's not even the right thing

glass steeple
#

@rotund badger honnestly tho, if you want to learn gamedev it's fine but you are certainly not ready for multiplayer

rotund badger
#

LETS GO I FIXED IT

#

😛

#

hell yeah

#

Where would you even find that link though

#

Like

olive vessel
#

It's called the internet

rotund badger
#

I searched, whatever, I mean I solved problem so thats pro i guess

#

😛

#

😛

#

XD ok i llstop

olive vessel
#

You mean I solved the problem

#

You are just here proving yourself to be lazy

rotund badger
#

Dude wdym lazy

#

I'm legit not... I've been grinding all day to get something done

#

Im 13 bro lol

#

Im trying my best

#

Ill keep trying as well

#

You can't get rid of me yet xD

orchid sierra
#

I feel like the docs are pretty easy to find. They are exactly where I expect them to be. Literally can be accessed from the main page

glass steeple
#

@rotund badger you have take a couple steps back and start from the beginning

#

learn the things and actually understand them before moving to the next thing

#

Find a basic unity introduction tutorial

#

play with the concepts it teaches

olive vessel
#

We've been through all this

glass steeple
#

actually try to understand

rotund badger
#

I know how to make a single player game...

#

I wont stop until I make a multiplayer game that I can play with the boys at school (:

rotund badger
#

Still grinding

#

Learning everything

rotund badger
#

Sleep is a reccomendation nerds

#

cant figure it out

#

just wasted 8 hours maybe

#

but whatever lol

#

ima sleep peace

glass steeple
#

Start small and simple

#

Go back to the beginning

plucky bramble
#

So I am thinking of a way to update positions on all other entities around one entity, question is what way would you prefer and why?

  • For each player, fetch all network entities around him and send him the positions in a list
  • For each network entity fetch the position (update) and send to all players around the network entity
glass steeple
#

What framework are you using?

#

Mirror has built in interest management

plucky bramble
#

A low level one, Lidgren3

#

Nothing that automatically syncs stuff 😄

glass steeple
#

I would keep a list on each players of what's near them

#

On the server

plucky bramble
#

And then send one packet to the player with the list anytime something updates?

glass steeple
#

Yeah

wispy bobcat
#

Hi so I am currently making my first multiplayer game, and I am currently working on the movement system, however Unity doesn't seem to pick up the rigidbody that my instantiated player has on the server side, I'm sending the player input to the server which needs to process it and send the new position back to the player but it can't find the player's rigidbody, it does have one in the inspector so I'm not sure what the problem could be. The test I did:

Debug.Log(rb.transform.position);

the error:

NullReferenceException: Object reference not set to an instance of an object
PlayerMovement.MyInput () (at Assets/PlayerMovement.cs:94)
PlayerMovement.MovePlayer (System.UInt16 PlayerInput, RiptideNetworking.Message playerInput) (at Assets/PlayerMovement.cs:79)
RiptideNetworking.Server.OnMessageReceived (System.Object s, RiptideNetworking.ServerMessageReceivedEventArgs e) (at <6fc295986c534e3fb691cbb0a3648ff3>:0)
RiptideNetworking.Transports.RudpTransport.RudpServer.OnMessageReceived (RiptideNetworking.ServerMessageReceivedEventArgs e) (at <6fc295986c534e3fb691cbb0a3648ff3>:0)
RiptideNetworking.Transports.RudpTransport.RudpServer+<>c__DisplayClass37_0.<Handle>b__0 () (at <6fc295986c534e3fb691cbb0a3648ff3>:0)
plucky bramble
#

@wispy bobcat can you show us the surrounding lines of code of PlayerMovement.cs:94?

wispy bobcat
#

Right, so here's that section:

public void MyInput()
    {
        x = Input.GetAxisRaw("Horizontal");
        y = Input.GetAxisRaw("Vertical");
        jumping = Inputs_[0];
        crouching = Inputs_[7];
        Debug.Log(rb.transform.position);
        //Crouching
        if (Inputs_[5])
            StartCrouch();
        if (Inputs_[6])
            StopCrouch();
    }

I'm rewriting my single player code so there's still a lot left from that - this function get's called every time the client sends it's inputs to the server which it does in an array, the rb comes from an instantiation which gets called when the player joins the server

Player player = Instantiate(GameLogic.Singleton.PlayerPrefab, new Vector3(0f, 1f, 0f), Quaternion.identity).GetComponent<Player>();

I can also show you the instantiated player in the editor if you want

#

it's not just that one line tho, it's everything that has the rigidbody in it

plucky bramble
#

What line is line 94?

wispy bobcat
#

Debug.Log(rb.transform.position);

plucky bramble
#

Ok, rb is a public member which you assign in the inspector?

wispy bobcat
#

The rb is a component on the player that gets instantiated

#

void Awake()
{
rb = GetComponent<Rigidbody>();
}

#

oh wait

#

maybe it's because it's on void awake and the player isn't there yet when the game launches?

boreal scarab
#

Can someone tell me or give me a hint why the Clients are moving faster than the host? ```cs
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");

    Vector3 movement = new Vector3(moveX, 0,moveZ);
    Vector3 curr_position = transform.position;
    Vector3 targetPosition = curr_position + movement * 5 * Time.deltaTime;
    Debug.Log(targetPosition.ToString());
    rb.MovePosition(targetPosition);
boreal scarab
wispy bobcat
#

ah I just changed it to

void CheckRb()
    {
        rb = GetComponent<Rigidbody>();
        Debug.Log(rb);
        
    }

and now it's saying:

NullReferenceException
UnityEngine.Component.GetComponent[T] () (at <028e4d71153d4ed5ac6bee0dfc08aa3b>:0)
#

though the rigidbody that im referring to is defo there because when I instantiate the new player and click on it the correct rigidbody is in the slot

weary creek
#

I am gettting this error when I try to call a PlayFab function on my server build. An unreal dev told me that there is a flag called Verify Peer that verifies all SSL connections. Is there an equivalent solution to unity?

weak plinth
#

i need help with google cloud. (im using mirror)

#

:(

mortal horizon
glass steeple
tepid mantle
#

Is there any recommended courses for .net networking in unity? Would it be better if I found something specific for .net and just try to implement it in unity? The general APIs for networking in unity haven't seemed ideal for what I'm looking for

austere yacht
runic rampart
tepid mantle
austere yacht
# tepid mantle I meant using .net sockets to create an online multiplayer game and send informa...

this is some theory on common multiplayer netcode problems and solutions #archived-code-advanced message
beyond that you're best off looking at examples and working implementations of netcode. Tutorials/courses cannot teach the complexities of actual, real world impelentations. Reading the source code of mirror and netcode for gameobjects is also a great way to start before writing your own. unless you are well versed in multiplayer networking i would not try to write a transport layer myself, there are excellent implementations out there already (enet, LiteNetLib, Lidgren, Ruffles, Telepathy, KCP...)

rotund badger
#

less goo i figured something out

#

only took me 5 hours

weak plinth
#

this is not working

mortal horizon
#

you have no return type

#

@weak plinth

weak plinth
#

because this works, but not for me?

mortal horizon
#

you need to specify the proper return type, which seems to be void in this case :)

weak plinth
#

OH

#

im so dumb

#

thank you

mortal horizon
#

np

boreal scarab
#

Can someone tell me or give me a hint why the Clients are moving faster than the host?
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");

    Vector3 movement = new Vector3(moveX, 0,moveZ);
    Vector3 curr_position = transform.position;
    Vector3 targetPosition = curr_position + movement * 5 * Time.deltaTime;
    Debug.Log(targetPosition.ToString());
    rb.MovePosition(targetPosition);
rugged obsidian
#

Hi guys how do i add online multiplayer to my game

sturdy granite
#

heelp, anybody with uMMO ?

#

does it local multiplayer are their default or we need to do a little adjustment ?

spring crane
spring crane
sturdy granite
#

the server address seems created yet

#

support think this is too basic, while the docs are unclear

spring crane
#

Still not sure what you are trying to do

sturdy granite
jagged violet
#

How client can get reference to a scene object in Start method?

#

I am trying to do this by using GameObject.Find() and I get NullReferenceException

light ginkgo
#

So, I'm using mirror and this function in my code is causing the error: 'Disconnecting connId=0 to prevent exploits from an Exception in MessageHandler: ArgumentNullException Value cannot be null. Parameter name: key', this function is causing it, but I have no idea why. (items is a SyncDictionary<Item, int>):

    public void CmdAddItemToItems(Item item, int amount)
    {
        if (items.ContainsKey(item))
        {
            items[item] += amount;
        } else
        {
            items.Add(item, amount);
        }
    }```
austere yacht
sacred spoke
#

I thought that PhotonNetwork.Destroy(viewID.gameobject) would destroy a gameobj for everybody, is this wrong ?

frosty crystal
#

Hey folk!

bright mauve
#

(NetCode For GameObjects) how can I get a new joining player's Player asset?
the network players id list is only saved on the host, is there a way to get the body of a player through their id? or get it the second they join?

boreal scarab
#

Can someone tell me or give me a hint why the Clients are moving faster than the host? The players are just cubes with rigidbodys attached, and they each have a Networktransform using Mirror

 float moveX = Input.GetAxis("Horizontal");
        float moveZ = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(moveX, 0,moveZ);
        Vector3 curr_position = transform.position;
        Vector3 targetPosition = curr_position + movement * 5 * Time.deltaTime;
        Debug.Log(targetPosition.ToString());
        rb.MovePosition(targetPosition);```
meager crypt
#

Anyone use Pun?

oak flower
meager crypt
#

Ah sorry

#

Im using pun and I Instantiate, and then parent the GameObject which works with with the client. However, when another player joins the instantiated object is in the wrong place. What could cause this?

stiff ridge
azure oracle
#

any good network solution for unity 2021+ except steam api? I wanna do like player-host and players-clients but also i want to do lobby list. In pun 2 server list is very easy, but i cant figure out how to make player host server, but not to use photon's servers.

boreal scarab
slow lichen
#

(Mirror)
Good afternoon. How does all this differentiation of realms work? For example, I create a method and give it the Command attribute. What now happens when I call it in the game code? Does it check where it is called from and if it is called from the client, does it send a request to the server? What is the general feature of this method, unlike others?

austere yacht
slow lichen
#

Okay. This is rpcs, right?

#

But my client have this method too. Why when I calling command method I executing this method on server?

#

Then when I calling method with Command attribute mirror checking who am I and doing something?

#

If client then gets connection and sends rpc

#

Or If I host then just calling this function

#

If you don't understand something from my words please tell me and I will start use translater👍

slow lichen
#

Okay. If I change something on server then I should sync this or It will sync automatically?

austere yacht
#

That’s basically what mirror is all about… sending high frequency data with low latency and enabling you to run methods on another computer over the network.

slow lichen
#

And what about Server/Client attributes. How to use it and for what I can use it?

slow lichen
#

How to understand server-only or client-only parts? Code anyway exists on all realms?

austere yacht
#

those can be used to make sure that method is only called on the server or client

slow lichen
#

Hm

#

For what this can be used?

austere yacht
austere yacht
slow lichen
#

What will happen if I just call ClientRpc from client

austere yacht
#

An exception

slow lichen
#

Okay. How I understand:
Server is just central point that can make some changes and sync this changes with client. But how this splitting?

#

Server know about all gameobjects in current scene, right?

austere yacht
slow lichen
#

Server know only about network objects?

austere yacht
#

Yes

#

Well and all of its own gameobjects naturally

slow lichen
#

Oh. Then server have his own c-side objects

austere yacht
#

If it is a host, yes

slow lichen
#

Host is pair client - server

#

Yes?

#

Oh okay. Thank you

#

And one thing..

#

If server know only about network objects then I can't just move piece of wall on client?

#

Only if wall is network object

#

Because wall is client side map

#

Just I think what server should know about loaded scene

austere yacht
#

The server knows about scenes and will assume they are identical with its own. But it can’t know for sure

#

If a client spawns any non network objects, the server will not automatically know about them

slow lichen
#

Okay. Thank you! You really helped me to understand how it works

jolly tree
#

Hello!

#

@charred dock So, what I need its basically having a console that do some math and sends the result back to Unity

#

like

#

Unity sends to the server:
ExampleArray[1,2,0,0]

#

the server takes this array and for example multiply those numbers

#

and give the results back to the Unity

#

2

#

in this case, the client/player will get the result

charred dock
#

So the best way I can think is to create an server build with the functions needed for the math problem and do an RPC with that array and have it return by doing an another callback to the client

jolly tree
#

uuuh

#

lemme search what is an RPC

charred dock
#

remote procedure call

jolly tree
#

hmmm

#

like, the thing its that what I think that I need its a console running and getting those inputs from the client

#

in this case, the console will be created like a room inside of the server

#

when a "battle" starts

glass steeple
#

@jolly tree what's your goal in doing this?

#

Why does it needs to be a console?

#

why couldn't the client do the operations?

charred dock
#

@glass steeple I was about to ask that, I am still confuse on what he is asking

jolly tree
#

Its because the game needs to be secure

glass steeple
#

ok sure

jolly tree
#

we gonna work with and stuffs like that

glass steeple
#

oh boi

#

Do you know what you are doing?

jolly tree
#

I'm not sure.

charred dock
#

So not really than huh

glass steeple
#

I feel like if you ask such basic questions you don't have the skills to get involved with blockchains lol

jolly tree
#

my task for this month its learn

#

basically learn

glass steeple
#

You'd need to be a least a little familiar with networking and stuff like REST API?

jolly tree
glass steeple
#

What kind of blockchain are we talking? Just communicating with some online service?

#

I don't think those problems are really related to Unity

jolly tree
#

damn I cant talk too much about this, but its basically saying to server "hey I want to do this" and the server verify if I can, and if I can, the server do this

#

will be like a mirror

glass steeple
#

yeah that's how game networking is usually done

#

The server has the authority

jolly tree
#

all math, processing and those kind of stuffs needs to be in server

jolly tree
#

so I cant use it

#

I'm start to think that I need to create it from scratch

#

and damn...

glass steeple
#

you could use Mirror

#

That's what I use and it works well

#

you have some code that runs on the server and some code that runs on the client

jolly tree
#

yeah but the problem is code running on the client-side

glass steeple
#

what's the problem with it?

jolly tree
#

Like, imagine if the client change the damage, for example

#

puts 1000 of damage

glass steeple
#

well how could they, that code should run on the server

jolly tree
#

yeah

#

what needs to happen its client request to cause damage

glass steeple
#

yes

#

lol

#

maybe read about game networking architecture

jolly tree
#

But I dont know what kind of technology use

glass steeple
jolly tree
#

?

#

what do you mean?

glass steeple
#

you could, like, google it?

jolly tree
#

This is what I'm doing right now

#

Coming here and asking its part of googling :b

jolly tree
#

btw, thanks for your time, now I have an abstraction of a north

glass steeple
#

basically you put all the code you need to be trusted on the server

#

on the client rather then saying "damage this player with 1000" you say, "run the attack command"

#

And the server checks if you can use that thing right now, then it does the damage etc and sends it to all clients

jolly tree
#

Yes

#

exactly what I want

#

but the first thing that I need to know its figure out how to do this in Photon

glass steeple
#

why do you want to use Photon?

jolly tree
#

I don't even clearly understand what Photon is

jolly tree
#

They said that they pretend to use Photon

#

do you know any other technology that could be more efficient?

#

and easier to learn

glass steeple
#

well I suggested Mirror

#

like, 4 times lol

jolly tree
#

Okay! I will read about this

#

but, you think that is sufficiently secure?

#

like... we gonna put hands on fire

glass steeple
#

depends on your implementation but I don't see why it wouldn't be

jolly tree
#

okeh

glass steeple
#

except with your 0 amount of experience I really wouldn't trust it

jolly tree
#

huaehauehaueh

#

thank you for your time, Lapinozz

#

I will start learning about this right now

glass steeple
#

good luck

teal obsidian
teal obsidian
#

what do you mean sure

glass steeple
#

Not very practical for dedicated server no?

teal obsidian
#

Why wouldn't it be?

#

It's one of the best solutions on the market

rugged obsidian
#

Hi how can I add local multiplayer to my game using Mirror and have a player count ?

#

BTW I am a VERY big beginner

frosty crystal
#

Hey folk!

#

I have a Web API project and want to make provisioning for different environments.

#

Do I have to build CI/CD pipeline with 3 branches in Git or is there another way?

stiff ridge
# glass steeple Not very practical for dedicated server no?

If the task is to make the server do some calculations (not move some objects in a Unity scene), then a Photon Server would likely be more efficient, really. You don't have to run Unity headless on your machines, if you don't need the engine.
It really depends on the requirements, which we don't know.
Actually, a secure web request can do what he was asking for, as long as it's not related to a scene.

slow lichen
#

Code in Command method should be runned on serverside?

glass steeple
#

Tbh I haven't looked that deep into photon, I don't like the pricing model

rich meteor
#

Man I wish there were more dedicated program server tutorials

#

And not dedicated "host it on this paid platform" server tutorials

spring crane
#

Which part are you having trouble with?

rich meteor
#

Unity's new multiplayer api

#

Not sure what you're supposed to use yet

#

And really hesitant to switch from legacy tbh

#

You can build a dedicated server, but from forum thread it's not a good idea

glass steeple
#

why it's not a good idea?

rich meteor
#

People report crashes, failed builds for no reason, weird bugs, platform specific issues

#

As recent as last week

#

It's apparently a super early version of dedicated build feature

glass steeple
#

with Netcode for Gameobject?

#

use Mirror then

rich meteor
#

I worked with mirror once and it wasn't bad tbh

glass steeple
#

I'm using it right now but I'm just sending NetworkMessage directly

rich meteor
#

Yeah don't wanna get into super high level stuff either

#

And LiteNetLib is just a udp library anyway

glass steeple
#

Mirror has already all the client/server/host logic so that's nice

#

and you can use multiple transport

#

So it's a bit nicer than using udp directly

rich meteor
#

Ideally I wanna set up a console server

#

Isn't mirror just headless?

glass steeple
#

what's the difference?

rich meteor
#

Bare minimum code and no assets?

glass steeple
#

ah

rich meteor
#

Like, correct me if I'm wrong but headless is just building a game and running it with no graphics

#

To act as a server

#

And dedicated is an app that just handles server things

glass steeple
#

ah yeah

#

I mean

#

you can do a Server build and it shouldn't include any visual stuff

#

and use #if UNITY_SERVER or something if you want to strip down on the code

rich meteor
#

Yeah Unity are trying to automate this but rn it seems like trash

glass steeple
#

really?

#

Seemed to work for me

rich meteor
#

Probably? From user reception

glass steeple
#

just ticking the box

rich meteor
#

Dedicated server build?

glass steeple
#

the "Server Build" in the build options

rich meteor
#

I don't think server build strips anything

glass steeple
#

which version of unity are you on?

rich meteor
#

2022.1.0b4

#

beta

#

trying new features

glass steeple
rich meteor
#

but I think dedicated servers work starting from any 2021

glass steeple
#

the Server Build option

rich meteor
#

Yeah but it doesn't strip code though

#

Just assets iirc

glass steeple
#

yeah

#

but you can use #if UNITY_SERVER if you really wanna strip code

rich meteor
#

Yeah and that new solution is supposed to just

#

Find network code and remove anything else?

#

I think

glass steeple
#

how does that work lol

rich meteor
#

no clue

glass steeple
rich meteor
#

bruh

#

misleading

#

I though it was something like removing unused code compiler optimizations

#

ok writing a server manually then screw this

glass steeple
#

outside of unity?

rich meteor
#

yeah

#

wish me luck

glass steeple
#

lol good luck

#

Wouldn't be very feasible for me as my game relies heavily on physics and stuf

rich meteor
#

if only physics was deterministic

#

😔

glass steeple
#

it kinda is

#

close enough

chrome thistle
#

which is the simplest way to make a post request from unity to server?

    public static async Task<string> Login()
    {
        const string url = HOST + "/auth/login";
        WWWForm form = new WWWForm();
        form.AddField("email", "email");
        form.AddField("password", "password");
        UnityWebRequest webRequest = UnityWebRequest.Post(url, form);
        await webRequest.SendWebRequest();
        Debug.Log(webRequest.error);
        string a = System.Text.Encoding.UTF8.GetString(webRequest.downloadHandler.data);
        string data = JsonUtility.FromJson<string>(a);
        return data;
    }

    private async void Start()
    {
        string a = await Login();
        print(a);
    }

the webrequest here return that the server cannot understand the request with status 400

#

maybe because I use WWForm, and the server is expecting a json_data

#
json_data = request.get_json(force=True)
#

the server is python flask

glass steeple
#

I think it would expect just raw json in the data

chrome thistle
#

yes, it does. but how to send that from unity?

#

I should write something like that?

IEnumerator PostRequest(string url, string json)
    {
        var uwr = new UnityWebRequest(url, "POST");
        byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(json);
        uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);
        uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
        uwr.SetRequestHeader("Content-Type", "application/json");

        //Send the request then wait here until it returns
        yield return uwr.SendWebRequest();

        if (uwr.isNetworkError)
        {
            Debug.Log("Error While Sending: " + uwr.error);
        }
        else
        {
            Debug.Log("Received: " + uwr.downloadHandler.text);
        }
    }
#

it's working!

#

May I use the same code but with async await instead of coroutines?

glass steeple
#

I guess so

#

would probably be faster to just try it ^^

chrome thistle
#

I already tried, and uwr.SendWebRequest() cannot be awaited. Where should I look for the equivalent awaitable?

jolly tree
#

Does Photon Cloud exist? Something that runs server in cloud and Unity communicates with it

chrome thistle
#

is this better? it's not async but uses event, I don't know if there is a pitfall on adding listener without removes

    private void PostRequestV2(string url, string json)
    {
        var uwr = new UnityWebRequest(url, "POST");
        byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(json);
        uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);
        uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
        uwr.SetRequestHeader("Content-Type", "application/json");
    
        //Send the request then wait here until it returns
        UnityWebRequestAsyncOperation a = uwr.SendWebRequest();
        a.completed += (b) => AOncompleted(uwr);
    }
    private void AOncompleted(UnityWebRequest uwr)
    {
        if (uwr.result == UnityWebRequest.Result.Success)
        {
            Debug.Log("Received: " + uwr.downloadHandler.text);
            LoginResponseData loginResponseData = JsonUtility.FromJson<LoginResponseData>(uwr.downloadHandler.text);
            Debug.Log(loginResponseData.user);
        }
        else
        {
            Debug.Log("Error While Sending: " + uwr.error);
        }
    }
bright mauve
#

(Netcode) can someone please send an example of networkDictionary?

olive vessel
#

Wasn't NetworkDictionary removed?

bright mauve
#

what should I use instead?

olive vessel
#

There's NetworkList but you don't get a Key Value thing then

bright mauve
#

that may work, thank you!!!

weary forge
#

Anyone have a good client side prediction solution for mirror

meager zephyr
#

I have a non-Unity bot streaming System.Numerics.Vector3s into my Unity client at a steady rate (roughly 60 fps). What is the most efficient way to convert it to UnityEngine.Vector3 once it hits the client? Currently constructing a new UnityEngine.Vector3(packet’s System.Numerics.Vector3.x, y,z) upon receiving the packet in the Unity client, but I am wondering if there is a more efficient way.

teal obsidian
#

vector3s are pretty fast to create anyways since they're just structs

meager zephyr
#

Thanks. I did read that modifying a default vector3 is slightly more efficient than constructing a new one, but they both seem acceptable for what I’m doing

teal obsidian
#

my vector 3's get split up into 3 floats when sending it over a network and then I just reconstruct it on the other end

halcyon bloom
#

nope

#

but i do recommend you use riptide by tom weiland

#

he made a tutorial of how to use it but its actually not that hard

worn burrow
#

its pretty awesome

slow lichen
#

How to make synced property?

#

I created abstract class from what should be inherited all door switchers

#

But in children class I can't make this property synced

high night
#

I want:
-Server instances automatically being hosted in playfab,
-Clients using playfab to figure out the servers ip,
-game server simulating the game and scoring the players when the game is finished

#

What sort of a photon realtime setup should I be doing here?

somber drum
#

A few yes, better to ask and assume some might wander by!

jagged violet
#

[Netcode for GameObjects]
How client can get reference to scene object just after it instantiates? When i'm trying to do this in player script (in method Start() ) by GameObject.FindGameObjectWithTag() client gets NullReferenceException but server finds it correctly.

halcyon bloom
#

i know i mean if you really want your code to work exactly how you want it to just use something like riptide and if you want to use photon like you said blackthornprod made a video about that

#

is that free?

#

oh nice

oak flower
#

!ban 911573495908032552 Annoying guerilla advertizement.

raw stormBOT
#

dynoSuccess Akarsh jain#1773 was banned

slow lichen
#

Help pls. What is it?

#

I don't trying instantiate network object

oak flower
#

Follow the object it points to to find the copy

slow lichen
#

I have two objects with same class

#

FirstKeypad and copy of FirstKeypad

#

I have many doors. In any door I have FirstKeypad and SecondKeypad

#

When I delete SecondKeypad this working

#

If I spawning more than one door this returns exception....

#

What...

oak flower
#

The error is telling you that you can only have one

oak flower
#

And the reason why

slow lichen
#

This is nonsense

#

Why I can't copy this objects

#

Hm

#

I need more doors than one

#

How to separate this entities?

#

Then why when I spawning many players this don't returning errors?

sacred spoke
#

(Photon PUN 2) first time with network events - I am trying to send a network event to destroy a bullet. However my photonEvent.code is not consistent. I am trying to sent a const byte 0 in my RaiseEvent but is not always 0 and therefore my bullets sometimes do not destroy themselves. Could someone please explain what I am not understanding? https://www.toptal.com/developers/hastebin/agozicayaz.csharp

tepid mantle
#

Has any one worked with riptide for networking?

spring crane
spring crane
sacred spoke
#

Yup - found out but alls good now thx

slow lichen
#

I anyway see this error

thick frost
#

Do anyone has any idea about an easy networking solution that does server authoritative movement for me with 0 cost?

#

?

spring crane
slow lichen
spring crane
#

You can copy prefabs, but not scene objects

slow lichen
#

I don't understand you

#

I should create many door prefabs?

spring crane
#

No

#

What are you referencing when you are instantiating those doors?

#

The door in the scene or the door in your project files

slow lichen
#

I think

spring crane
#

Well considering the error, you should probably know rather than guess 😄

slow lichen
#

But I don't understand how I should fix this error

#

If I can't duplicate this objects on scene then how I should create more door than one

spring crane
#

Make more using the prefab

#

Create a public door field in wherever you are spawning those doors from and drag in the prefab from project files

slow lichen
#

But this sounds so bad

#

Spawn doors using code

spring crane
#

I don't understand

slow lichen
#

I should spawning doors in needed positions using code?

spring crane
#

Depends on the situation, either way is fine

#

Scene objects you generally just can place in the scene

#

But if you need more at runtime, then sure, spawn more

slow lichen
#

May be I don't understand your words above

#

You said that I should create a public field containing a door.

spring crane
#

If you wanted to spawn a prefab, generally yes

slow lichen
#

Okay and what I should do with this field in next?

#

Spawn doors whenever when I need?

#

Using script

spring crane
#

What do you mean by this field in next? I don't know the situation

slow lichen
#

I have static map

spring crane
#

Then I would just place them in the editor

slow lichen
#

In every room should be one door

slow lichen
spring crane
#

So you aren't spawning new doors at runtime?

slow lichen
#

No

spring crane
#

As in you don't have code creating new doors

slow lichen
#

No

#

I don't have code creating new doors

spring crane
#

In that case I would go to the Mirror discord to figure out why your scene objects are behaving like this. Clarify upfront that you are not instantiating new objects.

slow lichen
#

Okay

#

Thanks

brisk timber
#

hey everyone i just started using the unity multiplayer SDK and the first code that i run in my game is await UnityServices.InitializeAsync(); and when it runs i get the error of "Failed to load config from cache"

#

this is what unity documentation says as the first thing i should run ti initialize unity service

shut zenith
#

Does anyone know a good tutorial Series on how to setup multiplayer in unity? I am making a simple quiz game, and i want for the Player to be able to host its own Server, on mobile, but i dont know how to do it

oak flower
#

You can find resources pinned in this channel. There are also third party solutions like Mirror and Photon and others, they have own tutorials.

static badge
#

Im currently trying to learn some basics about the new unity networking implementation "Netcode for gameObjects".
(Currently following the Golden Path Module 2 tutorial)
So my question would be: how would i declare a networked variable that is owned by the server? (and cant be overwritten by clients)
Something like:

public NetworkVariable<Vector3> Position = new NetworkVariable<Vector3>();
thick vigil
#

about unity.transport package,
i think there is a limit on the number of data that can be send in one frame.
Is that true? and if so whats the limit?

clever arrow
#

Hey guys is there actually any code example on how to do Client Side prediction in Netcode for gameobjects?

chrome thistle
#

Hi, I see others characters flicker when running in the same direction

#

I'm syncing with photon transform view

static badge
#

Using the new Unity Netcode for GameObjects package (which is in pre release) and wondering why that "OnFailedToConnect" callback wont get triggered after failing to connect a client via "Singelton.StartClient();"

using UnityEngine;
using Unity.Netcode;
using Unity.Netcode.Transports.UNET;

public void JoinServer()
{
  NetworkManager.Singleton.StartClient();
}

// The Callback
private void OnFailedToConnect()
{
  Debug.Log("Failed to connect to server");
}
olive vessel
#

Where does that callback come from?

static badge
#

Well im guessing its from the UNET transport

#

i havent found documentation on that so

olive vessel
#

I have never seen it before

static badge
#

It might be deprecated

#

But i need some kind of callback in order to check if the connection failed

mortal horizon
#

those are the old unet callbacks that used reflection, yea they dont work anymore

#

you should read the mlapi docs and figure out where their callback is

weak plinth
#

does netcode work w/ webgl and will it work on itch.io?

mortal horizon
chrome thistle
#

How to sync transform without jittering?

ionic abyss
#

hey anyone interested in participating in a gj??

jagged violet
#

Why client can't find a scene object in OnNetworkSpawn() or Start() but in Update() method it is able to find it only after 5th frame?
loopCount variable is to check on which frame taskManager is found and it's always 5 when it should be 1

rough timber
#

Hi, i need help with networking. Im working on a multiplayer fps game for the first time and im very confused.. i searched for the documentations in unity website but i dont know where to begin with. Unet, photon, netcode, im very confused. can someone please let me know what i should be doing?

unborn gate
#

Relatively easy to get starter with, are some tutorials on YouTube aswell

grave zenith
fiery onyx
austere yacht
fiery onyx
grave zenith
#

It is easy enough to get working given the tutorials they have, however it looks as though I'd have to rewrite all of my scripts

#

Looks like I won't be talking to anyone over at the mirror networking discord haha

mortal horizon
mortal horizon
grave zenith
#

Thanks, those phonewalls are woeful

slow lichen
#

I want use interface for network object

#

Did I do it right?

#

Idk why but I can't make property synced var

fleet aurora
#

how could i make a player respawn? using photon

minor escarp
#

i need someone or help with multiplayer in unity without port forwarding. it has to be server side because of cheating

glass steeple
#

if you have a server why wouldn't your forward the ports?

keen steeple
#

With Photon, how can I limit the max players in a photon lobby?

glass steeple
#

what version of photon?

runic rampart
#

Using MLAPI - how do I replicate a string?

glass steeple
#

where when what

runic rampart
glass steeple
#

yes

runic rampart
#

I want NetworkVariable<string> which is not possible due to string being managed. What's the next best thing I can do?

verbal lodge
#

You can do NetworkVariable<FixedString32Bytes>

runic rampart
#

aw that's unfortunate

verbal lodge
#

This is from 0.1.0

runic rampart
austere yacht
junior yacht
#

EDIT; removed, dumb/unlogic question.
Better formulated:
I am new and don't know where to start when it comes to structuring a game server, that can handle up to 300 players with larger open world (kind of as in games like RUST, or smaller MMORPGs).

austere yacht
junior yacht
#

besides your suggestion which i will follow, i dont know where to start when it comes to accounting. I put all the code for database and such in unity? Or has unity an API for this? Can i run separate SQL database or does unity has inbuilt database functionality?

austere yacht
#

you don't put code into unity, you just access the unity engine with your code, just like you would access any other system like a database.

runic rampart
#

Those classes should exist as a prototype foundation

olive vessel
#

I mean you were given a solution, you can use strings, but go off

austere yacht
#

why does your prototype need more features than your "shipped" product?

austere yacht
runic rampart
#

Because in normal professional game development you prototype constantly and then when you land on a design/solution, you optimize. You want the prototyping speed to be quick because your designers are quickly iterating and trying ideas

runic rampart
junior yacht
slow lichen
#

What is it?

#

I see it when I saving scene

real trail
#

Hey guys, I'm making a session based multiplayer game using mirror networking. my questions is very general. I want to create a lobby joining system that allows the user to host a lobby, and then anyone else can join it by entering its generated code. now how should I approach this? the ways im currently thinking is the following:

Option A:
Make a scene called "Main Server" where all people who host lobby must connect to and pass their IP, then load another scene where they are hosting the session. later on when a player wants to join the lobby, connects to the Main Server, which finds if lobby with code provided exists and returns its IP for the player to load another scene where he connects to that IP. (The Main Server would run on a fixed computer to keep the game matchmaking system up and running, and its IP would be fixed in the code).

Option B:
Similar to option A but instead of having a Main Server, I use a cloud database like Firebase to store IP addresses and then the users read from that.

Is there an easier way to make this? I wouldn't mind paying for a service to handle the "Main Server" functionality if they provide it.

jagged violet
#

Why is client able to find other scene objects only after a few frames? It seems like it has some delay but I would like to put reference logic in Start() method without getting NullReferenceException error. I am using ParrelSync to test game.

Loop count is often 4 or 5 displayed in Debug.Log

clear night
#

🌟 Hello from Unity! 🌟

If you're working in multiplayer, please consider participating in this short survey. This survey asks what is meaningful to you in terms of the performance characteristics of multiplayer networking solutions. It also asks for your feedback on netcode-related terminology, including category names and wording in group-related concepts. The survey might take 15 minutes total to complete, if all questions are answered.

Survey Link https://unitysoftware.co1.qualtrics.com/jfe/form/SV_8HRRikgpVzfomhw

fiery onyx
#

Quick question Im using unity’s netcode thing we’re should I put the player camera. I know I want it on the client so I’m guessing I shouldn’t put a netcode object in it?

austere yacht
#

your camera is likely different for each client, so its not part of a netobject. You also probably do not want multiple cameras in your client-scene for each connected client.

fiery onyx
#

Thx

junior yacht
#

@austere yacht following my question from yesterday, one point remains still unclear to me; the server, does it have to graphically spawn and render the world to act as server? or can it be headless without graphics?

austere yacht
#

there is a special build option for that

junior yacht
#

ah ok, thanks! i see planing multiplayer feature is more complex than i first thought. Besides the above question, some side questions arise, i.e. not sure if i need load balancing for more than 100 players, shall i use unity MLPA or Photon, and questions like that where i currently search the internet for information. But the main question about headless was solved, thanks for clarifying this 🙂

austere yacht
junior yacht
#

Thank you, thank god i can get rid of load balancing. For data exchange, i'd probably go for JSON and exchange position and inventory data for the begin.

#

Thanks to your help, the image slowly becomes more clear on how i'd structure and layout a multiplayer game

junior yacht
#

Thanks a lot, i will check this out 🙂

mossy kettle
#

which framework should I use for a multiplayer game? Photon seems cool, but 20 players for free ain't worth it. People suggested Mirror, but I'm not sure of it's limitations

I'm looking for less than 100 players for free. What options do I have?

somber drum
#

You pay $95 you get 100 players on photon iirc @mossy kettle

#

for the year*

#

which framework depends on your game though.

mossy kettle
#

My game is an fps.

clear bridge
#

Hi, where can I find some nice tutorials about multiplayer? I had a little experience with client-server in Java, but I don't know where to start with unity

olive vessel
#

There are many systems you can use, Unity's new official one is called Netcode for GameObjects, then there's community lead ones like Mirror and Photon. Photon is a company that has many different systems you could use like PUN or Fusion.

clear bridge
#

Any suggestions on which system should I use?

glass steeple
#

I like Mirror, but you should look into each of those and see which one fits what you want the best

clear bridge
#

using Unity's Netcode you make a user host a game, but I'd like to make user connect to my vps when the game starts because I need a matchmaking system

olive vessel
#

Netcode and Mirror are similar in this regard, both require you to either host servers, let players host servers, or use P2P

mossy kettle
#

I'm fine with letting players host servers, as long as I have more clients than what photon provides for free

#

how many clients can I have by using Mirror?

olive vessel
#

How many can you fit before it crashes?

#

They've done some CCU tests with hundreds of clients

tiny frost
#

I want to create multiple lobby like pubg matchmaking lobby. which api i should looked in

mossy kettle
mossy kettle
#

with a coder friend

mortal axle
#

Has anyone here used Photon networking with Unity's FPS template? I get camera rotation latency only in builds, I think it has something to do with the cinemachine component but I dont quite understand why

gray rose
#

Hi, I'm reaching out to anyone who's used the AWS (Amazon Web Services) SDK for Lambda.
I'm trying to simply invoke a function but get an empty payload.
If anyone has experience in this at all, help would be greatly appreciated, Cheers.
Here's my StackOverflow post for more info:
https://stackoverflow.com/questions/70982161/payload-is-empty-when-using-iamazonlambda-invokeasync-in-the-aws-net-sdk

slow lichen
#

If code base same on client and on server then why from the client the request is sent not by the client version of Player but by Input?

sharp coral
slow lichen
#

On clientisde I have my own player object

#

And I can change it

sharp coral
slow lichen
#

I about rpc

#

Player have player object on clientside

#

And when on client something calling in player object Command function

#

Player object calling this function on server

sharp coral
# slow lichen But why?

Speed is a reason. Sometimes the client does not have the computing resources necessary to compute/update the player object quickly.
So instead of computing locally, computation is handled on the server

slow lichen
#

How it works?

#

I calling function on client and this function through NetworkConnection calling same function on server?

sharp coral
slow lichen
#

But when I calling function on client, client should send request to server

#

Right?

sharp coral
#

Yep, I would assume so

slow lichen
#

But how it works?

#

Client have connection to server

sharp coral
#

Here's more in-depth

slow lichen
#

Where is it?

#

Can you send me link

sharp coral
#

Sure one sec

#

There's a local procedure call > parameters/inputs are packed (marshalled) into a message > message is sent from client to server > server receives message > server unpacks parameters (unmarshalling) > ...
... > server procedure acts on inputs, computes return values/updates player, and packs the return values/objects into a message > message is sent back to client

#

And then client unpacks messages and uses the return values to update objects on client side

dense leaf
#

I can't import MLAPI using package manager (installing from git url) with 2019.4.2f1
Furthermore git from CLI throws "repo not found"

slow lichen
#

Then what happening when I calling it?

#

When I calling it my client send request to server and server running this method on serverside

#

Right?

olive vessel
# dense leaf

MLAPI is now "Netcode for GameObjects", perhaps that's the issue?

quaint moon
#

Anyone heard of or tried Fishnet networking? Everyone’s Ive talked too has said it’s amazing but considering it has only been out a couple months, I have my doubts

austere yacht
#

have they said why it is amazing?

mortal horizon
#

I would recommend mirror or if you are making an fps or anything that needs prediction/reconciliation then go with photon fusion (or quantum if you have the money), all of which have been out alot longer than fishnet and have bigger communities to help you learn them

#

FN developer is also banned from this discord for discriminatory remarks and making alt accounts to advertise, not sure if that's something anyone would want to support, but as always, just use whatever works best for you

shadow spoke
#

Pretty much what cooper said... while it (FN) is touted to be better than other network stacks (the dev has a lot of beef with the Mirror devs for some reason...) there has been no games made with that said stack, while Mirror et al have been proven to be able to provide you with fundamentals to make a successful network game. Mirror is focused on MMO-based games, but it is mature enough to be utilized for other genres. If you are trying to make a FPS in the style of Call of Duty or Valorant or Tarkov, then if you have the money go with Fusion and/or Quantum, they are battle tested.

See also: Mirage. It's a rolling-release network stack that originally started out as a close sister to Mirror, but has since evolved over time. While it's still a distant sister network library to Mirror, it incorporates features that Mirror can't/won't accept and also provides a modular framework - instead of using all of Mirage at once, you can piecemeal the setup to tailor to your needs.

#

Honestly, do your homework and pick your poison. Don't just jump into a network library because "omg omg features" and find that it's not ideal for your needs.

#

Personally, I started with Mirror then migrated to Mirage. I still have Mirror projects that are in the freezer for other reasons outside of networking libraries. Then again I'm making a shooter that'll probably hit a niche market. Need to check out Fusion though, I should have done that last christmas but I didn't

distant bolt
clear bridge
#

Is the documentation outdated or something?

slow lichen
#

How to use TargetRpc?

#

How it works?

#

I added target parameter in method

#

But I never use it

#

How mirror understand who should receive this rpc?

spring crane
shadow spoke
#

Read the fine manual... it's there for a reason and it will help you a lot 🙂

dense leaf
slow lichen
#

This is Rider

lusty pivot
#

It looks like Rider.

#

Rider is awesome. I've been using it for years.

light ginkgo
#

Should I use Photon or Mirror for a Jackbox type game? (PC Screen is the game and all clients connect with a phone app)

mortal horizon
#

you can also just use mirror normally with default transport if you just want local play only

rough timber
#

im just following a tutorial on youtube and there's an error im getting

rough timber
foggy sage
#

No namespace at the top?

rough timber
foggy sage
#

no nevermind that you did that

olive vessel
hardy citrus
#

Im using netcode and steamworks, this code doesent work anymore?

NetworkManager.Singleton.GetComponent<SteamP2PTransport>().ConnectToSteamID = hostSteamID.m_SteamID;

Does anyone know what type im looking for instead of <SteamP2PTransport>

In NetworkManager settings i'm using the protocol called SteamNetworkingTransport, how do i call for that? 😄

quaint moon
# austere yacht have they said why it is amazing?

Yes, basically what I’ve been told is that Mirror is just Unity’s deprecated networking solution with a bunch of band aids on it. Fishnet offers everything that Mirror has except it’s completely free and has way more features. Plus small testing from me has shown that it is able to ping quicker than Mirror to various locations

quaint moon
#

^ Wont work with Photon because of their pricing/business model

austere yacht
verbal lodge
#

Maybe we're all just less component than the developer of fishnet 🙂

quaint moon
#

Unity needs an integrated networking solution like Unreal Engine

austere yacht
#

unreal is a much more focused product than unity. there is no point in comparing the purpose built features of unreal that make it easy to build FPS type games with a general purpose framework/engine like unity

quaint moon
#

I think it’s fair to say that Unity needs an integrated networking solution

#

Networking is an integral part of game development

austere yacht
verbal lodge
clear bridge
#

Hi, I'm totally new to Unity Netcode and I wrote these few lines, is there any "OnClientConnected" event? I can't find any info

verbal lodge
#

Yes it's called OnClientConnectedCallback

#

You can use it like this:

public void OnConnected(ulong clientId){
}

public void Start(){
    NetworkManager.Singleton.OnClientConnectedCallback += OnConnected;
}
clear bridge
#

oh thank you

#

I have only another question, how can I set the IP that clients have to connect to? Is this the way?

olive vessel
clear bridge
#

thank you

olive vessel
#

Yes I find it odd to totally discount any Photon product, but do listen to the guy who sends spambots to Mirror and here

clear bridge
olive vessel
clear bridge
#

oh it worked, thanks

shadow spoke
# quaint moon Yes, basically what I’ve been told is that Mirror is just Unity’s deprecated net...

While it’s true that Mirror has roots in the deprecated networking solution architecture, the bunch of bandaids statement is invalid. Mirror started out as HLAPI CE, and aimed to fix the bugs in Deprecated UNet, but then the developer wanted to go MMO scale. There are some things that have been improved dramatically. Comparing deprecated UNet now with Mirror is like night and day - Mirror does things that UNet could only dream of. 🙂

You will get mirror naysayers that will bash Mirror out of spite.

#

Besides, Mirror has been used in a large variety of games, be it Desktop, Console or VR. Naysayers said oh Mirror never will do VR networking… well, I bet they ate their own words when Mirror powered VR games started arriving.

#

If you are going to use FN, by all means go for it. Do that, make your game, hit it big and retire on a tropical island somewhere. Just keep in mind that support venues are pretty much locked to FGG’s outlets and expect things where the developer will just go “sorry, can’t help” and change topic.

#

Also check out Mirage, it’s what I’m using for my own shooter.

#

Networking is something that has many tools for the job

somber drum
#

Yeah can't beat that mirror community. Great folks over on their server.

distant bolt
#

The fishnet dude not only creates fake accounts that talk to each other and spam other discords, he also disingenuously has garbage like this:

#

Which is just a lie, and used to be worse until it was edited.

#

I'd have a spine and not support someone so transparently trash, but hey 🤷

frosty crystal
#

Hello-

#

I am trying to understand to protect my database. the issue is that my "Student entity" has a read/write policy/role to the "Students" table.

#

all the students have the same policy attached to their identity.

#

But Student A might make a request to change the value of Student b by using the access token belonging Student A

#

how can I prevent this issue?

#

Then I have to make a lot of claims for each of the users individually.

#

But it is a huge work to do

dense leaf
#

Which is the latest multiplayer system in unity?

rough grotto
dense leaf
#

thx

fiery onyx
#

So I was going to have my multiplayer game make the players the server so I don’t have to pay for a external server. But then I realized if I want it global it still needs one location to now who to talk to. Is there a simple way of doing this?

royal lava
#

can someone help me make a udp server which sends one string of data contating all the information nescesary between users

cunning mirage
#

hello, I am trying to use wantstoquit event from unity to show a message on screen to the player if he is in combat, the message appears but player is disconnected from bolt, any idea how to keep player connected, considering wantstoquit is exactly to cancel quitting the game? (using photon bolt)

pliant sundial
jade glacier
rough timber
rough timber
jade glacier
#

Let me get the link, if it allows me to post it here

verbal lodge
#

Your discord link is really hard to find btw. I suggest putting it in the web page footer or something like that if you want people to easily find it.

clear bridge
#

Using Unity Netcode I connected a client to my server and the connection works good (client has ID 1)... but when I see the "NetworkObject" script on the client, here is what I see

#

it says that the owner is the client with id 0 and that i'm not the owner of the object

#

Any ideas?

jade glacier
verbal lodge
clear bridge
#

uhm I spawn the object like if it was a single-player game, so I just put the prefab in the scene... Maybe this is the problem?

verbal lodge
#

Scene objects are owned by the server which has id 0

clear bridge
#

oh ok understood, thank you

#

btw where can I find a documentation to know things like this?

verbal lodge
clear bridge
#

yeah but is it still a work in progress?

verbal lodge
#

It's constantly being improved on.

clear bridge
#

oh ok, so I'll check it often, thanks

clear bridge
#

which is the best way to make a movement system in Unity Netcode? Should I send an RPC request in the update to send the server the new translated position?

#

i mean, is it good for the server to get a request every update?

#

Something like this

quaint moon
shadow spoke
#

Uh yeah, it does 🙂

quaint moon
#

Do you have the invite to it

#

I can’t find it

shadow spoke
#

I won’t directly link the discord as it may violate this discord rules doing so and moderators might get annoyed

somber drum
#

hey uhh.. one of you boys I think cooper was offering invite without the phone verification would you mind getting me on with that too? Phone is MIA would love to get back in the server 🙂

shadow spoke
#

@mortal horizon

somber drum
#

thanks!

hardy citrus
#

Is there any good github example with Steamworks.net and Unity? I want to test lobbys and syncing gameobjects

somber drum
hardy citrus
#

I dont get it, when i starthost i get the player prefab automatically, but when StartClient is triggered, no player prefab is created 🤔

somber drum
#

Ah haven't used the new netcode for gameobjects myself.

#

Make sure your client is connecting to the lobby etc sounds like hes not getting command to spawn character or something..

verbal lodge
hardy citrus
verbal lodge
#

It's using netcode 1.0.0-pre4 I think. I created it to test whether the steam transport works.

clear bridge
#

Hi, don't you think it is a bit laggy?

#

the video is recorded in 60 fps

radiant flare
clear bridge
#

so i need something like a Vector3.Lerp between the position 1 and position 2?

radiant flare
clear bridge
#

I figured out this

royal lava
#

is anyone available to voice chat with me about networking requirements for releasing a server protocol setup

runic rampart
#

Using Unity Netcode - should a network object parented to a network object work seamlessly?

runic rampart
#

Also I am consistently getting an error message saying that I am leaking memory due to a native list. This only started happening once I started using NetworkList. Is there something I need to do to properly dispose of these objects?