#archived-networking

1 messages · Page 109 of 1

pseudo adder
#

wat

#

yes

#

but it can be anything aslong as you change it spawnpoints = GetComponentsInChildren<what ever component>();

golden plume
#

ok

#

deleted what?

pseudo adder
#

nothing

golden plume
#

i just made another script for spawn manager cause it seemed easier but what do i change about the instantiate thing

#

the: ```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;

namespace a.parkour.fps
{
public class Manager : MonoBehaviourPunCallbacks
{
public string player_prefab;
public Transform spawn_point;

    private void Start()
    {
        Spawn();
    }

    public void Spawn()
    {
        PhotonNetwork.Instantiate(player_prefab, spawn_point.position, spawn_point.rotation);
    }

    public void DisconnectPlayer()
    {
        StartCoroutine(DisconnectAndLoad());
    }

    IEnumerator DisconnectAndLoad()
    {
        PhotonNetwork.Disconnect();
        while (PhotonNetwork.IsConnected)
            yield return null;
        SceneManager.LoadScene(0);
    }
}

}

#

so i remove thepublic Transform spawn_point; i assume but what do i change in the public void Spawn() { PhotonNetwork.Instantiate(player_prefab, spawn_point.position, spawn_point.rotation); }

shut yarrow
#

Make a public Transform[] spawnPoints

golden plume
#

i am just wondering what i put in the spawn function

shut yarrow
#

Then pick a random spawnpoint like

int randomIndex = Random.Range(0, spawnPoins.Length);
Vector3 spawnPoint = spawPoints[randomIndex].position;
#

Not sure if I understand your question, but this does select a random Vector3 which you can use to instantiate an object

golden plume
shut yarrow
#

Alright then just call that method from within that spawn function

golden plume
#

that picks a random spawn but i want to know how to instantiate there

shut yarrow
#
Transform spawn_point = GetRandomSpawnPoint(); //Assuming you have a function like this
PhotonNetwork.Instantiate(player_prefab, spawn_point.position, spawn_point.rotation);
golden plume
#

i think i got it

#

thanks

wind hinge
#

can somebody help me with this error. i can join a room and switch to another scene. When i leave the scene and go back to the main menu i get this error : PhotonView ID duplicate found: 999. New: View 999 on RoomManager (scene) old: View 999 on RoomManager (scene). Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new.

i also cant join another room and switch to the game scene again after leaving one single game. i can after i restart the whole game though.

#

i also get this error at the exact same time

InvalidOperationException: Duplicate key 999

jolly wadi
#

Hey guys. I am using Photon Transform View to sync players spine rotation but it is not syncing. I have added a transform view to its head and that is syncing tho. This is a mixamo character btw. Any help would be appreciated 🙂

spring crane
#

I would just temporarily throw in logs or breakpoints to confirm what is happening in the transform view component

jolly wadi
jolly wadi
spring crane
#

Is it happening though, did you check?

jolly wadi
#

I am not near my computer

#

I will check now

#

No it doesn't work 😦

#

Do you think an animation could be overriding it

spring crane
#

So the component definitely is syncing? Yea animation could override it

jolly wadi
#

Ok i will check for that

#

No the animations aren't overriding i disabled the components

#

This is not a good idea by any means but should i try Rpc's?

spring crane
#

It shouldn't make a difference if you confirmed that the transform view component is doing what it's supposed to

spring crane
#

How did you confirm that?

jolly wadi
#

Because on the breakpoint it is not registering

spring crane
#

Does the breakpoint trigger anywhere else in the script? Just making sure that the debugger is properly attached

jolly wadi
#

Yeah it triggers on the character moving

#

Just not the spine moving

#

Idk why

#

I think I might synchronise myself

#

Tbh

spring crane
#

Oh the transform view is nested?

jolly wadi
#

Yes

spring crane
#

Can't recall if there were any gotchas with that, but I think that should be fine with PUN.

#

Did you check if the other client is sending the rotation?

jolly wadi
#

Sorry for the spelling mistakes typing on a phone is annoying

spring crane
#

I meant if the owner of the object is writing the rotation as expected

jolly wadi
spring crane
#

Yea then obviously nobody can receive it

jolly wadi
#

yeah ik

#

im gonna try and sync another component

#

see what happens 🙂

spring crane
#

I would just debug the component up the chain, it's using the same API as you should be using

jolly wadi
#

Ok

spring crane
#

Are you using the normal or classic transform view?

jolly wadi
#

Normal

spring crane
#

Debug the conditions

jolly wadi
#

i did try classic btw tho

spring crane
#

If OnPhotonSerializeView is not being called, check if the PhotonView is finding the component. The finding method seems to be the first one if you look for references to the IPunObservable

jolly wadi
#

Yeah it does

spring crane
#

So at what point does it fail?

jolly wadi
#

Um writing

#

Actually after futher observation it all works

#

but just doesn't sync

golden plume
#

does anyone know how to make random map change after like 5 mins with a timer at the top of the screen? here is my manager script ```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;

namespace a.parkour.fps
{
public class Manager : MonoBehaviourPunCallbacks
{
public string player_prefab;

    private void Start()
    {
        Spawn();
    }

    public void Spawn()
    {
        Transform spawnpoint = SpawnManager.Instance.GetSpawnpoint();
        PhotonNetwork.Instantiate(player_prefab, spawnpoint.position, spawnpoint.rotation);
    }

    public void DisconnectPlayer()
    {
        StartCoroutine(DisconnectAndLoad());
    }

    IEnumerator DisconnectAndLoad()
    {
        PhotonNetwork.Disconnect();
        while (PhotonNetwork.IsConnected)
            yield return null;
        SceneManager.LoadScene(0);
    }
}

}```

astral gull
#

May I ask, is it hard to migrate from photon pun to photon server? Does the syntax differ too much?

cloud nest
#

I have problem in photon when masterclient goes to background everything pauses

granite yew
#

Hey. I am making a game with roles. I have 3 roles, Innocent,Detective and Murderer so far. How can I assign the roles individualy to all players? ( I am using Photon Unity Networking btw)

modern drift
cloud nest
visual lotus
#

Hi, Im using Photon Pun 2 for my networking and can anybody help with making a level voting system

next jolt
#

should i use Pun or Mirror for player hosted servers

olive vessel
#

Mirror

next jolt
#

alright, thanks!

teal obsidian
#

Does anyone know of any public custom wheel collider scripts that can be used with prediction?

#

the default physx ones won't cut it. If anyone can share a script, that would be amazing.

dry egret
#

Can I use both Photon PUN, Voice and Chat in one project? Or how would I "stack" Photon's types? Thanks

dry egret
#

Do I have to create 3 projects in the dashboard for this to work? Like, 1 PUN, 1 CHAT and 1 VOICE?

jolly wadi
#

Nah

#

You just import it for each one

#

so like import Chat Pun and Voice

#

oh wait now i get what u mean

jolly wadi
dry egret
#

Great, thank you!

dry egret
#

Can you make the player host locally with Photon or should I use Mirror for that? Thanks!

vestal flicker
#

has anyone used unity remote config?

#

I'm getting a response of ConfigOrigin.Remote even if my internet is off and the cached version is being used

#

it allows player to modify the remoteConfig json and turn off their internet to bypass the servers overwriting their changes

jolly wadi
#

In Pun Players host locally

dry egret
#

Oh I thought Photon provided a server

jolly wadi
#

wait i take that back

#

They provide servers

dry egret
#

that's why they allow certain amount of concurrent players, well that's what I thought not sure that's the case

jolly wadi
#

but in Fusion the new project in developement they allow Client Host Server Host and all that you need

dry egret
#

so I shouldn't create a project as 'PUN'? Should I choose another one?

#

Sorry if these are dumb questions I'm just getting started with multiplayer

cloud nest
#

I have problem in photon when masterclient goes to background everything pauses

cloud nest
#

Not literary everything but wverything that masterclient controls

west hamlet
#

Hey, I want a networking system that works without a host. So the game is hosted by the server. But I don’t won’t to run the server on my own pc. Does anyone know what the right solution is for me?

west hamlet
verbal lodge
#

You can use most networking solutions and host your servers on the cloud. There are services around like Playfab or AWS Gamelift which have been made for that or you can buy a VPS and do it yourself.

cloud nest
patent fog
#

Then I'm not sure I understand what your problem is

cloud nest
#

my problem is when master client goes to background that everything master client controls will pause

#

i need some way to swtich master client when he is in background

indigo thicket
#

Hey guys, I'm creating a lobby with MLAPI. Should I use the switch scene locally in Unity to move from the menu to the lobby, and then use the synchronized MLAPI scene change to move from the lobby to the game once the players are ready?

#

Another question: with the lobby I don't need the player pref spawned at connection time, how do I spawn it manually?

indigo thicket
#

How do I check if a connection to a server was successful with MLAPI? I can't find any callback in the client-side

cerulean crescent
indigo thicket
#

No, I mean, I need to check if my client has successfully connected to the server

#

So if StartClient() worked and the server was online

cerulean crescent
#

As a player prefab spawning wouldn't happen unless you've connected successfully

#

the NetworkManager.Singleton.OnClientConnectedCallback will work the same way. You can assign a method or function that will call whenever you've connected as the client

#
        private void StartClient()
        {
            NetworkManager.Singleton.StartClient();

            NetworkManager.Singleton.OnClientConnectedCallback += OnConnectedClient;

        }
        private void OnConnectedClient(ulong clientId)
        {
            print("Client: " + clientId + " connected.");
        }```
