#archived-networking

1 messages ยท Page 4 of 1

forest chasm
#

got this now

olive vessel
#

Well if you make any changes in the editor, you must make a new build to test

forest chasm
#

i close the run everytime

olive vessel
#

And rebuild it?

forest chasm
#

yes

olive vessel
#

Well you seem to have differences in NetworkConfig

forest chasm
#

anyidea where i might find that

#

ive done alot of mindless following and im not sure where exactly everything is at perfectly

olive vessel
#

I assume the NetworkManager

forest chasm
#

its in there but its also 2000 plus lines

#

pre made from unity

olive vessel
#

Not the code...

#

The component NetworkManager

forest chasm
#

nothing in there for config

#

im looking tho

olive vessel
#

Well I don't have Netcode installed, so you're gonna ahve to show the NetworkManager component

forest chasm
olive vessel
#

I would rebuild the client and try again

#

NetworkConfig is things like that connection approval, and spawning stuff

forest chasm
#

rebuild client?

olive vessel
#

Well you've made a build, so I assume you know how to make another build

forest chasm
#

ah like. start all over lol

#

do you think burst option could be an issue?

olive vessel
#

Probably not

forest chasm
#

idk i just googled thee warning i got a that was a solution

#

you happen to know where it is so i can try it?

olive vessel
#

Along the top I think

forest chasm
#

top?

#

found it

olive vessel
#

Top of the window

forest chasm
#

calling it a night thanks for all the help really!

weak plinth
#

Has anyone used quantum v2 photon for multiplayer on unity? Whats their opinion on it. I was thinking of making my own game server, but it seems this quantum stuff has some much done already.

#

The documentation looks horrid though.

vagrant garden
#

What do you not like about the docs?

weak plinth
#

Some of the stuff i just cant understand. .e.g. making a custom authenticator it tells me how to impl a interface but it dont explain anything around how the interface methods are called

#

Good documentation in my eyes is something i understand without reading it multiple times

#

Maybe im just looking at the wrong thing?

vagrant garden
#

No You're looking at the right page but you should start with the intro stuff (Quantum 100). Custom authenticators will make more sense once you actually need them they are a bit more advanced.

weak plinth
somber sable
#
    // PLAYER SCRIPT
    [ServerRpc]
    void SendMsgServerRpc()
    {
        MyNetworkManager.SingleTon.ServerAuthTestClientRpc(" ; hi", OwnerClientId);
    }
    
    // NETWORKMANAGER SCRIPT    
    [ClientRpc]
    public void ServerAuthTestClientRpc(string message, ulong clientId)
    {
        Debug.Log("Player: " + clientId + message);
    }

Unity Netcode for gameobjects:
is there something wrong with this? When I call it from the client, the code is only ran on the server. Im trying to make it run on all clients. The idea is that the client wants to tell the server to run the code on all the clients

forest chasm
#

okay im stuck... ive been trying to research work around that my brain can understand and i cant, i have a client host and a client on a build/run, TWO PROBLEMS,
1! when i imput on one of the two instances BOTH prefabs move, so the client controls itself AND the host (and vice versa)
2! im still glad im able to even get connection BUT, when im moving aorund in one window as client the clients movement is not synced to the host and also vice versa

gusty fjord
forest chasm
#
using UnityEngine;
using Unity.Netcode;

public class movement : NetworkBehaviour
{
        public CharacterController controller;

        public float speed = 5f;
        public float gravity = -32f;
        public float jumpHeight = 2f;

        public Transform groundCheck;
        public float groundDistance = 0.4f;
        public LayerMask groundMask;

        Vector3 velocity;
        bool isGrounded;

        public GameObject PlayerCanvasObject;
       
        
    
        
        

      void Start()
        {
            if (IsLocalPlayer)
            {
                PlayerCanvasObject.SetActive(true);
            }
           
        }
    // Update is called once per frame
    void Update()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if(isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }
      float x = Input.GetAxis("Horizontal");
      float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

        if(Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }
        
        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }
}
somber sable
somber sable
gusty fjord
forest chasm
somber sable
#

see if that works

forest chasm
#

trying nowe

somber sable
#

OnClientConnectedCallback is the Action derived from NetworkManager component

forest chasm
somber sable
#

share ur Update() method now

forest chasm
#
void Update()
    {
        if (IsOwner) return;
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if(isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }
      float x = Input.GetAxis("Horizontal");
      float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

        if(Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }
        
        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }
}
somber sable
#

you forgot the ! before IsOwner

forest chasm
#

aww ๐Ÿ˜ฆ

somber sable
#

so basically, !IsOwner is gonna check if we dont own the network object, then dont run the code below

#

but since you will own the object, it will run the code for YOUR object, not the other

forest chasm
#

okay neat i was running a if (!IsOwner) destroy line before.. it worked but it threw errors in game

somber sable
#

what are the errors

forest chasm
#

i dont get them anymore since i took that line out ive been looking for something different which you guys just gave me

#

ill find what it was hold up

somber sable
#

just go ahead and run the code and see if it works now

forest chasm
#

Netcode Behaviour index was out of bounds. Did you mess up the order of your NetworkBehaviours? Unity Netcode for GameObjects

#

this is what it was

#

THAT WORKED !

#

all i need now is for the movement to transfer to the host

somber sable
#

wdym

forest chasm
#

so if i have both "games" open right client and hos
if i tab in the clients game and mmove around, the movement doesnt show on the hosts screen and vice versa

somber sable
#

add a networktransform component to the prefab

forest chasm
#

doesnt work, it ruins my camera, i wrote a code instead

#

getting code now

somber sable
forest chasm
#

so everytime i use the transform component, whoever the client is CANNOT look left or right anymore, and it also doesnt even sync the movement anyways

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

public class PlayerNetwork : NetworkBehaviour
{
    private NetworkVariable<Vector3> _netPos = new(writePerm: NetworkVariableWritePermission.Owner);
    private NetworkVariable<Quaternion> _netRot = new(writePerm: NetworkVariableWritePermission.Owner);


    // Update is called once per frame
    void Update()
    {
        if (IsOwner)
        {
            _netPos.Value = transform.position;
            _netRot.Value = transform.rotation;
        }
        else {
            transform.position = _netPos.Value;
            transform.rotation = _netRot.Value;
        }
}
}
#

this is my replacement code

somber sable
#

well if u want a ClientAuth fix, add this instead

using Unity.Netcode.Components;
using UnityEngine;

namespace Unity.Multiplayer.Samples.Utilities.ClientAuthority
{
    /// <summary>
    /// Used for syncing a transform with client side changes. This includes host. Pure server as owner isn't supported by this. Please use NetworkTransform
    /// for transforms that'll always be owned by the server.
    /// </summary>
    [DisallowMultipleComponent]
    public class ClientNetworkTransform : NetworkTransform
    {
        /// <summary>
        /// Used to determine who can write to this transform. Owner client only.
        /// This imposes state to the server. This is putting trust on your clients. Make sure no security-sensitive features use this transform.
        /// </summary>
        protected override bool OnIsServerAuthoritative()
        {
            return false;
        }
    }
}
forest chasm
#

so replace that with what i sent?

somber sable
#

yeah, see if that works

forest chasm
#

one sec

gusty fjord
#

Your server is your host, yes?

somber sable
#

yes

#

i actually may have mislead you. the clientRpc is only running the code on the host client and not on any other, when of course called from another client

forest chasm
#

i ran into a problem trying to replcae the script

#

i cant override anything

gusty fjord
uncut bluff
#

hey guys when a clien spawns I get this message
[Netcode] Behaviour index was out of bounds. Did you mess up the order of your NetworkBehaviours?
Any sugestion?

forest chasm
#

the scripts are gone they arent here no more i deleted them i still cant override

somber sable
somber sable
#

ive never ran into that situation before

forest chasm
somber sable
forest chasm
#

he is getting the same error i was earlier with that coded