#

This can be used after using StartServer() as well. The difference is that the OnConnectedClient will be called for each client connecting for the server.

#

Whilst when it's after starting a client as the above example, then it will only be called ONCE, which is when "this" client has connected

indigo thicket
cerulean crescent
#

Though you need to spawn it on the server, so make sure you add the callback after you've started the server

indigo thicket
#

Wait. OnConnectedClient works both for the server AND the client?

#

I thought I could use it only on server-side

indigo thicket
indigo thicket
#

Can I send a list of a serializable class in my ClientRpc parameters?

weak plinth
#

Hello,

what is currently the best solution for FPS networking (Fast FPS, like Quake, CS, etc)
Of course, Server/Client architecture would be nice and no p2p.

Thanks in advance.

gleaming prawn
#

Fusion

indigo thicket
#

Why isn't my ServerRPC not being executed at all? (in the host, that should be both the server and the client)

 void Start()
    {
        InitializeCards(); //This gets executed
        Debug.Log("???"); //This gets executed
        if(IsClient)
        {
            if (IsServer)
                Debug.Log("I'm also server"); //This gets executed
            AddLobbyClientServerRpc(NetworkManager.LocalClientId, name); //This does NOT get executed, and that's the function that I'd like to execute
            Debug.Log("I'm client"); //This gets executed too, since it's a host
        }  
        else
            Debug.Log("...");//This does not get executed, as expected

        Debug.Log("!!!!");//This gets executed
    }    


    [ServerRpc(RequireOwnership = false)]
    public void AddLobbyClientServerRpc(ulong client, string name)
    {
        Debug.Log("Text"); //This does not get executed
        //Things...
    }


#

I have no clue at all, the computer executes everything above and under the function, but it seems it's not entering in it

#

Ok no RPCs at all are being executed

golden plume
#

wait no i do get an error

#

could anyone help pls

#

i have spent ages trying to fixgure it out

#

i dont know why it dosnt work i havnt been able to figure it out

#

???

#

it is not being called but why?

indigo thicket
#

Is there a way to call RPCs in MLAPI in a network object that's not been spawned? I need to call rpcs from clients, but the player prefabs is still not spawned, it will need to be spawned later on...

jolly wadi
#

Wait what are you trying to send

pseudo adder
#

it is giving me a error Cannot implicitly convert type 'Photon.Realtime.Player[]' to 'Player[]' pls help

pseudo adder
#

ok

jolly wadi
#

ok lets do this diferently

pseudo adder
#

k

jolly wadi
#

you see on joined room

pseudo adder
#

yea

jolly wadi
#

i will write some code then explaon

pseudo adder
#

k

jolly wadi
#
public override void OnJoinedRoom()
    {
        MenuManager.Instance.OpenMenu("room");
        roomNameText.text = PhotonNetwork.CurrentRoom.Name;

        foreach (Transform child in playerListContent)
        {
            Destroy(child.gameObject);
        }

        foreach (Player player in PhotonNetwork.PlayerList)
        {
            Instantiate(PlayerListItemPrefab, playerListContent).GetComponent<PlayerListItem>().SetUp();
        }

        startGameButton.SetActive(PhotonNetwork.IsMasterClient);
    }
#

basically instead we run a foreach loop through the players in the room

#

and we instantiate based on them

pseudo adder
#

so i just cp in

jolly wadi
#

yeah

pseudo adder
#

k 1 sec

jolly wadi
#

try it

pseudo adder
#

it says the same thing

jolly wadi
#

show me

pseudo adder
#

k

#

its giving 2 now

jolly wadi
#

ok the first one is because at the end

#

in

#

SetUp(player);

#

put that

pseudo adder
#

k

#

ye it work now the other one

jolly wadi
#

did that fix the first one

#

ok

pseudo adder
#

yes

#

im so confused with photon

jolly wadi
#

oh there is a small problem

#

ok do this

#

at the top

#

using Player = Photon.Realtime.Player;

pseudo adder
#

k ill try

jolly wadi
#

did that work?

pseudo adder
#

im getting this now

jolly wadi
#

oh ok makes sense

#

it is hard to explain

#

delete that from the top

pseudo adder
#

k

jolly wadi
#

then in the foreach loop put that in

#

so

pseudo adder
#

?

jolly wadi
#

foreach(Photon.Realtime.Player player in PhotonNetwork.PlayerList)

pseudo adder
#

k il try

jolly wadi
#

make that the top line

pseudo adder
#

got it

jolly wadi
#

errors?

pseudo adder
#

ye 1

jolly wadi
#

what

#

show

pseudo adder
jolly wadi
#

oh that again

#

maybe change that to

#

Photon.Realtime.player

pseudo adder
#

k

#

put that instead of player?

jolly wadi
#

yeah

pseudo adder
#

im getting this now 😦

jolly wadi
#

nah put lower case

pseudo adder
#

k

jolly wadi
#

Photon.Realtime.player

pseudo adder
#

still no

jolly wadi
#

wait a sec

pseudo adder
jolly wadi
#

ahhh do this instead

#
{

}
#

and then inside where you have setup

#

just put player

#

so

#

SetUp(player);

pseudo adder
#

k

jolly wadi
#

it work?

pseudo adder
#

hold on

#

it should be foreach(var player in PhotonNetwork.PlayerList)
{

}

jolly wadi
#

yeah

#

y

pseudo adder
#

and inside SetUp(player)

jolly wadi
#

yeah at then end of the line

pseudo adder
#

k

jolly wadi
#

Instantiate(PlayerListItemPrefab, playerListContent).GetComponent<PlayerListItem>().SetUp(player);

pseudo adder
#

its givingme the same error as at the start

jolly wadi
#

jeez

#

do you have a script called PLayer

#

Player

pseudo adder
#

1 sec

#

yeah...

jolly wadi
#

well maybe change the name of that

pseudo adder
#

k

jolly wadi
#

you have to change the name outside and inside

#

so if the name was PlayerController

#

go inside and change it too

#

public class PlayerController : MonoBehaviour

pseudo adder
#

k

#

no errors lemme test it

jolly wadi
#

omg

#

i knew that was the problem just didnt wanna assume

pseudo adder
#

im so sorry

jolly wadi
#

nah thats ok

#

lol

pseudo adder
#

2 seconds im gonna test it

jolly wadi
#

k

pseudo adder
#

it works tysm your a life saver 🙏

jolly wadi
#

np

indigo thicket
jolly wadi
#

why cant you do it when it is instantiates?

indigo thicket
#