uncut bluff
#
 if (!IsOwner) Destroy(PlayerController);    ```
forest chasm
#

thats the one

#

use this

#
if(!IsOwner) return;
uncut bluff
#

humm ok

forest chasm
#

at the very top of void update

uncut bluff
#

why cant I destroy the script?

forest chasm
#

i have no clue

somber sable
forest chasm
#

THATS what i was doing

somber sable
#

hmm

forest chasm
#

that yeilds the same error

somber sable
#

there may be a network destroy function within netcode. try find something like that

uncut bluff
#

maybe its because I am destryong the same script in two diferent places

#

gona check

#

nop still the same

forest chasm
#

help me with this dumb script warning ๐Ÿ˜ฆ

somber sable
forest chasm
#

try if (!IsOwner) return;

uncut bluff
olive vessel
#

I will say, there is a Discord specifically for Netcode for GameObjects pinned here if you want, they may have better answers

uncut bluff
olive vessel
#

The people working on NGO are somewhat active in there too which is a help

forest chasm
#

I GOT ITTTTT

forest chasm
somber sable
#

why is your player network script derived off of network transform?

#

dont do that

#

well, you dont need to do that. It will just makes things more confusing

forest chasm
#

i just put in the script you gave me

#

currently googling answering to see if anyone has a fix

somber sable
#

open up the script and send me a ss

forest chasm
uncut bluff
#

unity network animator and animator need to be in same gameobject?

forest chasm
#

animator and a animator control script worked for me

uncut bluff
#

what do you mean?

forest chasm
tidal moat
#

This channel is only for netcode cause I use Photon?

olive vessel
forest chasm
#

is there anyone who can help me with player networking, ive tried many different things but i cant get anything to work and sync my players

wide solstice
#

hello, im making a fps game with netcode and when i instantiate the player prefab it doesnt sync over the network

forest chasm
#

trying to use the network animator with my animator for my prefab and i get this when running client and host

civic flicker
#
RPC method 'OnFire' found on object with PhotonView 1001 but has wrong parameters. Implement as 'OnFire()'. PhotonMessageInfo is optional as final parameter.Return type must be void or IEnumerator (if you enable RunRpcCoroutines).
#
[PunRPC]
    void OnFire(InputValue value)
    {
        if (view.IsMine)
        {
            animator.SetTrigger("isAttacking");
        }
    }

void Update()
    {
        view.RPC("StaminaRegen", RpcTarget.All);
        view.RPC("OnFire", RpcTarget.All);
    }
#

hello, im trying to synchronize the attack movement throughout all my plaers

#

but its giving me that error

#

what could be the problem here?

spring crane
civic flicker
#

i just dont understand the "Implement as 'OnFire()' part

spring crane
#

That is probably what PUN actually sent once it ignored all the unsupported types, hence the tip.

civic flicker
spring crane
#

That is what I was referring to

civic flicker
#

ohh i see

weak plinth
#

if networkManager can control only one player prefab, how do we control other surrounding objects?

#

for Mirror

weak plinth
#

nvm i got my answer

little sorrel
#

When I try and use this script the camera is on the other player. I looked in the inspector and player is set to the right player.

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

public class MoveCamera : MonoBehaviourPunCallbacks
{
    public PhotonView pv;
    public GameObject player;

    void Update()
    {
        // forEach()
        if(pv.IsMine){
            Camera.main.transform.position = new Vector3(player.transform.position.x, player.transform.position.y, Camera.main.transform.position.z);
        }

    }
}
forest chasm
#

anyone know a work around to get the animations of a player prefab to sync

indigo sigil
#

Hi. I am using mirror and trying create player with unique name. But NetworkManager gets name form server. What should I change?

public class NetworkRoomManagerNames : NetworkRoomManager
{
    [SerializeField] private InRoomName inRoomPlayerName;
        
    public override GameObject OnRoomServerCreateGamePlayer(NetworkConnectionToClient conn, GameObject roomPlayer)
    {
        var gamePlayer = Instantiate(playerPrefab);
        gamePlayer.GetComponent<PlayerName>().playerName = inRoomPlayerName.Name;
        return gamePlayer;
    }
}
public class InRoomName : NetworkBehaviour
{
    public string Name { get; private set; }
    public void GenerateName()
    {
        Name = Guid.NewGuid().ToString();
    }
}
public class PlayerName : NetworkBehaviour
{
    [SyncVar] public string playerName;
}
opaque ember
#

how do I get my own ID in photon?

#

or anyones ID

#

@here

wide girder
stiff ridge
snow summit
#

Hello, I would do a small proiect: create a card game with a server and 2 client where they can enter and play. Which technology can I use between Mirror and Netcode?

olive vessel
swift lynx
#

Hi there, one newbie question, it's safe to use port 7777 as default? Or what's the best practice regarding ports? thx!

olive vessel
glad lantern
#

not sure what api you are using, most for the most part if you start listening on a unassigned port so port 0, the OS will assign a free port for you

swift lynx
#

just sending messages through the unity transport component, so we need the IP / port

civic flicker
#

i'd check the list just to make sure

civic flicker
#

i guess that makes more sense too

rustic sapphire
#

hello, I am having problems with the new netcode for game object thing, tbh I haven't ever written any multiplayer games ever, I've been strictly working on singleplayer games
so this might sound elementary

#

I am having problems with assigning cameras to each player

#

I can't get each instance of the game to only use that camera, and that camera only

#

it always grabs the newest camera in the scene

#

I tried making the cameras offline (they don't have network objects) but they still exist in the hierarchy of both

olive vessel
#

Put the camera on the player prefab, then check if this is the local player, if not disable the camera

rustic sapphire
#

does disabling the camera on one side, not disable it on the other?

olive vessel
#

No, not unless you make it that way

rustic sapphire
#

still doesn't work

olive vessel
#

Define doesn't work, because I've done it and it has worked

rustic sapphire
#

doesn't work meaning it still grabs the latest created camera

olive vessel
#

Latest created being the newest player?

rustic sapphire
#

yes

olive vessel
#

So the newest player that isn't the local player should disable their camera on our client

#

Have a component on the player object that checks if this is the local player, if it is not, disable the camera

rustic sapphire
#

ok

olive vessel
#

By grabbing the camera, I assume you mean the viewport switches to it

rustic sapphire
#

yes

olive vessel
#

Right then this ought to work

rustic sapphire
#

like this cs private void OnConnectedToServer() { if (!IsLocalPlayer) GetComponentInChildren<Camera>().enabled = false; }

olive vessel
#

If this is on the player, and the camera is a child, yes

rustic sapphire
#

still doesn't work

olive vessel
#

Is OnConnectedToServer actually called?

#

Surely it should be an override or something, I don't think it's called

#

What Networking solution is this?

rustic sapphire
#

netcode for gameobjects

olive vessel
#

Right well my guess is OnConnectedToServer is not called

rustic sapphire
#

let me see

olive vessel
#

Is it asking you to override it?

rustic sapphire
#

no

olive vessel
#

I don't even think it exists in Netcode

rustic sapphire
#

there is OnNetworkSpawn

olive vessel
#

Ok, so use that then

#

The method has to actually be called to do something

#

You will have to override that method

rustic sapphire
#

that did it

#

thank you

#

I realize that with the new netcode library there's not going to be much help, as much as Mirror or UNet

#

UNet is about to be deprecated

olive vessel
#

UNet is deprecated, Netcode has docs

rustic sapphire
#

should I switch to mirror now, before getting any major work done

olive vessel
#

Well would switching to Mirror benefit you? What is Netcode lacking that Mirror brings?

rustic sapphire
#

help

#

the netcode docs are a bit lacking tbh

olive vessel
#

Well it depends on how far you've got and if you want to switch now

#

They're not too different, I personally like Mirror more but that's because I've used it more

rustic sapphire
#

well I am making a multiplayer shooter, as my graduation project

#

you obviously know how concrete it is?

#

I'm afraid of lunging into netcode, and being later surprised that its immature

olive vessel
#

I was gonna make a multiplayer project for mine, ended up swapping ideas

#

Mirror has a good community too, so maybe it'd be best to use it instead

rustic sapphire
#

I'll give it a go

#

I haven't spent much time with netcode either way

#

only started yesterday

olive vessel
#

Ah well, you'll have forgotten it by Friday

rustic sapphire
#

well I hope it goes well, I have about until next june

#

and I haven't even started on a proper character controller

tribal silo
#

Hi, is it a good idea to use Rpc's just to send input/ state data?

rustic sapphire
#

I assume this is game critical input

#

and as I understand it RPC client or server has to go and come back

#

might introduce some kind of latency

tribal silo
#

oh I didn't know it had to be returned but now that I think about it makes sense ๐Ÿ˜ฎ thanks I guess I'll look into custom messages then

rustic sapphire
#

if it must be broadcasted to other objects, you can probably do it localy first, then broadcast ot

uneven mural
#

I'm trying to make a 1vs4 game. I did this by assigning everyone a number when they enter lobby (everytime they leave or re-enter the lobby they give back the number and it's switched again). I thought this would be an easy way to differentiate between players (different characters, abilities, items,...). I'm starting to get a few problems now tho. My first problem is not knowing how I can put multiple character models with all their own animations and skills on the different numbers. Via a tutorial I made one PlayerObject asset which owns the player mesh, the player controller script, etc. I was thinking that maybe an array of character models would fix that? I'm not sure.

#

Second and maybe the most easiest problem...

#

I already threw in one standard character mesh, for when the player is one of the four normal players. I animated it to. Now the problem is that this mesh already appears inside the lobby with animation, but then also appears inside the game without animation

#

like this

bold forge
#

Hey, does anyone know of any good resources to implement a dedicated server client? Can unity build the game client and a dedicated server client from the same project?

little sorrel
little sorrel
dusky storm
dusky storm
dusky storm
#

however, some libs allocate strings or use reflection for rpc calls, which would be more expensive.

opaque ember
urban pendant
#

I have problem with RoomOptions in Photon. I want to set CleanupCacheOnLeave to false. I don't really understand how to do it and how to work with RoomOptions at all. So when i tried to make them there a error that this thing doesn't even exist. Why this is happening?

wide girder
# opaque ember wdym docs?

Docs, documentation, manual. You know, the thing that people read to learn/troubleshoot an engine/library/api...

wide girder
urban pendant
wide girder
urban pendant
#

nah

wide girder
summer anchor
#

So i spawn a damage pop up on the server, how can i then make it face each player locally? i know the rotation part, just unsure how to do it locally to each player

urban pendant
wide girder
# urban pendant ?

Is your ide configured properly? It should suggest you the correct namespace if it is.

wide girder
summer anchor
wide girder
summer anchor
#
 //Enemy spawns damage pop up
    [Server]
    public void ServerShowDamage()
    {
        GameObject damageTextSpawn = Instantiate(damageTextPrefab, transform.position, Quaternion.identity);
        damageTextSpawn.GetComponent<TMP_Text>().text = enemyHealth.ToString();
        NetworkServer.Spawn(damageTextSpawn);
        RpcRotateDamageText(damageTextSpawn);
    }

    //place this on the player to run
    [ClientRpc]
    public void RpcRotateDamageText(GameObject damageTextSpawn)
    {
        if (isLocalPlayer)
        {
            //get the damage text spawn gameobject, and rotate it to current player
        }
}

something like that? and once ive checked if local player, i could just do transform.rotation and that would refer to the current players gameobject, then to move the damage text i would use damageTextSpawn reference?

wide girder
summer anchor
#

its on the enemy, but i probably can try put it on the player

fervent root
#

Do you guys have any idea how to fix this one issue?
I already fixed one issue but there is a little more.
It would be awesome if you guys could help out straight away:

wide girder
fervent root
wide girder
#

It's not the same as in the video.

fervent root
#

I change the stuff a little because my layout style is different

wide girder
#

Compare character by character if you have to. It's not just the layout. It's a totally wrong syntax.

fervent root
#

F

#

xD

#

Well we learn by out mistakes thanks โค๏ธ ๐Ÿ˜‚

wide girder
#

It would be even better if you analyze the mistake and learn the proper syntax. Or figure out what led to the misunderstanding.

fervent root
tulip ledge
#

I'm having trouble getting around a issue and I'm not sure how to fix it.


        private void OnTick()
        {
            if (IsOwner && IsClient)
            {
                Debug.Log("CAN SERVER EXECUTE THIS ? " + IsServer);
            }
        }```

I have the following code on a player, if the editor is playing as the host this will still run.
Although this is not what I want. I want this code to only run for the client of the host.

But I guess that is not possible to do so? I think the script is only run once if your are the host/client
#

This is in netcode btw

austere yacht
tulip ledge
#

        private void OnTick()
        {
            if (IsOwner && IsClient)
            {
                var bufferIndex = NetworkManager.Singleton.NetworkTickSystem.LocalTime.Tick % BufferSize;
                var userInput = GetUserInput();

                clientInputBuffer[bufferIndex] = userInput;
                clientStateBuffer[bufferIndex] = ProcessMovement(userInput);
                
                SendInputToServerRPC(userInput);
            }

            if (IsServer)
            {
                while (inputQueue.Count > 0)
                {
                    var userInput = inputQueue.Dequeue();
                    var bufferIndex = userInput.Tick % BufferSize;

                    if (!IsLocalPlayer)
                    {
                        StatePayload statePayload = ProcessMovement(userInput);

                        if (bufferIndex != -1)
                        {
                            UpdateStateClientRPC(statePayload);
                        }
                        
                        return;
                    }

                    if (bufferIndex != -1)
                    {
                        UpdateInputOnClientRPC(userInput);
                    }
                }
            }
        }
        
        [ServerRpc]
        private void SendInputToServerRPC(InputPayload payload)
        {
            inputQueue.Enqueue(payload);
        }

        [ClientRpc]
        private void UpdateStateClientRPC(StatePayload statePayload)
        {
            if (IsOwner)
            {
                latestServerState = statePayload; 
            }
        }

        [ClientRpc]
        private void UpdateInputOnClientRPC(InputPayload payload)
        {
            if (IsOwner || IsHost || IsServer)
                return;

            ProcessMovement(payload);
        }```
#

Got it like this now and working

mighty moss
#

Hey guys, i'm just trying out Networking for GameObjects, and i got done with basic player movement syncing.

I'm currently trying to make the clients be able to find and connect to a host without the host needing to port forward.
I tried researching online and i found a few posts about NAT-Punchtrough, but i didn't find any actual explanations or code examples on how it should be done
Can someone please help me understand it/point me in the right direction? Thanks in advance

austere yacht
#

The easy answer is to use a relay server. The other options require your clients to configure their firewalls and routers such that a request from the public internet on a certain port gets directed to the right machine on the private network or using a server to moderate the connection setup. maybe this helps https://bford.info/pub/net/p2pnat/

fervent root
#

This might be a advanced question but how would we make a button not show for a client but only to the host?
Or to a specific client?

#

its very very hard to research lol

mighty moss
civic flicker
#
[PunRPC]
    void StaminaRegen()
    {
        staminaRegenTime += 1 * Time.deltaTime;

        if (staminaRegenTime >= 5f && canDash)
        {
            staminaRegenTime = 0f;
        }

        if (staminaRegenTime >= 5f)
        {
            stamina.value = stamina.value += 0.1f;
        }
    }

hello, im using photon and my stamina doesnt seem to be syncing at all

#

each player has its own health + stamina UI (both sliders)

spring crane
civic flicker
#

basically only send data if the value changes?

spring crane
#

and without tying the send rate to frame rate.

civic flicker
#

i'll give it a look

#

thanks again!

spring crane
#

Stuff like this will result in overcharge fees ๐Ÿ˜„

civic flicker
#

oh. xD

#

i really gotta learn more about this

fervent root
#

Where do we look for if we want to develop register and login menu for netcode game objects or netcode itself?
So data from players can be save.

fervent root
#

alright didnt know where to ask thank you

olive vessel
#

Actually they appear to have not linked anything about it in the channel

fervent root
#

0/

olive vessel
little sorrel
#

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

public class MoveCamera : MonoBehaviourPunCallbacks
{
public PhotonView pv;
public GameObject player;
public GameObject cam;
public Vector3 CamPos;

private void Awake() {
    cam = gameObject;   
}
void Update()
{
    // forEach()
    if(pv.IsMine){
        CamPos = new Vector3(player.transform.position.x, player.transform.position.y, Camera.main.transform.position.z);
        Debug.Log(cam + "teleported to" + player + "with PhotonView" + pv);
        Debug.Log(cam + "and" + CamPos);
        cam.transform.position = CamPos;

    }

}

}

little sorrel
#

please help

#

I've been stuck for 5 days

#

and my teacher is going to give me an z-

woven kiln
#

Is it possible to remove data from scriptable objects for server build?

#

if i do use #if then it breaks the client

bright mauve
wide girder
civic flicker
#

just add an else statement

wild wedge
#

Any idea how to attempt reconnection based on FusionBR? Outcome should be: do not destroy player Agent for others when someone disconnects, and reinitialize existing object to reconnecting player.
First goal is achived but second one is more complex ๐Ÿ˜ฆ

severe fable
#

what's the best way to find a network object by ID? Is this fine? ```cs
foreach (var networkObject in FindObjectsOfType<NetworkObject>())
{
if (networkObject.NetworkObjectId == nID)
{
// FOUND IT
}
}

austere yacht
spring crane
fervent root
#

@olive vessel I couldnt dm you but login and register menu is very hard to do then networking itself xD

olive vessel
fervent root
#

networking is alright but menu sucks xD

#

but I wont give up ofc

olive vessel
#

I quite liked PlayFab too for that kind of thing

#

I only suggested UGS because it's Unity's new solution

fervent root
#

I saw something about playfab when I was deep researching

uncut bluff
#

hey guys is there a "Network Transform Child" component? I can't seem to find it

#

?

spring crane
uncut bluff
#

yes

#

how should I approach this then? I need to sync a child transform position in the server

spring crane
uncut bluff
#

๐Ÿคท

#

ok I eneded up just sendind the transform position by NetworkSerialize

mild owl
#

Hey can somebody help with the new unity network. I try to let the player move but somehow only the host can move and not the client. What do i make wrong with the input system?

public class PlayerNetwork : NetworkBehaviour
{
    [SerializeField]
    private InputActionAsset inputActions;

    [Header("Movement")]
    [SerializeField]
    private float movementSpeed = 3;

    private PlayerCameraManager playerCameraManager;

    private NetworkVariable<Vector3> newtorkMovementDirection = new NetworkVariable<Vector3>(default, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Owner);
    private NetworkVariable<NetworkPlayerData> networkData = new NetworkVariable<NetworkPlayerData>(
        new NetworkPlayerData
        {
            currentHealth = 100,
            maxHealth = 100
        }, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Owner);

    public override void OnNetworkSpawn()
    {
        SubscribeInput();
        base.OnNetworkSpawn();
    }

    void Update()
    {
        if (!IsOwner) return;

        ApplyMovementServerRpc();
    }

    private void SubscribeInput()
    {
        if (!IsOwner)
        {
            return;
        }

        var map = inputActions.FindActionMap("Player");

        map.FindAction("Move").performed += PlayerNetwork_performed;
        map.FindAction("Move").canceled += PlayerNetwork_performed;
    }

    private void PlayerNetwork_performed(InputAction.CallbackContext obj)
    {
        if (!IsOwner)
        {
            return;
        }

        newtorkMovementDirection.Value = new Vector3(
            obj.ReadValue<Vector2>().x, 
            newtorkMovementDirection.Value.y, 
            obj.ReadValue<Vector2>().y);
    }

    [ServerRpc]
    private void ApplyMovementServerRpc()
    {
        transform.position += newtorkMovementDirection.Value * movementSpeed * Time.deltaTime;
    } 
}
uncut bluff
#

hey guys In client two weapons spawn instead of just one

         if (!IsOwner)return; 

         print("equiping");
            RequestEquipServerRpc();
     }

     [ServerRpc]
     public void RequestEquipServerRpc(){
         
         EquipWeaponClientRpc();     
    }


    [ClientRpc]    
    public void EquipWeaponClientRpc(){
         
        
        Destroy(SpawnedWeapon);
        
       SpawnedWeapon=Instantiate(
            weapon,
            weaponPotision.position,
            weapons.transform.rotation
            );
       SpawnedWeapon.GetComponent<NetworkObject>().Spawn(true);
      
    }

spawning in host side only one weapon spawn correctly, meaning host and client can see the player spawing the weapon,
but if client spawns, it double spawns on its side

#

I am getting this message NotServerException: Only server can spawn NetworkObjects
So I guess the code is trying to spawn for it self and another that is comming from the server

mild owl
uncut bluff
#

sorry I am retarded I dont get it

#

what do you mean?

uncut bluff
#

well I fixed by manking the weapons not an network object

mild owl
#

Does the new Input system work with the new Netcode?

bold forge
#

I would like to have a board game thatโ€™s hosted centrally, and have users sign into the server, and have the server host multiple games simultaneously. Iโ€™m extremely confused on where to even begin. Mirror seemed promising but everything is geared towards client hosted server.

austere yacht
spring crane
bold forge
spring crane
bold forge
spring crane
bold forge
#

Got it, I tried to find a mirror discord but didn't find anything on google. Do you know how I can find it?

spring crane
bold forge
tribal silo
#

When I copy paste the example code at: https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/fastbufferwriter-fastbufferreader/index.html and use it with a writer with buffer size 1100 it always throws the exception "Not enough space in the buffer"

#

What size should the buffer be? also is the size in bytes? The API documentation just says "Size of the buffer to create"

snow summit
#

Hi! I'm studying Netcode and I can't find nothing about to setup "tag" for both client and server. Anyone can redirect me how to sync tags ?

chrome vessel
#

Hey everyone, currently I am developing an application where on every start it checks for new images or changed values/settings. Basically I want to synchronise my application with some settings made in a backend on a website! Has anyone an idea how I can achieve that. No experience with Networking Problems like that! Thanks in advance

austere yacht
#

If you need the concept of tags in your architecture just make a tag component that derives from NetworkBehaviour and store the tag value itself in a network variable

snow summit
wispy basin
#

hello

#

how i can use bluetooth multiplayer android platform please

austere yacht
wispy basin
#

please help

snow summit
mild owl
#

Can somebody helps - all the time my client is not a owner from itself. How can i fix it?

uncut bluff
#