I do this using a script, a lobbymanager, that sends the client data with his Start(), using a server rpc... But since I can't use the server rpc without spawning the object, this seems quite wrong

indigo thicket
jolly wadi
#

no but you said that you are trynna send an rpc to a prefab that is not yet instantiates

#

why cant u wait for it to instantiate then send the rpc

#

like upon spawning the player prefab send the info

jolly wadi
#

nah wait

indigo thicket
#

The prefab will be instantiated in game

jolly wadi
#

yes

indigo thicket
#

At least, that's what I thought

#

In the lobby, no player, no prefab

jolly wadi
#

and you are trynna send info to that prefab?

indigo thicket
#

No

jolly wadi
#

oh it is gonna be in another scene?

indigo thicket
#

I've got an UI with all the players informatrion

#

in the Lobby

#

A list of cards, representing the players

jolly wadi
#

wait so you are gonna be in the lobby then load into the game and you want the prefabs to have those values?

#

or have the info

indigo thicket
#

Well... More or less, yes, but the prefabs will not "get" the information from the lobby

#

the data will prbably be stored in another way

#

Wait

jolly wadi
#

Yeah you can create a dontdestroyonload object

#

then take it to the game

#

as it will save the values

indigo thicket
#

That's what I'm trying to load

jolly wadi
#

oh dapper dino

#

so you wanna load the player names

indigo thicket
#

Oh yeah lol

#

Currently only the names

jolly wadi
#

i didnt watch that i have never used MLAPI tbh

#

but since you are dealing with rpc's it shouldnt be hard

#

wait so these guys get instantiated?

#

like when a player fills a spot

indigo thicket
# indigo thicket

Summarized is: to use and receive rpcs I need a spawned object in the network, and I haven't one, so I can't send and receive other player's data

indigo thicket
#

Currently it just switches scene and can only press the isReady button

#

But I think I'm forced to have at least one network object per client

#

so they can use rpcs

jolly wadi
#

wait Lazy

#

i understand that they have callbacks?

#

like on someone connected and disconnected

indigo thicket
#

Which callback? Currently I'm only using the OnConnect callback

#

Yeah

jolly wadi
#

well with that

#

what you can do

#

is create a dontdestroyonload object in the lobby.
then create a string[] and save it .

#

as it is dont destroy on load it will transfer to the game

#

in which you can grab the valuews

indigo thicket
#

Well, I'm using a static string for that

#

It's working

jolly wadi
#

oh

#

wait

#

Does your code work to some extent?

indigo thicket
#

But it works if I spawn the lobbymanager as a networkobject

#

If I don't spawn my LobbyManager the rpc's about the "upload" and "download" of the data will not be executed, so every card just results in an empty slot

jolly wadi
#

hmmm

indigo thicket
#

if I spawn the LobbyManager, the host effectively connects

jolly wadi
#

so is the difference between yours and dapper's code that he does it all in one scene?

indigo thicket
#

A lot, I basically am writing my own code lol, I also did my UI (based on his video, but still, I downloaded nothing)

#

His code is way too complex and uses his libraries

#

I used some of it to resolve some problems

#

Anyway I think I must use a player prefab to do this

jolly wadi
#

ok

indigo thicket
#

If someone has another easier/cleaner option, it would be appreciated

#

but thanks anyway for the help

jolly wadi
#

np

indigo thicket
#

brainstorming always help ❤️

cerulean crescent
#

Oh or the other example projects. I'm pretty sure there is one that does exactly what you need

#

let me find it for you

#

This project includes lobbies with scene management

#

I'm gonna do something similar myself, but I haven't gotten around to it yet so I can't help you personally

cloud nest
#

I have problem in photon when masterclient goes to background everything pauses

cloud nest
#

I know you need some way to switch masterclient when he is in background but i dont know how to script it

spring crane
#

@cloud nest Which part? Make sure run in background is enabled to avoid this problem where possible, but when it can't be, I would check if MonoBehaviour.OnApplicationPause is called. PhotonNetwork.SetMasterClient() for setting the masterclient.

jolly wadi
golden plume
#

can i call an RPC from a different script to the one that the RPC is on I am using photon and i cant figure out why this dosnt work to kill the player

#

it dosnt even call the RPC

#

public void Respawn()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Time.timeScale = 1;
photonView.RPC("Die", RpcTarget.All);
}

#

i get this error when i click the respawn button

#

and it takes me to the photonView.RPC("Die", RpcTarget.All); of the respawn function

#

can anyone help?

#

what do i do?

indigo thicket
#

soooo... I have some questions with this code. I'll try to ask just the hardest ones, to not flood this chat 😛

indigo thicket
river meteor
cloud nest
tender marten
#

Hi, can someone please help me?
Unity console writing this errors:

Assets\Scripts\TestConnected.cs(23,41): error CS0246: The type or namespace name 'DisconnectedCause' could not be found (are you missing a using directive or an assembly reference?)

Assets\Scripts\TestConnected.cs(17,26): error CS0115: 'TestConnected.OnConnectedToMaster()': no suitable method found to override
olive vessel
#

Your class must be derived from MonoBehaviourPunCallbacks

empty relic
#

Does anyone know what this mean??

PUN is in development mode (development build). As the 'dev region' is not empty (asia) it overrides the found best region. See PhotonServerSettings

barren onyx
#

I am having problem with the mirror plugin where both server and client have identical script, but they are in two different game project. When I start the host, the client can join, but the client gets this error message:

cerulean crescent
#

So whenever people start the game (Main menu) the menu control is available in that scene. Whenever a client decides to connect they press a button and they're switched to the lobby scene

#

and inside the lobby scene is where the LobbyControl is. Spawning is not something you should do with the control, as there should only exist 1 per client

#

Spawning is only the concept of replicating a networkobject that exists on the server across all the clients, which is not what you want to do with the control I'd say

#

And what I assume you want to do is just creating an empty gameobject in the respective scene, and adding the control script to it as well as a networkobject

#

This example is for hosted lobbies too, hence the checks for "isHosting"

feral trout
#

i got 1 error when importing pun

#

hello