hey guys help me out, I have two player shooting each other and I got this code to call for the health

 public void Damage(int _damage){
        
        OnDamageRequestServerRpc(_damage);
        print("damage "+_damage);
    }

    

    [ServerRpc()]
    public void OnDamageRequestServerRpc(int _damage){
        OnDamageRecieveClientRpc(_damage);
    }

    [ClientRpc]
    public void OnDamageRecieveClientRpc(int _damage){
       
       
        CurrentHealth-=_damage;

        if(CurrentHealth<=0){
            GameOver();
        
    }


#

I call public void Damage with an raycast that detects the interface that uses that method

#

of the player in specific that was targeted

#

my problem is, when some one calls OnDamageRequestServerRpc I get an "Only the owner can invoke a ServerRpc that requires ownership!"

#

I already used a system like to spawn objects and it works, but for this case it does not

#

void equipWeapon(){
         if (!IsOwner)return; 
        RequestEquipServerRpc(weaponDefenition.name);
     }

    [ServerRpc]
    public void RequestEquipServerRpc(string WeaponName){
         
        EquipWeaponClientRpc(weaponDefenition.name);     
    }    

    [ClientRpc]    
    public void EquipWeaponClientRpc(string weaponName){       
    
      
       SpawnedWeapon=Instantiate(
            CurrentWeaponEquiped.WeaponPrefab,
            weaponPivotPoint.position,
            weaponPivotPoint.transform.rotation
            );
      
       
    }

#

this last one works, so I guess its the same aproach, why does the first one does not?

#

ok I changed it to [ServerRpc(RequireOwnership = false)] can some one help me out if this the best approach?

little sorrel
pearl swallow
#

Does anyone know any SDK I can use for offline Multiplayer?
The goal is to have my laptop as a server and all the devices connected to it via hotpot get to play the game.
I did notice that Netcode allows for offline multiplayer when connected to a LAN cable but it did not work with hotspot.

uncut bluff
#

Tarodev as it also

austere yacht
pearl swallow
austere yacht
#

you're always gonna have IPs and send messages between them

pearl swallow
austere yacht
pearl swallow
#

Alright, I will try it out once again, thank you ๐Ÿ™‚

stone agate
#

We need our app to be used behind a proxy server with Proxy-Authorization. To do so it's necessary to set the HTML request's custom header "Proxy-Authorization" like this:

request.SetRequestHeader("Proxy-Authorization", "Basic HereIsTheToken");

Unfortunaly Unity is blocking it saying InvalidOperationException: Cannot override system-specified headers. Does anybody has an idea on how to solve this problem?

snow summit
#

Hello, I'm building a card game with 2 players, I coded everything but I missed one important thing, with 2 client, LocalClientId is 0 for both clients when I run it on my PC... there is a way to change the local clientid for one of them?

cobalt ore
snow summit
snow summit
#

I build the game and than I open from the build the game 3 time, 1 server and 2 clients

cobalt ore
cobalt ore
topaz forum
#

Can someone DM who is familiar with Photon Fusion?? i need help spawning game objects

uncut bluff
#

any idea on how should I aproach on how to do a game score? I didn't want to keep it client side, only server side, should I use the network variables with a list?

#

or should I just make a list of network variables?

#

a variable for each player in game

azure mango
#

@uncut bluff Without more context I don't know what are you doing.. but you can have a variable in each client that stores that (even if you set it only on the server), or a list in a Server script with each player score...

uncut bluff
#

so this is what I am trying to do

public class GameScore : NetworkBehaviour
{ 
    private NetworkList <PlayerScore> _gameScore = new NetworkList <PlayerScore>();
}    
public class PlayerScore{

    public int ID =0;
    public int Death=0 ;
    public int Kill=0 ;

    public PlayerScore (int _id, int _death, int _kill )
    {
        ID=_id;
        Death=_death;
        Kill=_kill;
    }
}
#

but I am getting a "The type 'PlayerScore' must be a non-nullable value type" when creating the network list

olive vessel
#

Make that class a struct

uncut bluff
#

the same error pressits

#

public struct PlayerScore{

    public int ID;
    public int Death;
    public int Kill;

    public PlayerScore (int _id, int _death, int _kill )
    {
        ID=_id;
        Death=_death;
        Kill=_kill;
    }
}
#

like this?

#

now I have the error
The type 'PlayerScore' cannot be used as type parameter 'T' in the generic type or method 'NetworkList<T>'

olive vessel
#

Well that's technically a different error, progress

#

Ah

#

You may need to implement this interface

uncut bluff
#

so I cannot use a struct in a list I guess?

olive vessel
#

Well yes you can

#

And it can't be a class

uncut bluff
#

humm ok

cobalt ore
# uncut bluff ```cs public struct PlayerScore{ public int ID; public int Death; ...

I think you should do something like:
`
public struct PlayerScore : INetworkSerializable
{
public int ID;
public int Death;
public int Kill;

    public PlayerScore(int _id, int _death, int _kill)
    {
        ID = _id;
        Death = _death;
        Kill = _kill;
    }

    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref ID);
        serializer.SerializeValue(ref Death);
        serializer.SerializeValue(ref Kill);
    }
}

`

#

sorry, i don't know how to format code xD

uncut bluff
#

still has this error
The type 'PlayerScore' cannot be used as type parameter 'T' in the generic type or method 'NetworkList<T>'. There is no boxing conversion from 'PlayerScore' to 'System.IEquatable<PlayerScore>'. [Assembly-CSharp]csharp(CS0315)

#

with that last one @cobalt ore

cobalt ore
#

the variable declaration is something like this:
private readonly NetworkVariable<PlayerScore> playerScoreVariable = new(writePerm: NetworkVariableWritePermission.Server);

uncut bluff
#
private  readonly NetworkList <PlayerScore> _gameScore = new (writePerm:NetworkVariableWritePermission.Server);
cobalt ore
#

Maybe because you're trying to use NetworkList instead of NetworkVariable.

#

Try changing to NetworkVariable and see if that works.

uncut bluff
#

maybe, that was why I was using a class instead of a struct?

cobalt ore
#

After that you may try to adapt to a List.

uncut bluff
#

but I need a list

uncut bluff
#

a list of networkvariables?

olive vessel
#

Then your struct needs to implement IEquatable<T>

uncut bluff
#

fuck this is gona be hard I suck at reading docs

olive vessel
#

Nobody said Multiplayer is easy

uncut bluff
#

hahaha

#

well I was thinking in making a gameobject with a script that holds a list of players with their kill/death ratio, and I wanted only that object to be edited in the server, maybe I can save the data of each player in the player game object using RPC and then I fetch all of the network variable data from each player game object?

#

can that still be hacked?

#

ah no forget it, because each player prefab network variable would be the same...

cobalt ore
#

you want something like a network game manager, right?

#

I just found an example of NetworkList inside Boss Room sample

#

You might just adapt to your needs.

#

how do i insert a code block here on discord?

uncut bluff
#

in unity learn?

cobalt ore
uncut bluff
#
`` ``
#

3 of those in the beggining and in the end

#

I made 4 by mistake, no spaces

#

were can I find that boss room project?

cobalt ore
#

discord do not allow me to send, the code is too long ๐Ÿ˜

uncut bluff
cobalt ore
#

if you want to look the code yourself, it's located at "Assets\Scripts\Gameplay\GameState\CharSelectData.cs"

#

just search for NetworkList

uncut bluff
#

humm cool thanks man

cobalt ore
#

the key to NetworkList appears to be the "public bool Equals(LobbyPlayerState other)" inside the struct

uncut bluff
#

I am already downloading the project to study it but I am gona try to do this now

#

ok

cobalt ore
#

ok, good luck

#

I've been working on online multiplayer for my game using Unity Relay, and it's doing well for now. I'm trying to figure it out how to implement NAT Punchthrough with Relay Fallback, but I couldn't find any guide on how to setup NAT Punchthrough. Do I need a different Transport? Can anyone tell how to begin with it? Thanks!

uncut bluff
#

@cobalt ore I managed to make the list

#

now it seems that to add rows its not as like a normal list

cobalt ore
#

i did not mess with network lists yet, so I don't know how it works

#

and the docs seems to be vague yet

uncut bluff
#

yeap I dont know I am getting a null ref when I try to add a row, and it seems that its the same as a normal list as I can see in the example project

urban pendant
#

Using this rpc on all clients. Everything okay if client is a MasterClient, but things are going weird when client is not. At the part when i am setting the map map = โ€ฆ it not setting it or it sets to (Missing object). And at the transform.position = โ€ฆ it throws Null Reference Exception. Everything other in this rpc is works, except it cant set the variable map for non-MasterClient players.

vestal stump
#

Hey guys, I'm new to Unity multiplayer and this new Netcode for Gameobjects still doesn't seem to have enough easy sources to learn from. Is there an alternative to use or should I just wait for more learning content to be produced?

olive vessel
#

Mirror is probably most similar to Netcode

vestal stump
#

Would you recommend them over Netcode to a beginner?

#

Netcode doesn't seem too hard but I keep making mistakes on it and I just can't find a proper in depth tutorial that goes over everything

olive vessel
#

Beginner at Unity and C#, or beginner at multiplayer?

#

I found Mirror easier to grasp than Netcode

vestal stump
#

I'm decent at C# coz I've been using Java for years, and I've started with Unity like 3 months ago, so I do know how to make games, even tho they're not necessarily polished by any means. I wanted to look into multiplayer, but that just seems harder to learn

olive vessel
#

But Mirror has been around longer, there's lots more information out there about it

vestal stump
#

Hmm, will look into it

#

Thank you

#

Heck yeah, so many tutorials about it

#

Will switch back to Netcode if it becomes the norm but Mirror seems great for now :D

serene saddle
#

Is there a better way to 'hold' objects? When I have two players loaded into a scene and I have the non-master client holding something, the master client sees the non-master client's held object jumping into place, causing physics to freak out a little. I do have it set so OnClick() (when the item is picked up) ownership is transferred.

serene saddle
#

Upon further investigation the strange de-syncing only seems to happen when an object is 'dropped' by one player, and picked up by another.

hexed stone
#

I'm new to unity, but wanted to get some insight into networking design for a simple multiplayer fps in the future. When designing multiplayer functionality, do you generally lock the server update tick rate to the physics rate, or is it generally independent? How does physics tick rate affect client desync and server tick rate?

austere yacht
#

A simple architecture would just have client send inputs to a server and receive all changes resulting from these inputs that affect gameplay from the server directly without doing any prediction or anticipation to reduce lag, since the tick here is just happening on the server no further management of it is needed. Alternatively if you donโ€™t need to deal with cheating you can allow all clients to change the game world directly and use the server only for reporting these changes to others, with the result that lag becomes invisible unless two players interact in high-accuracy situations (like shooting at each other), here a tick system is also often unnecessary

eager panther
#

example:

should i do that to not run it on a server?

public class FpsCounter : NetworkBehaviour {
    
    private float t;
    private long lastTicks = DateTime.Now.Ticks;
    private int count;
    private int frames;

    public override void OnNetworkSpawn() {
        if (!this.IsClient) return;
    }

    public void Update () {
        long ticks = DateTime.Now.Ticks;
        this.t += (ticks - this.lastTicks);
        this.lastTicks = ticks;
        this.count++;
        
        if (this.t >= 10000000) {
            this.frames = this.count;
            this.count = 0;
            this.t %= 10000000;
        }
    }
    
    public int GetFps() {
        return this.frames;
    }
}

or is that fine? (because this need not run on a server) does it automaticly not run on a server?

public class FpsCounter : MonoBehaviour {
    
    private float t;
    private long lastTicks = DateTime.Now.Ticks;
    private int count;
    private int frames;

    public void Update () {
        long ticks = DateTime.Now.Ticks;
        this.t += (ticks - this.lastTicks);
        this.lastTicks = ticks;
        this.count++;
        
        if (this.t >= 10000000) {
            this.frames = this.count;
            this.count = 0;
            this.t %= 10000000;
        }
    }
    
    public int GetFps() {
        return this.frames;
    }
}
wise flower
#

On games that have server browsers, how does the server broadcast its presence to other clients on the internet? I assume there's an sql database somewhere that the server just sends its ip address, server name and whatnot to an sql database sever. Then the client server browsers just retrieve the information from that predefined server. I could be wrong though. Is there a better way to do that?

You don't have to do that with lan servers because checking all 255 ip addresses for a server isn't that hard.

austere yacht
serene saddle
#

Is there a better way to 'hold' objects? When I have two players loaded into a scene and I have the non-master client holding something, the master client sees the non-master client's held object jumping into place, causing physics to freak out a little. I do have it set so OnClick() (when the item is picked up) ownership is transferred.

Upon further investigation the strange de-syncing only seems to happen when an object is 'dropped' by one player, and picked up by another.

(posting again as I didn't get a response from yday, and am still stuck on the issue)

upbeat palm
weak plinth
#

hello noob question how can i sync in the unet structure with code the players prefab? like GetComponent<NetworkObject>().syncPrefab ?

dusky storm
swift oriole
#

Anyone have any idea why rigidbody collision velocity would be inconsistent with clientnetworktransform?

#

they seemed to work fine when i was trying to make it server-side, but when i changed to client-side, the variables are really strange. like a normal object falling from a relatively short distance at normal gravity will give me 70 squaremagnitude for collision.relativevelocity

fervent root
#

Does anyone have a solution in mirror only for certain game objects to have a rank tag before there name like owner: playername for an example?
All I want is an answer FYI

olive vessel
#

I don't think you can create tags at runtime

#

You can create components that hold strings though

#

Now I understand you only want an answer, but there's probably a different way to do what you're doing

fervent root
#

alright because right now I am researching my solution atm

fervent root
#

@olive vessel So I can do this by adding on strings to the player object?

weak plinth
olive vessel
olive vessel
fervent root
olive vessel
#

You mean a nametag?

fervent root
#

yes but with some tags that are assign as staff and etc. But for default players it will just be memeber

#

idk if I am making any sense

olive vessel
#

Right well be specific in future, tags are a different thing in Unity

fervent root
#

ah

olive vessel
#

A nametag is simple, make a component with a networked string or whatever, that sets a text above someone's head

#

To put the text above someone you can use a world space canvas

fervent root
#

right and I did this for an example and its not the best example in the world lmfao.
So I just add a canvas next to that certan object to add the text owner: to that one object?

olive vessel
#

You can use the same text object, just concatenate strings

fervent root
#

aaah

#

thank you UnityChanClever

olive vessel
#

Maybe it'd look better to have it on a different Text object in smaller font

#

Either above or below the name

fervent root
#

ah alright

#

thinking above maybe

vestal stump
#

Anyone have a guess as to why Build And Run ruins my movement?

olive vessel
vestal stump
#

Think so. Why?

#

That a mistake?

olive vessel
#

Are you?

#

It's yes or no, you can't maybe have done it

vestal stump
#

I did, yes.

#

Oh wait, no

#

My bad, that was just the camera speed in my Script

#

The movement itself doesn't use it

vestal stump
#

Great, now I can't move in the Unity Editor version either

#

Lemme increase the speed

#

It works! Thanks!

swift oriole
#

anyone have any idea why this throws an error? i'm literally just copypasting the sample from the documentation, seen at
https://docs-multiplayer.unity3d.com/netcode/current/basics/object-spawning/index.html
getting this compilation error: ssets\Scripts\PogoCharacter.cs(460,9): error - SpawnVfxServerRpc - Don't know how to serialize GameObject. RPC parameter types must either implement INetworkSerializeByMemcpy or INetworkSerializable. If this type is external and you are sure its memory layout makes it serializable by memcpy, you can replace UnityEngine.GameObject with ForceNetworkSerializeByMemcpy`1<UnityEngine.GameObject>, or you can create extension methods for FastBufferReader.ReadValueSafe(this FastBufferReader, out UnityEngine.GameObject) and FastBufferWriter.WriteValueSafe(this FastBufferWriter, in UnityEngine.GameObject) to define serialization for this type.

olive vessel
#

I can't see one that passes a GameObject in an RPC

#

Probably because you can't

swift oriole
#

even if the reference is stored on the server, it seems to throw the same issue

olive vessel
serene saddle
#

Is there a better way to 'hold' objects? When I have two players loaded into a scene and I have the non-master client holding something, the master client sees the non-master client's held object jumping into place, causing physics to freak out a little. I do have it set so OnClick() (when the item is picked up) ownership is transferred.

Upon further investigation the strange de-syncing only seems to happen when an object is 'dropped' by one player, and picked up by another.

(posting again as I didn't get a response from yday, and am still stuck on the issue)

swift oriole
swift oriole
# olive vessel Yeah, like this

hmm... there doesn't seem to be any kind of error message thrown, i'm sure im doing something wrong.. but unity does not seem to be giving me any warnings for this

#

0 errors thrown on either server or client side

sick belfry
#

Hi everyone, I'm using Unity Netcode For GameObj and I have an void which Updates the Client. But in the editor I get "Server Rpc Method must end with 'ServerRpc' suffix!"

swift oriole
sick belfry
#

but the problem is, that the UpdateClient void is looking like this "UpdateClientServerRpc"

swift oriole
#

you rename that as well, and you add [ServerRpc] above

sick belfry
swift oriole
#

yeah, that should work

sick belfry
#

yeah, i still get the error

swift oriole
#

you need to add it where it's called as well

sick belfry
#

wdym?

#

oh

swift oriole
#

show me how you're trying to call it

sick belfry
#

so?

swift oriole
#

yeah, what's the error now?

sick belfry
#

yea, i fixed it

#

I moved the position for the void in the script (Like at the top in the class) and it got fixed.

serene saddle
#

Hey, I have a Flashlight which players can pick up at their own discretion, however when someone picks it up after it's instiatiated and drops it and someone else picks it up, it has really bad positioning de-sync and I'm not sure why.

    void Click()
    {
        playerController = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();

        handCube = playerController.GetRightHand();

        this.tag = "HeldEquipment";

        GetComponent<BoxCollider>().enabled = false;
        GetComponent<Rigidbody>().isKinematic = true;

        transform.parent = handCube.transform;
        transform.position = handCube.transform.position;
        transform.rotation = handCube.transform.rotation;

        transform.localRotation = Quaternion.Euler(180, 0, 180);
        transform.localPosition = new Vector3(1.8f, -0.2f, -1.7f);

        this.tag = "HeldEquipment";
        isPickedUp = true;
    }
    
    [PunRPC]
    void OnToggleEquipment()
    {
        GetComponentInChildren<PhotonView>().RPC("ToggleEquipment", RpcTarget.All);
    }

    [PunRPC]
    void ToggleEquipment()
    {
        if (!isPickedUp) return;

        isTurnedOn = !isTurnedOn;
        lightSwitch.Play(null);
        lightSwitch.Play("Click");

        GetComponent<AudioSource>().Play();

        StartCoroutine(ToggleLight(isTurnedOn));
    }

    IEnumerator ToggleLight(bool toggle)
    {
        yield return new WaitForSeconds(.1f);
        lightObject.enabled = toggle;
    }

    void OnDropEquipment()
    {
        this.tag = "Equipment";
        
        isPickedUp = false;
        GetComponent<BoxCollider>().enabled = true;
        GetComponent<Rigidbody>().isKinematic = false;

        transform.parent = null;
        GetComponent<Rigidbody>().AddForce(handCube.transform.forward * 100);
        this.tag = "Equipment";

        playerController = null;
    }

Is there anything obvious there?

swift oriole
#

i know network parenting is tricky.. one of the docs should mention it somewhere, maybe in networktransform

serene saddle
#

I managed to 'fix' it by removing the .addForce() from it.

#

It's probably not the best solution but I'm so annoyed that I didn't think of that before.

#

Seems to look stable enough so I'll deal with it.

#
        DoorController[] doors = GameObject.FindObjectsOfType<DoorController>();
        foreach(DoorController doorController in doors)
        {
            GameObject networkedDoor = null;
            if(PhotonNetwork.IsMasterClient)
            {
                networkedDoor = PhotonNetwork.InstantiateRoomObject("Doors/" + doorController.name, doorController.transform.position, doorController.transform.rotation);
            }
            networkedDoor.AddComponent(doorController);
        }

I'm currently working on this and trying to figure out the best way to apply already-existing variables to a newly instantiated object.

#

cannot convert from 'DoorController' to 'System.Type'

raven temple
#

Hi, I'm planning to make 1v1 tower defense game. I've never made any multiplayer game, but I'm familiar with Unity. Would You recommend me to use Photon or Netcode?

glossy vault
raven temple
finite knot
#

is this the channel for online games?

olive vessel
#

Sure, it's for networking

amber dew
#

Hey I'm having a issue where my server shutsdown after like 3minutes with the error: stack smashing detected, I'm using unity Game Server Hosting.
All I'm doing is sending a boolean to the server every 15 seconds to prevent the client from disconnecting for being idle:

    private void SendActivityToServerServerRpc(int inClientID, bool inIsActive)
    {
        if (inClientID == 1)
        {
            IsStillPlayingPlayerOne.Value = inIsActive;
        }
        else
        {
            IsStillPlayingPlayerTwo.Value = inIsActive;
        }
    }```
finite knot
#

I have a "simple" question which is

#

is it possible to do an online game for mobile phone devices with Unity

#

I know it is possible to do an online game or a phone game but idk if the both combined are possible for really amateur teams

swift oriole
#

is there like.. any way to debug why an a function is not getting called?
i have a simple scenario where the server subscribes to networkvariable.onvaluechanged
now, i've debugged every single variable change.
the variables are being changed from the server, which should be triggering the onvaluechanged function.
but there are just no errors and no debugs of any sort, the function just never gets called.
i tried serverrpc as well, but it just doesn't seem to work.

olive vessel
finite knot
#

between any phone from anywhere

#

not sharing the same wifi or anything like that

swift oriole
#

the bottom line on the image does trigger onscorechanged

finite knot
#

a real online game

#

@olive vessel so it is possible right?

#

sorry for ping

olive vessel
#

It is possible yes

#

There are games that do that, which would be hard if it were impossible

swift oriole
#

but somewhere else, (still running on the Server), i change the teamscore value, it debugs that it's getting called, but the onvaluechanged is never called

finite knot
#

is it possible or only Amogus can do it?

olive vessel
#

Well that's a silly comment

#

If one game can do it, any game can

#

I am assuming Netcode could do it

#

You can test it

finite knot
#

okay, thank you so much! I should probably

amber dew
#

Would you happen to know what it means when my server stop with the error: stack smashing detected?

olive vessel
#

Interesting, what on Earth are you doing?

amber dew
#

Nothing, thats the issue, my clients are connected to the dedicated linux server using unity gaming service

#

And everytime after 3 minutes this error stops the server

olive vessel
#

I'm sorry but I doubt it's "nothing"

#

Clearly something is going wrong somewhere

amber dew
#

True, but I'm not sending any RPC calls or anything

olive vessel
#

Are you doing anything?

amber dew
#

No, only initializing some network variables once the server and client connect

olive vessel
#

Lets have a look

amber dew
#
    {
        if (!Instance)
            Instance = this;

        // Initialize all the networked variables
        Player1Field = new NetworkList<ReplicatedGameData>(new List<ReplicatedGameData>(), NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server);
        Player1Field.Initialize(this);
        Player2Field = new NetworkList<ReplicatedGameData>(new List<ReplicatedGameData>(), NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server);
        Player2Field.Initialize(this);

        BulletsThatPlayer1Fired = new NetworkList<ReplicatedBulletData>(new List<ReplicatedBulletData>(), NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server);
        BulletsThatPlayer1Fired.Initialize(this);
        BulletsThatPlayer2Fired = new NetworkList<ReplicatedBulletData>(new List<ReplicatedBulletData>(), NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server);
        BulletsThatPlayer2Fired.Initialize(this);
    }```
#

So this is happening on the server and the clients, since the script is placed on a object in the scene

olive vessel
#

If you comment it out is it still borked?

amber dew
#

Yea

olive vessel
#

You mentioned earlier you were sending a heartbeat

amber dew
#

Yes it's set to 500ms

#

Its all the default settings on the unity transport component

olive vessel
#

Meh I don't get it, you're using Netcode right?

amber dew
#

Yes, using Unity.Netcode;

#

public NetworkList<ReplicatedBulletData> BulletsThatPlayer2Fired;

olive vessel
#

What's ReplicatedBulletData

amber dew
#

A custom struct

olive vessel
#

Lets see it

amber dew
#
public struct ReplicatedBulletData : INetworkSerializable, IEquatable<ReplicatedBulletData>
{
    public int TileID;
    public int BulletType;

    public ReplicatedBulletData(int inTileID, int inBulletType)
    {
        TileID = inTileID;
        BulletType = inBulletType;
    }

    public bool Equals(ReplicatedBulletData other)
    {
        return TileID == other.TileID && BulletType == other.BulletType;
    }

    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref TileID);
        serializer.SerializeValue(ref BulletType);
    }
}```
olive vessel
#

And ReplicatedGameData

amber dew
#
public struct ReplicatedGameData : INetworkSerializable, IEquatable<ReplicatedGameData>
{
    public bool bIsInitialized;

    public int TilePos;
    public int TileType;
    public int FogDuration;
    public int DamagedDuration;
    public int BuildingType;
    public int Health;
    public int ShieldTopLeftCornerID;
    public int CartType;
    public int UpgradeType;

    public ReplicatedGameData(GameData inGameData)
    {
        bIsInitialized = true;
        TilePos = inGameData.TilePos;
        TileType = inGameData.TileType;
        FogDuration = inGameData.FogDuration;
        DamagedDuration = inGameData.DamagedDuration;
        BuildingType = inGameData.BuildingType;
        Health = inGameData.Health;
        ShieldTopLeftCornerID = inGameData.ShieldTopLeftCornerID;
        CartType = inGameData.CartType;
        UpgradeType = inGameData.UpgradeType;
    }

    public static int SortByPos(ReplicatedGameData a, ReplicatedGameData b)
    {
        return a.TilePos.CompareTo(b.TilePos);
    }

    // Don't compare these lol, tiles from different fields are not comparable with one another
    public bool Equals(ReplicatedGameData other)
    {
        return TilePos == other.TilePos;
    }

    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref bIsInitialized);
        serializer.SerializeValue(ref TilePos);
        serializer.SerializeValue(ref TileType);
        serializer.SerializeValue(ref FogDuration);
        serializer.SerializeValue(ref DamagedDuration);
        serializer.SerializeValue(ref BuildingType);
        serializer.SerializeValue(ref Health);
        serializer.SerializeValue(ref ShieldTopLeftCornerID);
        serializer.SerializeValue(ref CartType);
        serializer.SerializeValue(ref UpgradeType);
    }
}```
olive vessel
#

I've no clue, I thought you might have some recursion in your serialisation

#

The Netcode Discord is pinned here, might get you help faster

amber dew
#

Could it be this: GameData inGameData in the struct constructor

#

Cause thats not a replicated struct

#

Its not stored inside it though

olive vessel
#

As I say, no idea

amber dew
#

Alright, thanks for the help though! I'll ask in netcode server in that case

olive vessel
#

They'll probably have a better understanding of it than I do

swift oriole
#

hmm i don't get it.. networkvariable.onvaluechanged does not get called on server? also you can't call serverrpc on server?

real plume
#

I'm using Netcode for GameObjects, and I want to be able to show an error message on screen when the user types in an invalid port or address. Is there a quick way to accomplish this?

olive vessel
real plume
real plume
ripe mesa
swift oriole
#

What would be the proper way to set up a playername, and then synchronize that name to other players upon join, if the player name is stored as a networkvariable?

#

since each player has team-related things, i assume you'd have to somehow iterate through all connected clients on join on Server, and have them assign the necessary things client-side, on all other clients (that they don't own)?

amber dew
ripe mesa
amber dew
#

I think that maybe GameData inGameData this could be the issue, its a parameter inside a networked struct, and that is not a networked struct, and maybe there it somehow gets fucked? But its not storing it in anyway so yea

#

I will do a bunch of more testing when I get home and see if anything works!

olive vessel
#

I doubt it, they're all value types so there's no references being stored

weak plinth
#

i did a player 2d topdown movement with a joystick for mobile, but when i try to implement multiplayer, that doesnt work, because in my script i cant use the joystick because player becomes a prefab what could i do?

olive vessel
#

I don't see why the player being a prefab is an issue?

weak plinth
#

well ig i just asked wrong way

#

here i need to put my joystick

#

but everytime i delete the prefab from the scene, so it comes into the scene when i start host

olive vessel
#

Well surely it's a script on the player?

weak plinth
#

wdym on player theres player script and i have script on joystick canvas aswell

olive vessel
#

So PlayerMovement is on what?

#

Because really with a name like that, one would assume it's on the player

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

public class Player : MonoBehaviour
{
    public PlayerMovement movementJoystick;
    public float playerSpeed;
    private Rigidbody2D rb;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if(movementJoystick.joystickVec.y != 0)
        {
            rb.velocity = new Vector2(movementJoystick.joystickVec.x * playerSpeed, movementJoystick.joystickVec.y * playerSpeed);
        }