#
UnityEditor.AssetDatabase:ImportAsset(String)```
#

i think its a weird one

indigo thicket
#

When you join the lobby, he spawns both the playerprefab (it's hidden in the scene but you can see it in the hierarchy) and the lobbycontrol... The lobbycontrol has a networkobject, and can send RPCs

#

However, if I do the same with my lobbycontrol - that I called lobbymanager - the network object is not active, or spawned, and if I look at it in the hierarchy, with the game on play, there's a button to manually spawn it

#

Lobbycontrol in the invaders project has not this button, and it is automatically on, both for the client and the server

#

That's his lobby control

#

And that's mine, if I don't spawn it manually - and I can only do it in the host

cerulean crescent
#

I have not cloned the repo myself, so I can't really see. But it seems he has 2 prefabs, one being "NetworkManager" and one "Invaders Game Manager"

#

Maybe one of these prefabs does some of this work?

indigo thicket
#

I'm... not sure? I'm looking through the Scene Transition Manager inside the NetworkManager, but it's pretty complicated, so many callbacks... However, if he calls a .Spawn() for the lobbycontrol to spawn it and use the rpcs, shouldn't the object be spawned to every client?

cerulean crescent
#

Yeah so the server is probably calling spawn once to replicate it, for the lobby control that is

indigo thicket
#

Or, maybe, he uses a ClientRpc with the .Spawn() executed only by the client that connected and has not a lobbycontrol... Is that possible?

cerulean crescent
#

The menu control isn't

indigo thicket
#

So, there should be one lobbycontrol per client

cerulean crescent
#

There should be one per client, yes

indigo thicket
#

I tested it: when two connected players join the lobbycontrol is still one o.o

cerulean crescent
#

Because it is decided who is hosting in the awake method

#

Of the lobby control

#

Well there should be 1 lobby control on each client

#

There shouldn't be a lobby control for each client

indigo thicket
#

That's what's happening, but I can't understand why: the .Spawn() method spawns the networkObject only in local?

#

I mean, not replicating it everywhere

cerulean crescent
#

Well say a client connects, then it has nothing

#

The server knows a client just connected, and will spawn the lobby manager

#

So each client will be assigned 1 lobby manager each

#

but the server will still have only 1, which is how it should be

indigo thicket
#

i mean how

#

if I use .Spawn() it spawns the object for everyone

cerulean crescent
#

I'll just clone the project myself lmao, I need to check the prefabs and the scene

indigo thicket
#

The prefab has no lobbyControl

#

I checked it

cerulean crescent
#

To be fair the lobby control has no NetworkStart

#

So I don't think it's being spawned at all

#

and only has the networkobject to use RPC's

#

It is just assigned in the scene and stays there on both client / host

#

Not sure if that's a thing though, I haven't use networkobjects outside of prefabs

#

Yeah that seems to be the case

#

In the main menu it is decided who is host, by setting the static bool in the Lobby control. Then the scene is switched to the Lobby which Instantiates the gameobjects in that scene (LobbyControl) being one of them

#

the Awake() is therefore called and starts a host, or starts a client etc etc

#

If it's the host, it will start listening for connections, to where he adds himself to the list of connected clients and then add callbacks to be notified whenever new clients connects

#

if all the players are ready, the callbacks are removed from the manager etc and the scene is switched to the "in game"

#

And since the networkmanager will exists between scenes if I'm not wrong (it isn't destroyed), the same networkmanager behaviour is just carried between scenes

indigo thicket
indigo thicket
#

If you destroy it the connection stops

cerulean crescent
#

Because the host itself is started within that script

#

so spawning anything prior to that isn't even possible

indigo thicket
cerulean crescent
#

I think you're too hooked about the spawning of the lobby controls

#

what I understand is that they're not spawned at all

indigo thicket
#

Because my object is not online

indigo thicket
indigo thicket
#

Both screenshots are in the lobby

#

His networkobject is online and can send rpcs, mine is not and can't

#

and I can't find why my networkobject is not online if it's not spawned

barren onyx
indigo thicket
#

Wait.. Im going to try something

indigo thicket
#

Nothing, it's not working

#

I really have no clue why my object has to be manually spawned and his doesn't 😦

golden plume
#

???

river meteor
#

then try to execute via PV.RPC(...)

golden plume
golden plume
#

the pause menu thing is not part of the player cause that gives me problems with the leave button

golden plume
barren onyx
#

I'm sorry that doesn't make sense? The way the code works is that as long as it can see the host on server discovery, it immediately joins (It's intranet based only, not internet base).

golden plume
golden plume
river meteor
#

I don't know if you done correctly what I said, for me it should work (NRE should be gone)

golden plume
golden plume
#

[SerializeField] PhotonView PV;

river meteor
#

Did you set your photonview in inspector?

golden plume
golden plume
golden plume
#

if you are wondering why the multiplayer pause gameobject is not active it is because it gets turned on when player presses esc

river meteor
#

aaand where do you have your script attached?

#

I cant see it here.

golden plume
#

script on the canvas (parent of multipause)

#

and i set the phootn view on it

#

now i am getting this error

#

I think i have to attack the multipause to the player prefab but then i cant use the leave function

river meteor
#

oh

#

you did it

#

and you are getting this error

golden plume
#

yes

river meteor
#

because you are referencing wrong photonview

#

let me explain

golden plume
#

wait do i put the player prefab in there?

river meteor
#

If you want to call RPC on some object - this object MUST HAVE photonview too and you must refer to that photonview and then execute rpc

#

So you must refer to object's called "Target" photonview

#

because there you implemented your rpc function

golden plume
#

how do i do that tho cause i set the player prefab as the pphoton view but when i tried it got this

#

and it didnt work

golden plume
#

???

river meteor
#

you must store somewhere a player gameobject which pressed the button

golden plume
#

how

river meteor
#

Learn some basics of programming then try to make a mp game please, I don't wanna explain here all c# stuff related

golden plume
#

ok

swift epoch
#

So, I'm learning Mirror, and with this code if the client presses space, the host moves up, and if the host presses space the client moves up. The client also sees no changes at all. Can someone help me figure this out?

#

So I copied some code from a tutorial, and I still have the exact same problem, so I don't think it's something with that

#

Here's my network manager

#

And the network identity of the player prefab

swift epoch
#

Got it. I didn't realize it needed a network transform

#

And also a single camera

sage agate
#

i am making a third person shooter game using Photon PUN
how can i make players instantiate with a random playercontroller prefab from a list of diffrent playerController prefabs?
i want to do this because i dont want all players to look the same

river meteor
# sage agate i am making a third person shooter game using Photon PUN how can i make players ...

Just do prefabs with different playermodels and in your network code when you instantiate player do a list/array with these prefab and then randomize it something like ```cs
[SerializeField]
private GameObject[] playerVariants;

public override void OnJoinedRoom()
{
GameObject spawnedPlayer = PhotonNetwork.Instantiate(playerVariants[Random.Range(0, playerVariants.lenght)], Vector3.zero, Quaternion.identity);
}

sage agate
#

oh
thanks

sage agate
river meteor
#

I don't know. Try

#

I think yes because it is done via PhotonNetwork Instantiate

indigo thicket
# cerulean crescent maybe this is true then

Yup. If I start the server/client in the lobby, with the lobbymanager already loaded in the scene, it gets spawned. Damn man, so much time lost for something not really intuitive...

indigo thicket
#

Is there a way to get a console error in MLAPI due to a failure in executing RPCs? Now my object is spawned, everything should be fine, but it still refuses to execute all my RPCs, with the networkobject spawned and the connection active. No errors in the console, nothing...

patent fog
#

Probably you're testing on localhost and the port is already used by another application ?

#

2 apps can't use the same port on the same address

thick barn
#

i need some MLAPI help

#

I am programming a FPS game with MLAPI as multi player api. Instead of Raycast i am shooting instanced bullets tho they only seem to work on the owner.

#

What do I do to make it work on the client as well?

granite yew
#

Hey. I want to make an item that if you type the player's name in an input field and press a button, the player dies. How can I do this? Thanks.

#

so kinda like the Death Note lol

weak plinth
#

guys I need help with making a huge decision.. my game is more than 95% done , like all i need to do at this point is to make better materials and edit some things in maps... but I also am thinking about moving from PUN to Fusion cause fusion is much better especially in the case of my game, yet at the same time I am having a rough start at it, I dont know why.. lots of people seem to be working with it with 0 problems... and i am not sure what to do anymore, stay using PUN or move to fusion ...
if someone has used both please give me your opinion

olive vessel
#

If you're 95% done, then whatever Fusion supposedly brings you cannot be that crucial, and if it's delaying you I personally don't see the point

#

Plus depending on project size, if you're 95% done, changing to Fusion from PUN could set you back a good while

gleaming prawn
#

95% done is a tough decision

#