        else
        {
            rb.velocity = Vector2.zero;
        }
    }
}```
#

thats the player one

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

public class PlayerMovement : MonoBehaviour
{

public GameObject joystick;
public GameObject joystickBG;
public Vector2 joystickVec;
private Vector2 joystickTouchPos;
private Vector2 joystickOriginalPos;
private float joystickRadius;
    // Start is called before the first frame update
    void Start()
    {
        joystickOriginalPos = joystickBG.transform.position;
        joystickRadius = joystickBG.GetComponent<RectTransform>().sizeDelta.y / 4;
    }

    public void PointerDown()
    {
        joystick.transform.position = Input.mousePosition;
        joystickBG.transform.position = Input.mousePosition;
        joystickTouchPos = Input.mousePosition;
    }

    public void Drag(BaseEventData baseEventData)
    {
        PointerEventData pointerEventData = baseEventData as PointerEventData;
        Vector2 dragPos = pointerEventData.position;
        joystickVec = (dragPos - joystickTouchPos).normalized;

        float joystickDist = Vector2.Distance(dragPos, joystickTouchPos);

        if(joystickDist < joystickRadius)
        {
            joystick.transform.position = joystickTouchPos + joystickVec * joystickDist;
        }

        else
        {
            joystick.transform.position = joystickTouchPos + joystickVec * joystickRadius;
        }


    }

    public void PointerUp()
    {
        joystickVec = Vector2.zero;
        joystick.transform.position = joystickOriginalPos;
        joystickBG.transform.position = joystickOriginalPos;
    }

 
}
#

thats movement which is on my joystick canvas

olive vessel
#

Right so when the Player is spawned, they're gonna need to use a method to find it

weak plinth
#

like so

olive vessel
#

You can't reference scene objects in a prefab

weak plinth
#

so like i need to find the other methos, that at the start, it connects the script or its not even possible?

olive vessel
#

Well obviously it's possible to find other objects at runtime

#

When the Player is spawned you can search for the PlayerMovement that exists in the scene

weak plinth
#

i acidently had canvas as a prefab or should i have it? i think no right?

olive vessel
#

I don't really get your setup to be honest

#

If the canvas with PlayerMovement exists in the scene, when the Player is spawned you can find it

weak plinth
#

yeah its here, the one i drag in the player script is MovementJoystick object

#

so ig i have to find a way to find MovementJoystick at the start?

willow arch
#

I'm getting an error saying that "only the server can despawn objects" even though I'm running the despawn function in a server rpc

amber dew
#

So even with having no networked variables in mt game, the server still shuts down after 3min saysing 'stack smashing detected'
Could it be my build confif Launch parameters, that I'm missing something? I have:

-nographics -batchmode -ip 0.0.0.0 -port $$port$$ -queryPort $$query_port$$ -logFile $$log_dir$$/matchplaylog.log -sqp

swift oriole
#

still kinda stuck on this... maybe i'm just missing something very obvious... how would you synchronize player names?
i'm able to assign teams and names to my players using networkvariables, but if a player's name is set, wouldn't that mean you'd have to assign the textrenderers on every other connected player, but not on their own networkprefab, but on their local versions of every client?
since you can't just synchronize a textrenderer like you can synchronize a networktrasform...
anyone got any tips for this?

olive vessel
#

The player exists for other people, so give them a network variable for their name, and set their "body"'s text for everyone using it

#

Should be really simple

swift oriole
#

they do have a networkvariable for their names. by all accounts it should work, but it's looking strange

#

for some of the clients none of them synchronized, for some, all but one did

#

that's pretty much all i did

swift oriole
olive vessel
#

I wonder if the OnValueChanged event is called when a client joins after the change

#

It might not be, and that would mean the original client (or host) sees all the names, and the newest sees none of them

swift oriole
olive vessel
#

My guess is the event is not called when a client joins after a change

#

You can ask in the Netcode Discord, it's pinned here

swift oriole
#

oh there's a netcode discord ๐Ÿ˜ฎ

#

thanks for the tip ๐Ÿ™‚

stone fulcrum
#

Hey everyone! Just dropping by to say that the **Multiplayer Dev Blitz Day is open for your questions! **
Just head to the Multiplayer Discord Server, Unity Forum or Reddit Unity3D to ask anything related to Multiplayer ๐Ÿ™‚
https://discord.gg/3SzD5agE?event=1032672021110329344

uncut bane
#

Hello. I'm using Netcode. How can I set player's camera? Each player has a camera as a child object.

#

I want the player to see from it's own camera.

olive vessel
#

General rule is to check isLocalPlayer and disable components like the Camera on objects when that is false

uncut bane
#

Okay, thank you

dry cave
#

I found the issue on why the second player can't move. The new input system assigned him to an Xbox Controller. Is there a work around so Unity can assign every player Mouse and Keyboard?

agile cosmos
#

I have a question about Relay/Lobby system.

_currentLobby = await Lobbies.Instance.QuickJoinLobbyAsync();
there is no problem about this part. I'm getting my lobby code via Data property.

Players can find available open lobbies but the problem is after they left the lobby they can't find the same lobby again. (No available lobbies even if lobby is still there)

But i wan't people to be able to find the same lobby again.

Details:
*There is no problem about lobby heartbeats etc. New players can still find that specific lobby with QuickJoinLobbyAsync .
*The player who leaves the lobby is still able to join another/a different lobby if there is any (room available)
*The player is able to join the same lobby using the lobby code

forest vessel
#

Hi
I am working on a multiplayer game.

I want if the player 1 and player 2 is in the circle and player 3 is not in circle
The destroy player 3

Those player whos not in the circle destroy

bold canyon
#

hello i have another problem.. so basically i was trying to get netcode to work with a server but a server and client dont work.. why? it gives a error that only server can spawn players tho i made a server
also i have not assigned the player prefab as i do it in my script automatically

olive vessel
#

That means the client tries to spawn objects, which isn't allowed

bold canyon
#

Ok

mild owl
#

Hey i am trying to combine MLAPI with Steam to use the steam functionality to combine player. Can somebody help how to do that?

olive vessel
mild owl
#

can you send it to me?

olive vessel
# mild owl do you know where

There is a repo for them online if you search for it, ensure you are using Netcode for GameObjects and not it's predecessor MLAPI

sonic wigeon
#

anyone here done networking? I need help thinking on how to sync objects
the problem is that I have A LOT of objects in the game
and sending them over will be slow
does unity have like "hashes" for objects or smth like that?

#

mainly, I need to give each object a unique "id" which is gonna be accessed with a dict

#
    public Dictionary<int, Object> Objects { get; private set; }

still hare
#

just increment an int every a time a new object is created and assign that id to that new object.. but what does a dictionary of objects have to do with the fact that sending them all over will be slow?

#

if you are sending a ton of data when a client connects or something, just send it over time and make the client wait for a message letting it know that it been sent all the data and can now join

sonic wigeon
tender moon
#

sorry for the very green question - What is the current state of networking / official networking solutions in unity? I'd like to make a mobile racing game as a solo developer.

bold canyon
#

hello, uhm in my networking with netcode when i dont assign the player prefab in the player prefab spot and i try to spawn it myself it doesnt work. I did it as a network object but somehow it doesnt work.. please help. below is code

#
        NetworkManager.Singleton.StartClient();
        Vector3 playerPosition = new Vector3(0f, 1f, 0f);
        Quaternion playerRotation = new Quaternion(0f, 0f, 0f, 0f);
        Transform spawnedObjectTransform = Instantiate(playerPrefab, playerPosition, playerRotation);
        spawnedObjectTransform.GetComponent<NetworkObject>().Spawn(true);```
bold canyon
#

in my code basically when i try to make a network Object it doesnt create a network object

#

just locally

#

idk why

#

i tried to add things if(!IsServer) return; but no change

olive vessel
#

My guess is no given the StartClient call there

#

Pretty sure that Quaternion isn't valid either, you don't want to be messing around making Quaternions, use Quaternion.identity

crimson gate
#

anyone can help me with photon?

i have 2 players one of them cant see through the other character

for example player A and player B
I join in with player A
Friend joins in with player B
I am able to move player A and not B
Friend can move player B but cant see out of him
instead is looking through the view of player A and roates both when looking around but doesnt move A only moves B

graceful hare
#

this shows up when im spawning as host

olive vessel
#

I saw the post in the other channel. Are you actually starting host mode somewhere?

graceful hare
#

yeah

olive vessel
#

Well that error would suggest otherwise

graceful hare
#

ohhh

#

whats host mode

olive vessel
#

Well you've got a button for it there

graceful hare
#

im only using a button to start the host

#

ive also tried manually starting in networkmanager

olive vessel
#

I assume you're trying to spawn networked objects before it's ready

graceful hare
#

it was working before

#

until i went on adding a player count

#

maybe

olive vessel
#

Well then you need to think about what changes you made

graceful hare
#

i tried to comment out everything here and it was still not working

#

i think i might have broke it

olive vessel
#

Well the error is regarding the spawning of objects

graceful hare
#

this is how im spawning it

#

am i doing something wrong

#

i have the gameobject correctly linked with both the script and networkprefabs

#

but its just not working

olive vessel
#

Do you have any other object spawning code?

graceful hare
#

yes

#

i have another script spawning the same thing

#

could that be the issue

olive vessel
#

Any code that spawns objects before the NetworkManager is ready is an issue yes

graceful hare
#

im only doing it in the updates

olive vessel
#

That tells me nothing

graceful hare
#

uhhh

#

how can i tell if networkmanager ready

olive vessel
#

How about you just show the code?

graceful hare
#

ok

#

this part has been working

#

this is from another script that im testing with

#

but it doesnt call rpc

olive vessel
#

In the error is it more specific, click it and show the whole Console

graceful hare
olive vessel
#

What is PlayerObjectSpawner line 19?

graceful hare
olive vessel
#

Well that's the line that is called before the NetworkManager is listening

graceful hare
olive vessel
#

Not quite sure how, thought that class was a NetworkBehaviour

#

Ah ha

#

You're calling Spawn in a ClientRpc, it must be called on the server

#

So do it in the ServerRpc instead

graceful hare
#

ive tried that before i think

#

lemme try again

#

for some reason its just not recognizing my host as the host i think

olive vessel
#

I'm out of ideas then, the Netcode Discord is linked in pins if you want to give them a go ยฏ_(ใƒ„)_/ยฏ

graceful hare
#

AwkwardEmol thanks

bold canyon
bold canyon
bold canyon
#

Okay so I found the error in my code I believe..

#

So basically don't have a RPC to send the message to server to create the object

#

But I have no idea how to do it

#

Can someone tell how to use RPC to spawn objects?

olive vessel
spark violet
#

Hey Guys question ! im looking to start my first multiplayer project "super small" to learn basically like let 1 friend join me and play any advice on where to go or what to use to get that ?

olive vessel
spark violet
#

Ok and what would be "easiest" for beginner

#

?

olive vessel
#

Well that's not exactly an easy question, most people just say "Photon PUN" to that but I always found Mirror easier

#

With Photon PUN you run on their servers, up to 20CCU free

#

So you wouldn't have to mess around with port forwarding or using a relay

#

At the end of the day it comes down to features and preference

spark violet
#

Oh ok

#

And like p2p ?

#

20CCU is what ?

olive vessel
#

20 concurrent users

spark violet
#

Ah ok

#

But o need to use either one of those even if I want a pop like situation ?

olive vessel
#

I have no idea what a pop situation is

spark violet
#

2p2*

#

Peer to peer

#

P2p**

olive vessel
#

You can do P2P or dedicated servers with most solutions

spark violet
#

Hm ok.. so photon pun I guess will be the solution then messing with ports is a hassle

#

You got any good tutorials for that ?

olive vessel
#

Nope, didn't like PUN really so never bothered going too far with it

spark violet
#

Ok with mirror then ?

olive vessel
#

You're on Discord which suggests to me you have internet

#

Networking is hard, so you should expect to do a shit tonne of learning yourself

spark violet
#

Ok gotcha

weak plinth
olive vessel
#

Note: MLAPI is now called Netcode for GameObjects

bold canyon
bold canyon
#

After NetworkManager.Singleton.StartClient()

olive vessel
#

Well the error thinks not

#

Also you are not connected immediately after StartClient

bold canyon
#

What does that mean?

bold canyon
olive vessel
#

Well no, it's up to you to provide the code

#

I asked you when the RPC is sent, so show the code relevant to calling that method