then whatever Fusion supposedly brings you cannot be that crucial
This is the interesting point indeed... If you say you are really that complete with PUN, then either:

  • you do not need all the features fusion brings compared to PUN (it's miles different, fusion is closer to Bolt than to PUN)
  • or maybe you are NOT 95% done...
patent fog
#

I would release to the market what you got as a v1, then work on your v2: migration to Fusion + implement players feedback on the v1

#

So answer is yes to both 🙂 (I hate to pick choices)

#

But as Erick said, if you don't see much of a difference with Fusion, did you really need its features ?

cerulean crescent
feral trout
#

I got an error when importing pun

#
UnityEditor.AssetDatabase:ImportAsset(String)```
#

what is that

spring crane
#

I would guess it's some Unity issue

swift epoch
#

Odd question. What kind of netcode does Mirror use?
My friends are obsessed with rollback netcode, to the point where they bought Guilty Gear just to see how far they could push it. But I have no idea what Mirror uses

#

I can't seem to find anything online

gleaming prawn
#

Mirror uses client server just transferring changes from the objects to the clients

#

It does not qualify either as deterministic predict rollback (which is what people normally mean when they say rollback netcode) or as tick based state transfer (the basis for snapshot interpolation, client side prediction and lag comp)

#

If what you want is predict rollback like the type found in platform fighters or fighting games, off the shelf you have photon quantum. Other than that, you need to build yourself

swift epoch
#

Is this the correct way to do this? The player is supposed to rotate and reflect that change to everyone, while the camera (the player's child) is supposed to rotate client-side only, since each client only has their camera in the game

#

When I run it, as soon as I move my mouse on either client or server, it seems to make two copies of the NetworkManagerHUD but if I disconnect the client and rejoin it works perfectly

#

Got it working using a TargetRpc

opaque dew
#

FishNetworking just managed to send a rpc in 2 bytes. I am seriously looking forward to the official release.

cerulean crescent
#

Some changelogs if you're interested

#

So might be worth waiting for that

swift epoch
#

I'm using Mirror. How am I supposed to override functions on NetworkManager? If I make a script that inherits from it I get "Multiple NetworkManagers detected in scene"

swift epoch
#

Got it. I literally just deleted the main one

hasty pendant
#

Hello guys. Am creating a Multiplayer game and I tried to apply a damage on the same script attached to the player but it keeps telling me DealDamage can't be found on photonview 1001

I will drop the script later

normal dust
#

MLAPI, I have a client instantiating an object. I call a ServerRpc and instantiate the object and then .spawn(). But the problem is I need the player that spawned the object to know which object was spawned in his scene. How do I do this ???

prime salmon
#

how do I send a call to a clientId?

indigo thicket
#

Hello guys, I'm using mlapi and while the docs explain how to send a clientrpc to a specific client, they don't explain how to do a "foreach" with the clients connected

#

How can I do that? I need to manually spawn a player prefab and give the ownership to the corresponding client

indigo thicket
indigo thicket
prime salmon
#

@indigo thicket yeah, with MLAPI

#

I'm confused who is the owner of animator variables as well

indigo thicket
#

like that

#

and as a ClientRpcSendParams you set the clientid

prime salmon
#

and then it will only arrive at that single client?

#

or do I need to manually check the Params?

indigo thicket
#

"The following code provides an example of using ClientRpcSendParameters, which will allow you to send a ClientRpc to a specific Client connection(s) whereas the default MLAPI's behavior is to broadcast to every single client."

#

it will arrive at that single client

indigo thicket
#

and set it

prime salmon
#

yeah, I know how to get the clientId so that's okay 🤔

#

basically I have this code on my player

indigo thicket
#

The ClientRpc, yes

#

but it has to be called serverside

#

as every clientRpc

prime salmon
#
public class Player : NetworkBehaviour
 
private void Start()
{
  playerInput = GetComponent<PlayerInput>();
  playerInput.enabled = IsLocalPlayer;
}

public void OnAttack(InputAction.CallbackContext context)
{
  if (context.performed)
  {
    DoDamage();
  }
}

public void DoDamage()
{
  Collider2D[] results = attackCollider.GetOverlappingColliders();
  foreach (Collider2D col in results)
  {
    if (gameObject.GetComponent<Player>() != null)
    {
      NetworkObject networkObject = gameObject.GetComponent<NetworkObject>()
      var clientId = networkObject.OwnerClientId;
      ClientRpcParams clientRpcParams = new ClientRpcParams
        {
            Send = new ClientRpcSendParams
            {
                TargetClientIds = new ulong[]{clientId}
            }
        };
      TakeDamageClientRPC(1, clientRpcParams);
    }
  }
}

[ClientRpc]
public void TakeDamageClientRPC(int damage, ClientRpcParams clientRpcParams = default))
{
  Debug.Log("I got damaged!")
}
#

But I can only call "DoDamage()" on the server then?

hallow herald
prime salmon
#

@indigo thicket its not working 😢

indigo thicket
#

Everything that has to be done on the network must be either called by the server (if you're the client you can call a ServerRcp) or done by the client on one of his objects

#

Doing damage is something that has to be done on the network

#

because the server and the other clients must know how many HP the enemy/other player has lost

#

So yea, you have to use a ServerRpc as a DoDamage function

#

If that was what you were tying to do, no need to do the client filtering that you were doing: the ServerRpc will be called once by the client, and will be executed only by the server, once

prime salmon
#

okay 🤔

#

so the problem is that my AttackCollider is not rotated on the server 🤔

#

working on it...

indigo thicket
#

Guys! Do you know any way to get the line where the NetworkManager is returning an error?

#

I've got this problem so many times: I do something wrong with the code, like trying to use a clientId that doesn't exists, and the console correctly prints an error, but the error has no specific line of my code, but only MLAPI's code

#

Like this error: "KeyNotFoundException: The given key was not present in the dictionary."

#

I have no clue what is giving it, and since the console doesn't tell me which script is calling the line that is causing it, I can't fix it

prime salmon
#

@indigo thicket it works now.. I think :p thanks!

indigo thicket
#

No problem 🙂

sour crystal
#

Does anyone here have experience with Photon?

#

...

prime salmon
#

no, I don't have experience with photon 🤷

olive vessel
#

Usually better to ask a specific question, that way the conversation moves faster

#

Also allows people who don't know Photon, but have good Google Fu to have a crack

sour crystal
#

My Issue is that i want to Destroy a player if the health is 0 but it destroys it for 1 Player but for the others it doesn't work :/

shut yarrow
#

@sour crystal there are plenty people here who are experienced with Photon, you should just describe the problem as clear as you can and possibly post some code that you think is the cause. Nobody will be able to pull an answer out of a hat without more background

bright nacelle
#

Does Unity require a license per dedicated/virtual server instance? Playing around with ummorpg and just curious. /thanks 🙂

prime dawn
#

Hey guys. Do you think that the new networking solution in the 2021.1 version of unity can compete with the other ones like PUN and Mirror?

shut yarrow
#

Nobody knows, but best to not wait for Unity to lend a helping hand in networking and just use something that already exists and has good adoption

weak plinth
normal dust
#

Using MLAPI. I'm using .Spawn() for clients but I need each object spawned to call a method, how do I do this?

dry egret
normal dust
#

Well it wont work that way. I have features I'm doing to the object while a player is holding it. When they build it then I need to activate the object so the features go away.

normal dust
#

And using .Spawn() I cannot call a method on the clients to turn off the features

jolly wadi
#

Wait so you need the client active

#

To turn of features

normal dust
#

No my build objects have a method, ActivateBuildObject(). I call this when I build the object.

jolly wadi
#

Yeah

normal dust
#

.Spawn() puts the objects in the scene but I cannot call ActivateBuildObject() with .Spawn()

#

If there is not a way to do it then I'll compromise

#

Just curious if there was a way.

jolly wadi
#

Very confusing lol

normal dust
#

what is confusing?

jolly wadi
#

Idk what do you mean you can’t call activate thingy with .spawn

normal dust
#

Do you know what .Spawn() is?

jolly wadi
#

Yeah

#

It spawns an object in MLAPI?

#

or somin

normal dust
#

Ok, its instantiating same object for clients, right? but the object has a script that I want to call a method

jolly wadi
#

Ok yeah

#

But you can’t call the method

normal dust
#

IDK how to call the method other than Start() function on script but I'd have to do a lot of work to change this up

jolly wadi
#

Well

#

You can use events

#

Like subscribe to the event when you have spawned

#

And call the function

normal dust
#

Here is another example of a problem I'm having. Maybe you can help.

jolly wadi
#

Yeah

normal dust
#

currentBuildObj = Instantiate(bs, buildPos, Quaternion.identity);

jolly wadi
#

Yeah

normal dust
#

for solo I set the currentBuildObj to instantiated Obj.

jolly wadi
#

Yeah

normal dust
#

But trying to do multiplayer now. and I cannot do this anymore

jolly wadi
#

Because..,,

#

Oh I see

normal dust
#

I do ServerRpc to instantiate on server, then .Spawn()

jolly wadi
#

Yeah

#

So what is the problem in doing this in the rpc

#

Instantiating in the rpc

#

Idk

normal dust
#

The player spawning the object needs to know which object he has spawned

jolly wadi
#

Oh

#

Wait sorry Greg

#

I mean

normal dust
#

Client spawns object. ServerRpc then .Spawn(), ok, I get this. But I need the client that spawned it to know which object they spawned.

jolly wadi
#

Gtg

#

I have class

#

Umm you can ping me

normal dust
#

I need each netObj.Spawn() to call a method. Any way to do this ? 😦

[ServerRpc]
    public void InstantiateBuildObjServerRpc(Vector3 desiredPos, int objType)
    {
        NetworkObject netObj = Instantiate(gm.buildLoadObjects[objType], desiredPos, Quaternion.identity).GetComponent<NetworkObject>();
        netObj.Spawn();
    }
jolly wadi
#

netObj.gameObject.tag = “netObj”;

#

Then when you wanna find them

normal dust
#

oh

#

but ill find all of them and not just the 1

jolly wadi
#

GameObject[] = findgameobjectswithtag(“netObj “)

#

You can use an array

#

And findgameobjectsssssssd

#

With an s

#

Will find all of them

normal dust
#

ok makes sense, thank you

jolly wadi
#

Then you can to somin like this

normal dust
#

🙂

jolly wadi
#

Ok

#

🙂

normal dust
#

I also noticed something but its prob bad programming. I noticed the Start function isn't called immediately after the object is Instantiated, so if I wanted to do something in the Start function I can set a bool just after I instantiate it. If this makes sense.

jolly wadi
#

Maybe use on enable

#

Or use awake

normal dust
#

OnEnable does it immediately after instantiated?

jolly wadi
#

Not too sure

#

Probs awake

normal dust
#

Ok 1 more thing buddy if u have a second

#

Its an open world procedural gen world

jolly wadi
#

Ye sure

normal dust
#

I take hosts map seed and generate the same world for clients

jolly wadi
#

Yeah

#

Yeah

normal dust
#

So the dynamic objects and enemies are giving me an error cuz I just instantiate them on clients side, I have to use .Spawn() on server side for thise?

jolly wadi
#

Yeah

#

I would assume so

#

Maybe

#

I have rarely used MLAPI lol

#

I can understand a bit tho

normal dust
#

ok thank you. I have player equipment and custom appearance and login done so far.

#

awe ok

jolly wadi
#

Nice

normal dust
#

working on building and map seed generation

jolly wadi
#

Love to see the project

#

Wait do you know what the cap is on MLAPI?

normal dust
#

umm no

#

but its suppose to be 4 to 6 players only per host.

jolly wadi
#

Ok thanks

normal dust
#

its not an MMO, its more like Valheim

jolly wadi
#

Ye

#

I’m interested in learning different solutions

#

I only know steam photon mirror and a bit of MLAPI

#

So just thinking

#

But thanks

normal dust
#

I think MLAPI only lets me host 1 spot free. Until I add umm, forget what its called to store in the game lobbies

jolly wadi
#

Ok

#

I will look into it good luck on ur game

normal dust
#

cuz i tried making 2 lobbies with just MLAPI and it wasnt working

#

Thank you again

jolly wadi
#

Np

dry egret
#

is MLAPI beginner networking friendly?

weak plinth
weak plinth
#

You can host as many servers /hosts you want with mlapi

#

Just make sure change ip or port

normal dust
#

oh @weak plinth ok. I will look into this! 🙂

#

Any good tutorials on this that also shows you how to config ports on the hosts router?

weak plinth
#

You should be able to setup mlapi in less than 5 minutes

granite yew
#

Ok so I have a role online game and I have a problem. The role assignment works but when u have any role in ur perspective all other players have the same role as you. How can I fix this?


    // Update is called once per frame
    void Update()
    {
       if (PhotonNetwork.playerList.Length == 6)
       {
          if (HasRole == 0f)
          {
              Players = GameObject.FindGameObjectsWithTag ("Player");
              pv.RPC("AssignRole", PhotonTargets.AllBuffered);
          }
       }
    }

    [PunRPC]
    void AssignRole()
    {
        HasRole = 1f;
        Lobby.SetActive(false);
        Bus.SetActive(false);
        forest.SetActive(true);
    
        for (int i = 0; i < Players.Length; i++)
        {
            int rnd = Random.Range(1, 15);
            playerRole = Players[rnd];

            if (rnd == 1)
            {
               BecomeMurderer();
            }

            if (rnd == 2)
            {
              BecomeSheriff();
            }

            if (rnd == 3)
            {
                BecomeDoctor();
            }

            if (rnd == 4)
            {
               BecomeDetective();
            }

            if (rnd >= 5 )
            {
                BecomeInnocent();
            }
            

            Role = rnd;
        }
    }
distant ridge
#

Hey guy, I'm trying to build a multiplayer WebGL game with photon. everything works well in the editor but I can't join room when I host the game or play it locally

#

thank you in advance

granite yew
#

are you calling the OnJoinedRoom function to make it go to the game scene?

distant ridge
#

yes

#

other photon lines are working like for example I attached a photonNetworking.loadlevel method to a button and it worked but not anything in the OnJoinedRoom method

granite yew
#

u have to make the buttons have a JoinRoom function (its a different function to whatever networking system u have)

distant ridge
#

are you saying I should make a button for creating/joining rooms? already done that and I have other method which is OnJoinedRoom() that will excute something after joining the room but it doesn't work

granite yew
#

oh

#

sorry I cant help with that XD

cerulean crescent
#

I'm currently working on a 2d battle royale shooter in MLAPI, and my goal is to squeeze in 64 players per game

#

we'll see how it pans out

spring crane
#

@crude sleet We don't have job or collab posting on the discord server. There's a section on the forum.

astral gull
#

May I ask, so, I have two players on the same server, but (doesn't matter who joins first) the camera follows me on pc, only my actions
What is wrong in my code? I can post other code from file if this code is ok

public Transform followTransform;
    void FixedUpdate()
    {
        if (IsLocalPlayer)
        {
            this.transform.position = new Vector3(followTransform.position.x, followTransform.position.y, this.transform.position.z);
        }
    }
abstract copper
#

thats really the only possible thing that could be wrong here

astral gull
abstract copper
#

okay maybe you need to explain a bit more about your setup

#

this is on the camera, and the camera is in the scene at the start?

#

the players are then spawned in whenever they join?

#

if the players arent spawned in at the start, then how is followTransform actually being set

astral gull
#

the players spawn when they join, its a dedicated server preprealpha

#

I have main camera and player prefab has main camera child

abstract copper
#

ah

#

so there is no camera in the scene at the start, but each player spawns in with their own camera?

astral gull
#

there is a camera at the start

#

but also one camera for each player

abstract copper
#

so there are like, tons of cameras in the scene then?

astral gull
#

2 or 3, later up to 17

abstract copper
#

well there's your problem

#

cameras arent guaranteed to render to the screen in any particular order

#

unless you manually change their render order

#

you should rethink your camera spawning logic

astral gull
#

but I've set the camera to do something only if its IsLocalPlayer..?

abstract copper
#

but you said its a child

astral gull
#

yes

abstract copper
#

so it will already move with the players

#

you dont need to code anything

#

all cameras are already moving with the players

#

so you are just viewing the first camera in the randomly ordered list

#

which could be any one of them

#

what I was going to say though, is that instead of having the camera be a child, you should manually spawn in the camera in Start if you are the local player

#

like

private void Start()
{
  if (IsLocalPlayer)
    Instantiate(cameraPrefab);
}
astral gull
#

wait, why camera prefab? I don't have it, only main camera and children...

abstract copper
#

I know you don't have it, you should make one

#

having 17 cameras in the scene is very not optimal

#

you should only have 1 camera in the scene unless you are specifically using more than 1 to do something

astral gull
#

but I need one camera for each player?

abstract copper
#

that is not how it works

#

the scene hierarchy is not synced on the server

#

you can locally, as a client, spawn in a camera

#

and it will be your camera

#

all players will do this, so they will all have a camera, locally

#

the server does not need a camera since well, it's the server

#

and each client should not have other player's cameras

#

only your own

astral gull
#

should I do something with the main camera? Keep it, trash?

abstract copper
#

you could, yeah

#

since you won't be using it

astral gull
#

but I need something for the menu?

abstract copper
#

Oh, is the menu not in a different scene?

astral gull
#

no

#

it's a prepreprealpha

#

Also I have no idea what are other scenes yet

abstract copper
#

I suppose you could keep it then, and just disable it and spawn in player camera locally when the game starts

astral gull
#

but how do I disable a gameobject? I know how to do that with components only

abstract copper
#

gameObject.SetActive(false);

#

this is a long conversation so I will make a thread

tulip palm
#

Hello I was watching a networking tutorial and he made this script he did not get the error but i dont want to do anything wrong so i came here i have searched online but couldn't really find anything the script is:

if (PV.IsMine)
        {
            Hashtable hash = new Hashtable();
            hash.Add("itemIndex", itemIndex);
            PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
        }

and the error is:
namespace 'player' not found
the error occured at LocalPlayer

river meteor
#

[Photon Pun] - Objects with PhotonView component must be instantiated with PhotonNetwork.Instantiate only ?

abstract copper
#

yes, if it has a PhotonView then the server sees that as a network entity

#

so you must use the photon instantiate to create it, not unity's Instantiate

astral gull
#

What is IsLocalPlayer? Does it check if the file is attached to a player object that is controlled by someone locally or what?

austere yacht
astral gull
#

Okay! 🙂

astral gull
#

May I ask, how do I reference clones from the prefab? Tags and names I think are not an option since there is more than 1 player(clone) name and more than 1 player(clone) with a tag

normal dust
#

How do I make clients collide with .Spawn() objects using MLAPI? My clients are moving through the .Spawn() dynamic objects but my building fort objects are colliding with host and clients... The main difference is the dynamics have rigidbody dynamic with NetworkTransform.

astral gull
#

May I ask, how to make one camera clone follow one player clone and other camera clone follow other player clone? Right now the code is a mess and everything is bad

mint matrix
#

Hey guys what is the best networking sullutions for to make?

When i press host i make a server on my own pc and other poeple can join a way that i dont need a server?

late swallow
#

clients can't send commands

#

I'm spawning in player objects and then they can select a character

#

once they select one, they send a no authority command to the server that creates a player which then gets spawned, giving them authority

#

however, once the player is spawned, the rest of the script doesn't work anymore

#
    public void CmdSelectCharacter(NetworkConnectionToClient conn = null)
    {
        MyNetworkManager.instance.CreatePlayer(selectedCharacter, conn);
        
        Debug.Log("Ara");

        /*characterCards.RemoveAt(remainingCharacters.IndexOf(character));
        remainingCharacters.Remove(character);*/
        
        DestroyAllCards();
    }```
#
    {
        //Creates player prefab
        GameObject playerObject = Instantiate(spawnPrefabs[0]);
        NetworkServer.Spawn(playerObject, conn);

        //Sets player name
        CSteamID steamId = SteamUser.GetSteamID();
        PlayerSteam playerSteam = playerObject.GetComponent<PlayerSteam>();
        playerSteam.SetSteamId(steamId.m_SteamID);
        
        //Sets player character
        Transform playerCharacter = Instantiate(character.CharacterPrefab, playerObject.transform).transform;
        playerCharacter.GetComponent<ChildNetworkIdentity>().parentNetId = playerObject.GetComponent<NetworkIdentity>();
        playerCharacter.GetComponentInParent<PlayerData>().data.characterId = CharacterDatabase.instance.GetCharacterIndex(character);
        NetworkServer.Spawn(playerCharacter.gameObject);

        //Add player to world save
        

        //Adds player to the list of players currently in the game
        if (!gamePlayers.Contains(playerObject.transform))
            gamePlayers.Add(playerObject.transform);
    }```
#

this is the function that creates the player

#

also, I might have to specify this

#

I am using Mirror networking

tender marten
#

Hi, I have a problem with 2 errors. Unity Console still writes:

*1st* ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEngine.UIElements.VisualElement+Hierarchy.get_Item (System.Int32 key) (at <0ec220f696a74948a0877e75f89752cf>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateToIMGUIContainer (UnityEngine.UIElements.VisualElement root, UnityEngine.UIElements.EventBase evt) (at <0ec220f696a74948a0877e75f89752cf>:0)
*2nd* Assets\Prefebs\MainMenu\UI\Rooms\RoomListingsMenu.cs(23,57): error CS1061: 'RoomListing' does not contain a definition for 'RoomInfo' and no accessible extension method 'RoomInfo' accepting a first argument of type 'RoomListing' could be found (are you missing a using directive or an assembly reference?)

and I don't know what to do with it. Would anyone help me? Here is the .cs file:

abstract copper
late swallow
#

I'm already spawning a player in

abstract copper
#

clients dont enter a ready state by default unless you use this function

late swallow
#

I tried using ReplaceClientForConnection

#

but it still doesn't work for the clients

#

I have a script that sits on buttons that let you select the player

#
    {
        CharacterSelect.instance.SelectCharacter(character);
    }```
#
    {
        selectedCharacter = character;
        CmdSelectCharacter();
    }

    [Command(requiresAuthority = false)]
    public void CmdSelectCharacter(NetworkConnectionToClient conn = null)
    {
        Debug.Log("Ara");
        MyNetworkManager.instance.CreatePlayer(selectedCharacter, conn);
        
        Debug.Log("Ara");

        /*characterCards.RemoveAt(remainingCharacters.IndexOf(character));
        remainingCharacters.Remove(character);*/
        
        DestroyAllCards();
    }```
#

and then for clients

#

only the createplayer function gets called

#

and nothing else

#

and they have authority over their own objects

abstract copper
#

you don't get an error?

late swallow
#

but once I send a command

#

it disables the client

#

disconnects them

#

and giving an error

#

like

#

how can I do this

#

once you join the server

#

you get assigned an empty gameobject for the player

#

and then I want players to be able to select a character using some buttons

#

once that's done

#

destroy the cards

#

but it only works for the host

abstract copper
#

there are no scripts on the empty gameobject?

late swallow
#

just network identity

abstract copper
#

because you cant send commands from anywhere but the player object

late swallow
#

oh

#

wait

abstract copper
#

so if you are trying to send commands from UI, it wont work

#

you can, however, send custom network messages without using any commands, and that does not require a player object to exist

#

so you could perhaps send the server a networkmessage that holds the ID of the character they want to select, then it spawns them in with actual authority after the server receives the message

late swallow
#

what about if the card calls a command that sits on the player object?

#

like

#

the character select sits on the player now

mint matrix
#

Hey guys is their a way to get multiplayer without a server but not local like you can play with everyone you want from everywhere

abstract copper
late swallow
#

it does not

#

if it's on the client

#

only the createplayer function will be called

#

and nothing else

#

does the script that calls the other script with the command have to be a networkbehaviour as well?

abstract copper
#

I dont think so, I think you are doing something else incorrectly

#

you are telling me that CreatePlayer is called, but from where?

late swallow
#

uhhhhhhhhhh

#

wait

#

so now

#

if I make the DestroyAllCards a ClientRpc

#

it works

abstract copper
#

if your cards are client-side, then yeah that makes sense

late swallow
#

I see

#

I have inventories tho

#

they're classes that hold a list of items

#

if I wanna add to them

#

how do I do that

abstract copper
#

that kind of stuff is difficult to set up because it all has to be server side pretty much

late swallow
#

yeah

#

but I need it

#

how the hell

abstract copper
#

so basically you need the server to have all the details, then client simply receive only what they need to render and display numbers for, etc... what I mean by this is, the server might have the actual item class stored in the server-side inventory, but then the player might try to equip an item from the inventory, so instead of accessing the inventory directly, it would just send the index it wants to equip to the server. Then, the server uses that index to access the server-side inventory, and sends back some primitive data type that represents the item the user wants to equip

#

for example, it might send back an enum or an integer ID of the item

#

that way the clients can use that ID to lookup whatever it needs to render the item, like perhaps spawning a prefab, or doing whatever

#

It gets complicated trying to do inventories this way, but there isnt really another option

#

TDLR: the server holds all the actual data, and the clients only receive the very minimum data they need to do the rendering / etc

#

since they arent doing any of the actual logic

late swallow
#

but the inventories stay on the players

#

like

#

all the inventory data is saved locally

#

and players load that data once they join the server

#

kinda like terraria profiles

#

or characters

#

however

#

I want picking up and dropping to first go through the server and only then save locally

abstract copper
#

so then you could just send a command to the server that you want to pick up some item, the server could then delete the item from the world, and TargetRPC the player who tried to pick it up and have them locally add it to their inventories

#

that way you wont have weird overlap where two players pick up an item at the same time and it gives it to both of them or anything

#

since its bouncing off the server first

late swallow
#

but like

#

I don't want players to be able to pick up however many items they please

#

or drop them

#

so

#

I wanna have the server

#

verify the data

#

which once I receive the commands

#

I can do

#

and then save it

#

so it'll still be handled by the server

abstract copper
#

it is impossible for the server to do any sort of verification if you have the inventories held locally

#

hence why you can just cheat in terraria no problem

#

if you wanted it to be secure and accurate, it would have to not be local at all

#

whether or not that matters for your game or not is up to you

#

you are already probably using the "client / server" hosting architecture anyway, meaning the host could always just cheat however they want

late swallow
#

yeahhhhhh

#

how could I fix thaaat

abstract copper
#

it is complicated, you need an actual database for your game that is held online

#

like MySQL or something (NoSQL?)

#

not sure what is really standard

#

but that involves being online the whole time

#

this would be something for some kind of MMO

#

then you have to deal with user logins, sessions, and all this other junk just to have the inventories be (mostly) non-cheatable

late swallow
#

well

#

the game can be played offline as well

#

so

#

f

#

I just want the data to be verified before being saved

#

if they change it after

#

then

#

that's that I guess

late swallow
#

@abstract copper

#

how can I make it so the host doesn't have server administration

#

like

#

they can do anything

#

while the clients can't

late swallow
#

also

#

how can I make it so you can't edit other clients' scripts

#

cause, rn I'm just setting them to false on the client

#

so

#

uhh-

fair maple
#

Hello! Is anyone here good with Playfab?

#

I am in need of some assistance

fossil umbra
#

Is the reason why there are no basebuilding/rts mmo

#

because the server would have to process all the logic, which means high cpu costs, doing it client side would mean a vulnerability to cheating?

still hare
#

so yes, the performance costs would just be too high

#

and any MMOs need server-side logic, meaning you couldnt do it client side

swift epoch
#

Just how important is verifying input on the server? I've been dealing with input delay, but if I just take everything at face value it's non-existent
From a networking standpoint, my game is similar to Risk of Rain. No dedicated servers, just 4 Steam friends

mortal horizon
swift epoch
#

Ok cool! That's great to hear, actually

mortal horizon
#

Yeah, client authority is totally acceptable for co-op games

obsidian remnant
#

guys so im making a multiplayer using mlapi

#

and i have an arrow that shows where each your player is aiming at

#

oh wait

#

wrong png

swift epoch
#

Ah yes.

mortal horizon
#

looks like a good day

swift epoch
#

An arrow.

obsidian remnant
#

the one on the left is the actual user

#

and i dont want the arrow on the right to be appearing

#

i just want the player to see where he is aiming

#

here is abit more clear explenation

#

i just want for each player to see their own arrows

#

not other player's arrows

#

do u guys get it?

#

please anyone?

#

do i just if(!isLocalPlayer) arrow.SetActive(false)? will that work?

#

i dont know anything about multiplayer but that sounds the most logical way

#

IT WORKS

fossil umbra
hardy citrus
#

I have pun2 and using pun cloud, how do i convert it to player hosted servers, what is The most common way,

thorny gale
#

MLAPI vs Dark Rift 2 which one shall I choose

#

???

indigo thicket
#

Hello! I'm using MLAPI. I'm adding many items in my game, every item has its script with the override function "Use()" of his master class Item. Every item has a prefab, and must be spawned in the game. Since the "use" function calls some server RPCs, and most of the items are animated and thus need a networkanimator component, I'm forced to place every item prefab in the NetworkManager prefab list, right? Isn't there any other way of spawning it? I would spawn every item prefab in local, but then the item could not call the rpcs and/or use the networkanimator...

#

Placing hundreds of prefabs in the networkmanager seems pretty messy

#

(the items would be placed with all the prefabs of enemies, players etc.)

still hare
#

So, you would just make a ScriptableObject with various lists / arrays of GameObjects, each list / array named after a specific thing. Perhaps weaponPrefabs, enemyPrefabs, etc

#

then you would iterate through all the lists / arrays, and add a new NetworkPrefab for each of those prefabs

#

That should solve the organization problem when it comes to adding all the prefabs

#

You would have to test if this works because—after looking into it further, it seems they do some hash validation of the prefabs in the NetworkManager... I am unsure if what I sent would be all you need to do, but maybe it is. I would try it and see

gloomy sand
#

is there any work being done on QUIC support for unity for now, unity preview or opensource

prime salmon
#

I'm confused regarding the difference between "IsLocalPlayer" and "IsOwner", I would expect my local player to always be its own owner? But maybe this is not the case?

opaque dew
#

Don't use LTS? Where do you see that?

#

No problem then?

#

If you are making a board game however you might be more interested in PUN. It has room functionality built in.

prime salmon
#

I'm getting these kind of warnings:

#

How do I destroy something on the server side without my clients nagging about it?

#

this happens when I join the server (with a client) AFTER an object has been destroyed on the server side

opaque dew
#

I'm not certain, I use a lesser known networking solution. I'm not familiar with troubleshooting others.

#

Okay. I'd advise using LTS but if some reason you absolutely cannot, good news, there are plenty others that work without LTS. Bad news, none of them are officially released yet.

spring crane
#

Mirror recommends it, but it will probably work. Sometimes there are Unity bugs that affect Mirror.

opaque dew
#

I don't use Mirror. I'm on FishNet and quite happy with it.

spring crane
#

Not recently, but yes. I'm currently playing with Mirage on non LTS, which is quite similar to Mirror.

opaque dew
#

Sorry, that was to Danny. Read it wrong.

spring crane
#

Hard to say. I like Mirage due to it's much better architecture regarding singletons and statics

#

and better separation between features of the networking solution, in case I want to swap things out

#

I didn't say that it has better support, just that it has already done a lot of nice things to the Mirror codebase that I value 😛

opaque dew
#

PUN. They have free CCU and you do not have to deal with having a server. I know you said you are considering that for later but it sounds like PUN would be ideal for your requirements.

spring crane
#

It does look like James has taken solid ownership of Mirage, so updates to code are frequent. Few others are contributing regularly as well.

#

Worth noting that running a server generally requires port forwarding. To avoid that issue, you would need a relay server.

jolly wadi
#

No

#

U should try fusion

#

it is pretty good

#

very diverse

opaque dew
#

I was going to suggest Fusion but I wasn't sure of it's current state. I was looking this very moment.

spring crane
#

Photon Fusion

jolly wadi
#

yeah lol

opaque dew
jolly wadi
#

Also join the photon server

#

they will certainly help you with fusion

#

there are also constant updates

#

And they have recently added matchmaking

spring crane
#

Oh dang the landing page is throwing shade at other networking solutions 😄

jolly wadi
#

Wdym?

#

sorry

#

bad word

#

what do you mean?

opaque dew
#

I have not used MLAPI yet but I am familiar with Mirror's pitfalls, they are very real.

spring crane
#

Graphs on the page

jolly wadi
#

Oh

#

it is in developement

#

but has good potential

opaque dew
#

A little bit down they are comparing benchmarks.

jolly wadi
#

Sorry what do you mean by that

spring crane
jolly wadi
#

oh thats a bit weird