bold canyon
#
public void ButtonClicked() {
NetworkManager.Singleton.StartClient();
PlayerServerRpc();
}```
#

This is the code

olive vessel
#

Right, so chances are you ain't connected

bold canyon
#

What?

#

But it says connected in console

#

?

olive vessel
#

Jesus...

bold canyon
#

Sorry

olive vessel
#

Chances are that when you call the RPC you are not actually connected

bold canyon
#

I'm new to it

bold canyon
#

So how do I fix it?

olive vessel
#

Wait until a callback that guarantees you're in, like OnNetworkSpawn in NetworkBehaviour

bold canyon
#

Okay

#

So a function called

#

And I override it right?

olive vessel
#

I think so

bold canyon
#

Onnetworkspawn

bold canyon
olive vessel
#

Properly PascalCased

bold canyon
#

And in that I use rpc?

olive vessel
#

Call the RPC there

bold canyon
#

Ok lemme try

bold canyon
olive vessel
#

Method names should be PascalCased, where the first letter of every word is capitalised

olive vessel
bold canyon
#

Yeah ik

#

I'm using phone

#

That's why

#

I'll do it tomorrow morning that's why

#

Thanks for the help

serene saddle
#
        navMesh = GetComponent<NavMeshAgent>();
        alienObject.SetActive(false); // Hides the alien.

        NavMeshHit r;
        if(NavMesh.SamplePosition(RandomPointInBounds(gameController.mainRoom.GetComponent<BoxCollider>().bounds), out r, 5, NavMesh.AllAreas))
        {
            print("Warping NavMeshAgent to " + r.position.ToString());
            navMesh.Warp(r.position);
        }

        navMesh.SetDestination(RandomPointInBounds(gameController.mainRoom.GetComponent<BoxCollider>().bounds));

This code is causing .SetDestination to say itโ€™s not on a NavMesh after itโ€™s been instantiated by Photon. Iโ€™d appreciate any help.

sonic wigeon
#

I have an issue Iโ€™m facing (theory)

#

Ok so Client B can move object A

#

And then it sends the fact it moved to the server

#

The server sends that info to all clients except B

#

But the problem is that if the object is in motion, all of the clients will be sending information to be relayed off the server

#

so then that means all clients are constantly spamming the server with that info

#

What should I do instead?

weak plinth
sonic wigeon
#

This is a sandbox game

#

A mod for a sandbox game to specific

weak plinth
#

The problem you're describing is quite common. Ever hear about Tarkov's auctions?

sonic wigeon
#

No

#

Like the game escape from Tarkov?

weak plinth
#

Yes, that game. The flea market

#

When you search, you see a list of items. They're not constantly updated, so you might get 20 "This item is no longer available" before you actually get to buy it.

#

That's the opposite of the problem you were discussing, over-communicating

sonic wigeon
#

I see

#

So over communication is better than conservative

weak plinth
#

I think it's rather cheap to multi-cast.

#

It's expensive to debug why a client was on a tile where you thought it should be impossible.

graceful hare
#

does anyone know why when my client connects it doesnt spawn anything in the clients scene

#

nvm i didnt figure out why but it stopped doing that

sonic wigeon
#

And also wouldnโ€™t it result in objects jittering around?

weak plinth
sonic wigeon
#

I mean like, if a client moves an object, then receives that the object should be in the previous position, doesnโ€™t that lock the object?

weak plinth
#

That's why the Tarkov flea market is frustrating

#

It's essentially "Yes, I'll buy it" "Oops, it's already been sold!"

#

Same as the situation you just proposed. What's a better alternative?

sonic wigeon
weak plinth
#

and for the pokemon world situation, you would have exactly 2 people in the same position

#

what you are discussing right now is a new situation which I didn't address

#

You're talking about heuristics

sonic wigeon
#

but this is a sandbox game

weak plinth
#

All I said was: Client A should broadcast to everyone

sonic wigeon
#

Yep, I agree, and thatโ€™s implemented

weak plinth
sonic wigeon
#

But the object can be in continuous motion, so do the rest of the clients keep sending the info of the object to everyone? Because to them the object is in motion, and the server must be updated

weak plinth
#

welcome to extrapolation

weak plinth
#

What you really need is a new conversation with someone else.

#

since the topic of what you want to discuss is different

#

I'm already in bed and away from my computer.

sonic wigeon
signal crown
#

Hi, I'm using Photon PUN, and I saw somewhere that I don't need to pass the owner or the object to the RPC, because the call will only ever go out to instances of the same PhotonView on other clients. However it seems to affect all instances that object (i.e. rpc call goes out to sync one player's action with all clients, should only affect that player across all the clients, however it affects all players across all clients)

This is my code, it should affect just one player's torch across all clients but it's not for some reason:

    public void placeHolderMethod()
    {
        photonView.RPC(nameof(TorchSync), RpcTarget.All, torchIsOn);
    }

    [PunRPC]
    public void TorchSync(bool torchValue)
    {
        torchLight.SetActive(torchValue);
    }```
I hope it makes sense
austere yacht
# sonic wigeon What should I do instead?

Use server authority and have clients only send the intent to move the object to the server which then does the arbritration and updates all clients on the result. What youโ€™ve been discussing above is an unsolvable problem in P2P networks

sonic wigeon
#

So I think thatโ€™s what you are suggesting

austere yacht
sonic wigeon
#

Perfect, thanks!

austere yacht
sonic wigeon
#

thanks!

austere yacht
#

well itโ€™s solvable but only if you trust your clients ๐Ÿค“

sonic wigeon
#

I mean yeah I do

austere yacht
#

doesnโ€™t take away the n^2 messages though

sonic wigeon
#

yeah, thatโ€™s true

uncut bane
#

Ight im confused. Im using Netcode and I want to shoot projectile from client and then display it on every client, so that everybody sees it. But server RPC is sent from client to server, so clients dont see it, and client rpc is sent from server to client, so I can't call it from client... what do I do?

#

Please ping me if anybody answers

olive vessel
#

You could spawn the object in a ServerRpc and use NetworkObject's SpawnWithOwnership method

uncut bane
#

It worked, thank you

uncut bane
#

One more thing. (The right one is focused window)
For some reason the projectiles are going in the wrong direction on other clients.
That's the function that handles it:

private void ShootProjectileClientRpc()
    {
        GameObject t_projectile = Instantiate(currentWeaponScript.projectilePrefab, currentWeaponScript.firePoint.position, Quaternion.identity, GameManager.currentGameManager.projectileParent);
        currentWeaponScript.firePoint.rotation = Quaternion.Euler(0, 0, playerMovement.angle);
        t_projectile.transform.rotation = Quaternion.Euler(0, 0, playerMovement.angle);
        t_projectile.GetComponent<Rigidbody2D>().velocity = currentWeaponScript.firePoint.right * currentWeaponScript.projectileVelocity;
        t_projectile.GetComponent<ProjectileBehaviour>().weapon = currentWeaponScript;
    }
#

looks like it reads transform.right globally

#

it always shoots to the right side on other clients.

uncut bane
#

Figured it out. I had to synchronise the angle as a network variable

oblique star
#

Does anyone know if there is a networking asset that's available on the unity store to support multiplayer functionality for an RPG game?

uncut bane
#

How can I get collisions with Netcode (2D)? I've added rigidbody 2d, network rigidbody 2d, network object and network transform to both objects, and they are not colliding.

olive vessel
uncut bane
#

That's there aswell. I had the rigidbody set to kinematic.

olive vessel
#

Ah

tidal brook
#

Is there any way to see, how many concurrent users are there currently, when using Relay.

crisp panther
#

any idea what going on?

still hare
#

do you even know if that code is causing the issue? doesn't look like it to me

#

it's saying that somehow a server to client rpc is being called from a client, which is bad for obvious reasons

#

seems like the rpc that's being called is inside of mirror's NetworkTransform

#

so maybe you have incorrect settings on a NetworkTransform

crisp panther
#

ya i already found out why

#

!Application. isBatchMode doing weird stuff keep by pass

neat veldt
#

Does anybody know the difference between NetworkManager and NetworkManager.Singleton, if there is any? (netcode)

olive vessel
neat veldt
olive vessel
#

One is just a class name, the other is an instance of the class

neat veldt
#

Ye ye, but most of the instance members have static counterparts

olive vessel
#

Only one of the members of NetworkManager is static

#

The Singleton member

neat veldt
#

But why?

#

And are the static ones the same as their instance counterpart on Singleton or separate?

olive vessel
#

There literally are no static members except Singleton

#

You cannot do NetworkManager.StartHost(), you have to call it on an instance NetworkManager.Singleton.StartHost()

neat veldt
#

Oh wait, NetworkBehaviour has a field called NetworkManager that points to the singleton

olive vessel
#

Yes it does

neat veldt
#

Ok that's what I got confused about

#

Thanks anyway!

digital compass
#

Is there a way to pass a GameObject to a ServerRpc?

paper kettle
#

Hey guys, I need help with the following:

My manager and I are creating a football robot with Arduino. The robot will be an UDP Server. I'm creating an app so you can connect to the robot via your phone in the app, and when you're connected, you can control the robot. The robot has its own network.

The phone controller will be UDP Client

However, I've no idea on how to properly do this.

I want to get access to the robot's Access Point

I should note that I'm an intern and am still studying Game Development, and I've not worked with Networking yet

Can anyone help me?

austere yacht
opaque path
#

How can make no collision system in multiplayer?

olive vessel
west escarp
#

so recently i m using photon to make a game multiplayer
it does this wierd thing
whenever i start the game with 1 player , it works fine
but when i open another , the prefabs swap with each other , i m controlling 2nd person with camera of first and vice versa
and when i include one more player just to test
1 -> 2
2 -> 3
3 -> 1 st player
i tried most solutions on internet , but none of them seem to work

#

please ping me if anyone has an idea how to solve it ๐Ÿ˜…

fallen flax
#

Hello

#

Currently i am working on car racing game. Everything is working perfectly in my system like 1st, 2nd and 3rd player is getting their points correctly but when i am sending build to client so the 2nd and the 3rd player are getting points of each other
can anyone please help why this issue is coming at the client side

#

???

tidal brook
#

I want to create a first person shooter which can be played in multiplayer and singleplayer. What should I do with the multiplayer scripts then?

bold canyon
#

Hello, I wanted to just ask that sometimes in my netcode I have problems like the player won't move in multiplayer

The player is connected to server
The client transform script is there
The script is correct (I debugged it on a test project)

But still it doesn't work, also no errors on client/server. Please help

bold canyon
#

someone pls help

bold gulch
bold gulch
bold canyon
silk iron
#

please help, I am trying to install the client network transform (netcode) via git url, but it doesn't work. It just gives me an error (I copied the url correctly!!)
I also tried to install it directly via the manifest.json file, but It gives me also an error.

https://docs-multiplayer.unity3d.com/netcode/current/components/networktransform/index.html

olive vessel
#

Or copy it from there

silk iron
#

thanks