#archived-networking

1 messages · Page 20 of 1

wide girder
#

You should use the debugger with breakpoints to debug the issue.

abstract copper
#

is that method declared in a spawned NetworkBehaviour?

sharp axle
#

Is this using Photon or NGO?

abstract copper
#

they said they are switching from Photon to NGO

sharp axle
#

Derp totally skipped over that part.

sly fable
#

Every other responsibility the prefab is responsible for works just fine

crude ridge
#

If using relay with NGO, do we need a heartbeat for the relay like we have for lobby? It seems like relay doesn't allow connections after the first 10 sec

#

Wait @sharp axle, was I supposed to config this variable to make this code actually remove the player

sharp axle
sharp axle
crude ridge
#

Right

#

So shouldn't I make that instant?

sharp axle
#

I didn't think that effected the relay integration removing the player. If your players are not mobile setting to 0 should be fine. Just know that any dropped packets could kick the player in that case

crude ridge
#

Well the min is 10

#

So ig I have to set it to 10 and not 0

#

Also do you know the rate limit for SendHeartbeatPingAsync?

#

How often should we send it

#

So ig it gets auto disconnected after 10 sec now, is there a way to make it so it's instant?

mint anvil
#

(using unity's lobby system when joining a lobby)
does anyone know what this means? and yes the lobbyId/code is the same when joining and when created.
the invalid character is always different
a few days ago it worked and now this?? idk what i changed to cause this

code:

    {   
        try
        {
            JoinLobbyByCodeOptions joinLobbyByCodeOptions = new JoinLobbyByCodeOptions
            {
                Player = GetPlayer()
            };
            Lobby lobby = await Lobbies.Instance.JoinLobbyByCodeAsync(lobbyCode, joinLobbyByCodeOptions);
            Debug.Log("joined Lobby: " + lobbyCode);
        }
        catch (LobbyServiceException e)
        {
            Debug.Log(e);
        }
        
    }```
Error:
crude ridge
#

either change it to be JoinLobbyByIdAsync or actually use the lobby code (which is 6 characters compared to the 22 of hte id)

mint anvil
waxen quest
#

Can anyone tell what's the ideal way of setting these values?

MaxPacketQueueSize & MaxPayloadSize

Like for a game with 5-20 players what should be the value?

I found this on the forum is this correct?

MaxPacketQueueSize is (Clients * Clients + 10) * 2 (10 for a small buffer, 2 for the reliable message system)


MaxPayloadSize is: ((Clients + 10) * (sizeof(float) * 3 * 3) * 10 (10 again buffer, the flaot times three shall 
represent the Transform at the Client spawn, and times 10 just as safeguard not being to low)
sharp axle
waxen quest
sharp axle
teal cedar
#

How to manually spawn player object? Any idea how to do it? (Netcode)

sharp axle
teal cedar
#

Btw, should I update my unity editor? I have netcode 1.2 and now it is already 1.6

sharp axle
#

You'll need to instantiate the prefab first to use getcomponent but yea. also NGO is on 1.7.1 now

spring crane
teal cedar
spring crane
#

I believe 2023 LTS will be called Unity 6

teal cedar
teal cedar
crude ridge
#

Why does my host get this error when a client leaves?

ArgumentNullException: String reference not set to an instance of a String.
Parameter name: s
System.Text.Encoding.GetBytes (System.String s) (at <787acc3c9a4c471ba7d971300105af24>:0)
Unity.Netcode.CustomMessagingManager.UnregisterNamedMessageHandler (System.String name) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.7.1/Runtime/Messaging/CustomMessageManager.cs:218)
Unity.Netcode.Components.NetworkTransform.OnNetworkDespawn () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.7.1/Components/NetworkTransform.cs:2524)
Unity.Netcode.NetworkBehaviour.InternalOnNetworkDespawn () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.7.1/Runtime/Core/NetworkBehaviour.cs:529)
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.NetworkBehaviour:InternalOnNetworkDespawn() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.7.1/Runtime/Core/NetworkBehaviour.cs:533)
Unity.Netcode.NetworkObject:InvokeBehaviourNetworkDespawn() (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.7.1/Runtime/Core/NetworkObject.cs:1248)
Unity.Netcode.NetworkSpawnManager:OnDespawnObject(NetworkObject, Boolean) (at

long yew
#

How to play sounds to all clients? As for now I just play sounds locally and playing sounds using Rpc is one of the methods that I came up and actally working but is it a good practice?

abstract copper
#

(assuming the sounds don't matter too much and are sent quite often, unreliable RPC is the way to go)

#

but as with everything in programming, it really depends

long yew
#

Unreliable rpc. Whats the diffrence

#

I know how to code it and how code works

#

But I dont know how Reliability works

#

"This means they're guaranteed to be received and executed on the remote side" that doesnt explain to much

abstract copper
#

you should probably do some research on it, unreliable RPCs are significantly cheaper to send, but the tradeoff is that they don't always arrive

#

if the packet gets dropped, it will not attempt a resend

#

reliable RPCs will ensure that they arrive at some point, even if they get dropped

#

it will resend it

long yew
#

So that means sometimes with poor connection it may happen that I wont hear another player shooting for example?

abstract copper
#

yes

long yew
#

Ok thanks

modest mantle
#

How to create server browser for Game Server Hosting?

normal bluff
#

Is there a plugin or script I can use to expose all the values of every network variable that I’ve set?

I’m a visual person and I’d like to actually SEE the values in editor

neat veldt
#

The only easy solution is probably to just make a serialized field and copy the value of the network variable into the field in Update

sharp axle
normal bluff
normal bluff
sharp axle
earnest hinge
#

I have a SpaceshipMovement script that I would like to be able to be controlled by different players, meaning that based on something like a 'currentPilotId' variable or through other means, the script could perform its functionality on the spaceship rigidbody based on keyboard inputs from a chosen client or host. How would you go about making something like this?

sharp axle
earnest hinge
#

@sharp axle NGO

sharp axle
earnest hinge
#

What's the difference and do you recommend a specific one?

sharp axle
earnest hinge
#

Could I just change ownership of movement script throughout the game? @sharp axle e.g. when new player is piloting

earnest hinge
#

Ok thanks a lot for the advice, with being new to multiplayer this is very helpful

frail arrow
#

I have 0 idea what I am doing wrong. I have tried using localplayer instead but I got the same result

abstract copper
#

isOwner and IsOwner are very different things

frail arrow
#

You are so right I feel extremely stupid 😭

cedar belfry
#

Right after pulling my project with free download PlasticSCM, my NetworkManager looks like this. I need to run the scene, stop the scene, run cm update with PlasticSCM, change scenes in the editor, and go back to the original scene, then it gets populated

nocturne vapor
#

if you can replicate this, I would recommend opening up a support ticket, as this isn't how it is supossed to go

hushed wing
#

Hey my unity project is working over public ip/port forwarding. Can i just upload it to itch.io as a webgl build now and that should connect to my server the same as .exe does?

Ive configured WSS and SSL

nocturne vapor
compact bison
#

Hi, I’m hoping to share a gameobject transform (for example), with extremely low latency on a local network. I just tried in a project we have here using Mirror and there was quite noticeable lag. What is the way to achieve the lowest possible latency over LAN? 🙏

teal cedar
#
GitHub

A Matchmaking with Multiplay Unity example project. Implements the Unity Matchmaking and Multiplay SDK to create an end to end matchmaking game experience. - GitHub - Unity-Technologies/com.unity.s...

📥Get the Source Code📥
https://www.patreon.com/posts/82134830

If you liked this video please like and subscribe as it helps me a lot, and consider joining my Patreon or becoming a YouTube Member :)

►Check out the Previous Video
The Ultimate Multiplayer Tutorial for Unity - Netcode for GameObjects
https://youtu.be/swIM2z6Foxk

⚙️ Set Up ⚙️
►Mul...

▶ Play video
compact bison
#

Thanks I’ll look into that. I made someone using default Unity stuff about ten years ago, and over wired lab it still had significant lag. Is there any differences between different services, Unity inbuilt, mirror, photon, fishnet etc?

compact bison
#

Ah right 😅

tiny kraken
#

How can I teleport all players to a position with NGO? I made it so that when a player touches something, all players are supposed to teleport to a specific location with a serverrpc that calls a clientrpc. This only calls a single player to teleport tho, but it doesnt seem to work every time? and sometimes the player colliding with the trigger teleports back and forth on the other player's screen, as if they are going to the new location and back immediately (it's P2P so one player is host)

main swan
#

Hi - I have developed a game and am testing it, and my co-developers have asked me to rent a server to test out some bugs. It is quite expensive, and I have a fast PC sitting around doing nothing, so I thought i would just set up that PC as the server and leave it on all the time. I've used SteamCMD to install my own app to the local machine and followed all the same instructions that an external hosting provider gives for setting up servers, but they all stop helping at the point where they say "now go download the CSGO server software". Obviously i'm not installing counterstrike and my game does not have its own self installing server software, so i have a vague idea that i must create my own server config file etc, but i cant find any documentation on how to do so

icy flint
#

Hey I have a quite complicated project going on.
We are currently building a PoC for a School Project, it involves a very basic FPS shooter with the whole multiplayer and backend being doing in Java and communication is done using gRPC (the assignment itself was around java and gRPC, and we wanted to make a game with it).

We already implemented the authentication and that worked great, currently this is what's happening:
User starts the game, the Login Scene is visible.
User Logs in and lands in the MainMenu Scene.
User Presses on the Play button and lands on the MP_Browser Scene, which is just a ServerList basically.

Now here comes the tricky part, when the user finds a server he likes and presses join a few things should happen:

  1. The Code will send a ServerDetailsRequest to the specified server, this will return the Netty Port. The Netty Port is used for the websocket that's purpose it is to receive and send data bidirectionally (movement, shooting etc.)
  2. it will send a JoinServerRequest to the specified server that has 2 different outcomes:
    Outcome 1. The Server responds with success=true and message=AOK - The User is not banned and Server has sufficient slots free for the User.
    Outcome 2. The Server responds with success=false and a message - This means something is preventing the user to join, this could be that the server is full or the user was banned from this particular server.

Now we have a couple of questions on how to proceed:

  1. is Websocket the way to go? if so what data should be transmitted and how, and if not what are the recommended alternatives?

  2. How should I handle the loading? should I keep the Player in the MP_Browser Scene and just show a canvas with some loading text? or should I do something else?

  3. How do I actually do the Movement and stuff? The question is a bit difficult, but basically how would transmitting and receveiving movement updates work?
    This is what I thought how it might work:
    I join a lobby and start moving, on each move the Client sends a message to the Server saying "Hey I just moved to these coordinates".
    The Server then compares them to the previous coords to make sure he doesn't suddenly appear on the other side of the map.
    If everything appears to be fine, the Server broadcasts those coordinates to all connected players and that will cause the characters to move?
    We have a free Humanoid RPG Character from the asset store that has animations, how would we move the player from coordinate to coordinate without them just teleporting around?

  4. what about bullets and hits? How would I transmit shooting and how would I check if the player actually got hit?

Thanks for reading and I hope someone might be able to help

PS: Feel free to @ at any point

dark finch
#

From performance to architecture to server availability to player counts, to latency, etc

compact bison
#

Thanks. I just want the lowest latency solution for up to 10 people in the same physical space in VR

dark finch
#

For a long time, most network service providers would also provide many variants. As a multoplayer server for an RTS vs FPS etc has a lot of difference in requirements

compact bison
#

The server as authoritative source of truth, clients syncing to that

#

Security/cheating etc. no issue

dark finch
#

Yup that's one way to do it

compact bison
#

But given that scenario, which networking stack/system would be a wise choice?

dark finch
#

Rather that's a pretty common structure with any of them

#

But in short, for VR games, we almost entirely use photon. I think it mostly comes down to preference and comfort and effort

#

It's the best documented, most battle tested and longest supported IMHO.

tiny kraken
#

Why do I get Exception: Teleporting on non-authoritative side is not allowed!? I am running ClientNetworkTransform.Teleport() in a ServerRpc method, is that not authoritative?

urban hawk
#

Hi, I've got a question

public void DrawCardsServerRpc(ulong clientId, int numberOfCards)
{
    [... code]
            zoneManager.MoveCardServerRpc(cardId, ZoneType.Deck, ZoneType.Hand, clientId);
        
    }
}```

This serverrpc calls a serverrpc on another object (because the movecard function is a serverrpc clients can call directly so I just made it use the same method). 

I've heard a serverrpc can only be called by the client, but it seems to work fine here, it does that it's supposed to. Should I be worried about having it set up like this?
sharp axle
sharp axle
urban hawk
sharp axle
#

Yea. Unless you have reason for clients to initiate a card move on their own. It should probably only be handled by the server

urban hawk
#

Alright yeah makes sense thank you!

tiny kraken
sharp axle
tiny kraken
#

I’ll try that tho thank you 🙏

sharp axle
tiny kraken
sharp axle
tiny kraken
#

Ahhhhhh I see, thank you so much oml ive been so confused but I guess I had the wrong idea in the first place

icy flint
hushed wing
#

Anyone pro at webgl setup? I just need to get it uploaded somewhere for free to test. I have a dedicated server that works flawlessless with .exe on different wans

frigid bloom
#

hey everyone. i'm making a multiplayer fps, following the tutorial by "bananadev2". im just here to see if anyone would be kind enough to walk me through how i can set it up that when a room is created or joined, it puts you in another scene

#

im open to a vc call so i can screen share and i can learn as im newer to the photon stuff

nocturne vapor
#

this obviously need to be included:
using UnityEngine.SceneManagement;

icy flint
#

Hey quick question,
what's the best way to transmit movement to the gameserver and then to all the other players and how do I trigger walking animations when the player receives a movement update for other players

#

sounds very confusing xD
so I want to update all other players when Player A moves.
Whats the best way to tell the Gameserver that Player A moved, and how do I tell Players B-E "Hey Player A just moved, from xyz to xyz" and then trigger the walking animation fro Player A

nocturne vapor
icy flint
sharp axle
tiny kraken
# sharp axle Depending on what you code the RPCs to do yea. The network transforms use networ...

sorry that im back but it still doesnt seem to work for me, am I still dumb? Currently it kind of works but it always only sends over the client, not the client+host player.
Here is the basis of what im doing:

This

    [ServerRpc(RequireOwnership = false)]
    public void PlayerDeathServerRpc()
        foreach (GameObject player in players)
        {
            SCR_First_Person_Controller cntr = player.GetComponent<SCR_First_Person_Controller>();
            cntr.PlayerDeathClientRpc();
        }

And here is the other one

    [ClientRpc()]
    public void PlayerDeathClientRpc() 
    {
        if (!IsOwner)
            return;

        ClientNetworkTransform cnt = GetComponent<ClientNetworkTransform>();
        cnt.Interpolate = false;
        cnt.Teleport(new Vector3(0, 1, 0), Quaternion.identity, transform.localScale);
        cnt.Interpolate = true;
    }

again apologies if it's too much of a bother but I just dont get it

icy flint
#

Synching Movement / Anims

patent iris
#

Hi all, so I am dealing with an issue of "jitter" for clients. This is because I am allowing the client to move immediately on their end, and then when the server is done processing it's moving the client again.

Basically client moves say two steps, but because of latency the serer will move the client back one step once it sends positon to client.

How else can I get the player objects to move on the server and be visible to clients, because cleary this isn't the right approach

surreal jungle
#

does anyone have a recommendation for a good free or cheap example or package for a first person character controller using Netcode for GameObjects? The starter asset works okay but I'm looking for some examples of adding in animations from a first person perspective with a networked controller

south palm
#

I'm getting this error when I upload the newest build to my website
RangeError: maximum call stack size exceeded
at invoke_ii (http:mywebsite.com/Build
web_build.framework.js.gz:3:371759)
at wasm://wasm/04d1fa46:wasm-function[5506]:0x18a4dc
any idea what's happening here or how to fix it?

#

the build works fine connecting to the server from the editor

#

but as soon as I upload it to the website and open it in chrome it throws this during loading

sharp axle
patent iris
sharp axle
patent iris
# sharp axle Lerping to the latest position should work

Setting transform.position via a ClientRPC called by server is doing two things for me :

  1. Allowing all clients to see other clients and host movements (good)
  2. Causing jitter, since the client moves locally and then is reupdated by the server RPC.

How do I get rid of 2 without getting rid of 1 also? Right now if I remove tranform.position setting via ClientRPC called by server, it no longer does 1 or 2, so clients aren't seeing anything on their end

patent iris
normal bluff
#

How do i check if im already in a lobby? I've been trying to use ``await LobbyService.Instance.GetJoinedLobbiesAsync();

frigid bloom
nocturne vapor
frigid bloom
#

i guess a better question would be, if i have the map select and i have the connected users connect to the room and then get switched to the scene, would that work?

#

okay

nocturne vapor
frigid bloom
nocturne vapor
frigid bloom
#

im making a multiplayer fps. would you have any tips on the best way to go about it?

nocturne vapor
# frigid bloom im making a multiplayer fps. would you have any tips on the best way to go about...

prototype, get your stuff running and failing as fast as possible, with as much as possbile done.
you have later time for refinement.
This is iterative engineering and a technique I use for various things like video scripts, writing code, game features, solving any complicated problem, ...

if you mean the network side tho:
get it running with client authority and if that works start working on server authority you want to use client side prediction for that, idk if photon includes that per default ngo does not

frigid bloom
#

sick. i appreciate it

tiny kraken
#

can someone tell me, in a dumbed down version, the steps to teleport all players in a p2p server with NGO? i tried a serverrpc that loops through all players and calls a clientrpc in them but i cant seem to get it right...

nocturne vapor
#

if not do everything in the server rpc not the client rpc

tulip thorn
#

Are there any developers using Vivox?

How would you do it?

Hello 🙂

All players join a Normal 3D channel
All players join a 2D channel

Then the players join the map, I switch transmissionMode to single on the 3D channel

Players can talk in a walky talky,
I then switch transmissionMode between single on 3D Normal and All so that it speaks on 3D Normal and 2D Talky

Players can enter a dead state while remaining on the map
When they are dead they can talk to each other and hear the living but no longer communicate with the living.
They can hear the living regardless of the position (so 2D channel) but if the living players are on single 3D Normal it doesn't work
So all players would have to be on a common channel at the same time.
Let living players have the volume of this channel set to 0 (inactive)
And for the dead players to set the volume of this channel to 1 (active)

So switching Transmission mode to single or all does not work, since if the players are on single they will not transmit on the common channel
In my opinion it would be necessary to be able to play with the volume of a channel or the volume of a player in a channel but the mute unmute systems are general to all channels
Is this possible?

crude hamlet
tulip thorn
#

Sorry it's not really a recommendation it's more the logic that I suppose but I don't know how to do it
add players in a 3d and 2d channel and communicate either in 3d or 2d in the talky (without effects) it's good
But I don't understand the logic so that once dead I can hear all the players but only communicate with those who are dead.

sharp axle
tulip thorn
#

I try to schematize

Player 1
2d talky channel
positional channel
Player 2
2d talky channel
positional channel
Player 3
2d talky channel
positional channel

in game

Player 3 speak talky (transmit audio to all)
(Player 3 speak on talky 2d and positional 3d)
Player 1 & 2 hear player 3 non positionnal
Next
Player 2 is dead
player 2 speak dead 2d channel
how player 2 can hear player 1 & 3 2d channel if player 1 & 3 speak since 3d channel?
Player 2 can only hear player 1 & 3 if player 1 & 3 speak in talky?

but I would like to know if it is possible for player 2 to hear player 1 and 3 even if they do not speak on the talky
Maybe with audio tap but I haven't quite figured out how to use them yet.

chrome thicket
#

I am searching for any people that might interested in making an MMORPG with a custom multiplayer solution DM me if you want.

long yew
#
[ClientRpc]
void DestroyClientRpc()
{
    transform.SetParent(myParent);
    Destroy(gameObject.GetComponent<NetworkRigidbody>());
    Destroy(gameObject.GetComponent<NetworkTransform>());
    transform.localPosition = Vector3.zero;
    transform.localRotation = Quaternion.identity;
    gameObject.SetActive(false);
}
#

I have this simple script

#

I have to destroy NetworkTransform

#

And on host it works perfectly fine but on the client it doesnt because it says thath NetworkRigidibody require NetworkTransform

#

And that means that there is a delay for destroying component and I wonder does the do while is a good fix?

#

I mean should I use do while in rpc

fervent crescent
#

Hey Together i'm using Netcode für GameObjects and can't Find anything helpful about the following Error. I'm getting it after using the Update() to move something the whole time. Can someone Tell me more?

[Netcode] Deferred messages were received for a trigger of type OnSpawn with key 120, but that trigger was not received within within 1 second(s).

radiant harness
#

How viable would a networking system like this work?

#

Assuming the "inputs" are just strings of keyboard stuff

radiant harness
#

What I want is basically, the host client runs the vehicles, npcs, etc, while it shares inputs of itself to other clients, and those in between

#

Kinda peer-to-peer

#

Well, I think I just reinvented the wheel-

#

Well, more like "rediscovered" the wheel

nocturne vapor
#

Or havs I misunderstood what you want to achieve

sharp axle
sharp axle
normal bluff
#

I am getting this error:

Unity.Netcode.NotListeningException: NetworkManager is not listening, start a server or host before spawning objects

From this code:

    {
        if(!changes.LobbyDeleted)
            changes.ApplyToLobby(newLobby);

        if( newLobby.Players.Count > 1 )
        {
            StartRoomClientRPC();

            foreach (Player j in newLobby.Players)
            {
                GameObject listInfo = Instantiate(playerListInfo, playerList.transform);
                listInfo.GetComponentInChildren<TMP_Text>().text = j.Data["PlayerName"].Value;
                listInfo.GetComponent<NetworkObject>().Spawn();
            };
        }
    }```

Any idea whats going on? This code runs after I have already joined a lobby
#

@stiff charm

fervent crescent
# sharp axle Update happens before network objects have been spawned. You'll need to wait unt...

Thank you for your answer!

I think it's due to a circling ball that I added around the player. This message only appears on the host. I suspect it's trying to damage the opponent before they spawn. Since you instantiate first and then spawn.

I'm currently trying to work around this with the 2nd if, but it's not working. Do you have any idea what could be used? I'm very sure it's because of the damaging part, without the code, the error message doesn't come (which surprises me, since the other weapon in my Game works similarly)

I think it has something to do with this if not blocking it: if (enemy == null || !enemy.NetworkObject.IsSpawned) return;

private void OnTriggerEnter2D(Collider2D collision)
{
if (!IsOwner) return;
if (collision.TryGetComponent(out Enemy enemy))
{
if (enemy == null || !enemy.NetworkObject.IsSpawned) return;

PlayerStats playerStats = Player.Instance.GetComponent<PlayerStats>();
float damage = calculateDamage();
enemy.TakeDamageServerRpc(Convert.ToInt32(damage));

}
}

sharp axle
sharp axle
fervent crescent
hushed wing
#

Hey guys, what SSL format does unity support. if its PFX then how the heck do iconvert my .pem and .key into a valid format?

tough thorn
#

anyone know what this eror is?
TlsException: Failed to read data to TLS context - error code: UNITYTLS_INVALID_ARGUMENT
got it on my server side when trying to call ReadAsync from an sslstream

fervent crescent
#

I'm still having the following Error and no idea how to fix this, tryd for hours now. It only happens when i try to despawn enemys after they get 0 Healthpoints.

Error: [Netcode] Deferred messages were received for a trigger of type OnSpawn with key 120, but that trigger was not received within within 1 second(s).

No Error if i don't do this: this.NetworkObject.Despawn(true);

sharp axle
fervent crescent
tiny kraken
twin basalt
#

In Unity Netcode, I am able to set the NetworkVariable HostID when I am the host.
However, it seems that I cannot set the NetworkVariable ClientID when I am the client.
Essentially, I want to set a string (ClientID) for the host from the client side.
Can someone provide guidance or help me with this?

nocturne vapor
#

call a serverrpc, with the clientid as an arg and that it that way

sharp axle
patent iris
#

Hi, I am running into an issue where positions appear different on server / clients. Two different clients on left, and server on the right. What could cause positions to look different ?

#

I haven't implemented Server Reconciliation yet, could that possibly be why? Perhaps they aren't in line with the server?

gray pond
wanton scroll
#

What would be the proper way to synch a VR avatar using Netcode for gameObject and keeping it server authoritative?

sharp axle
wanton scroll
#

Well having the local rig sending it's positions to the server means it's no longer authoritative. I already made a test with a Client Network Transform and it works.

sharp axle
wanton scroll
#

well yes, the more I think about it the more it seems that a VR multiplayer game can not be server authorative

sharp axle
#

Even with server authority the clients still have to send it's inputs. It's just that for VR those inputs are positions

cunning quail
#

What are the major differences between photon and fishnet? I'm thinking about getting into multiplayer and I see a lot of talk about these two, what would you recomend? (For now Im just planning a simple create/join lobby game, but it would be cool if the tool would let me scale the project in the future, like dedicated servers or smt)

glad marlin
#

hey, so i have a problem that i think is easy to solve but i cant seem to find a solution for it. i have scrolled for about 3 hours now and still cant find it. the problem that i am having is that i have 2 players join a room and loading the scene. everything goes perfect there. now i have 2 players in the same scene and the master client can see the 2nd player, however the 2nd player cant see the master player because the master client has been instantiated before he joined. maby somebody here can help me? i already asked in the photon server but dont get a response there so i thought maby somebody here knows something about photon.

spring crane
#

PUN should instantiate all networked objects to every client. Make sure you are using PUN to instantiate objects.

orchid fractal
#

How do I get to this page???

austere harness
#

Question about Network Manager and Unity Transport - when started as a host, what ip:port does the program listen to for connection requests from clients?

#

When Allow Remote Connections is enabled

#

I'm trying to implement a Network Discovery system where the host device gets all clients awaiting a connection, then on user input orders one of the clients to connect to it. My problem is, I can't figure out how to make the client connect to a specific host.

GitHub

Community contributions to Unity Multiplayer Networking products and services. - Unity-Technologies/multiplayer-community-contributions

austere harness
#

I found this, but I don't really understand the difference between the remote adress and listenAddress, does setting the listenAddress matter when connecting remote?

austere harness
#

Figured it out, nvm. Turns out i just needed to use the ip of the host with the port of the Unity Transport

tepid bane
#

What is the best solution right now for multiplayer where one player is host and up to 8 players join? And if using DOTS I assume the only choice is Netcode for entities?

sharp axle
rich basalt
#

Does anybody have a good tutorial to start with netcode and relay from zero. I can only find some where they use a template and integrate stuff in there but I want to umderstand it from zero that i can implement it in my game

sharp axle
# rich basalt Does anybody have a good tutorial to start with netcode and relay from zero. I c...

Use this guide to learn how to create your first NGO project. It walks you through creating a simple Hello World project that implements the basic features of Netcode for GameObjects (NGO).

mint anvil
#

in unity lobbies, how do i check if i got kicked?
i kick them with LobbyService.Instance.RemovePlayerAsync(joinedLobby.Id, playerToKick.Id);
but how do i for example run a function on them to leave the lobby screen

dense eagle
#

i have some question, am i able to make LAN lobbies and LAN multiplayer with unity Netcode and Unity Services

sharp axle
# dense eagle i have some question, am i able to make LAN lobbies and LAN multiplayer with uni...

You can use them on a Lan but Unity Services require Internet access. You can use Network Discovery if you need something offline
https://github.com/Unity-Technologies/multiplayer-community-contributions/tree/main/com.community.netcode.extensions/Runtime/NetworkDiscovery

GitHub

Community contributions to Unity Multiplayer Networking products and services. - Unity-Technologies/multiplayer-community-contributions

dense eagle
#

thank you

dense eagle
#

i spend almost 2 hours on figuring this out...
i made jump button to canvas, but how to make it work? i added jump method in player controller script, but.. how to make jump button trigger this method? i make player controller get joystick whit FindAnyObjectByType and it works, but, what to do with button? i dont think that storing cavas inside of player is good idea...

mint anvil
#

Btw, i use unity lobbies, can i on top of that add steam? So i can join someone through steam?

sharp axle
sharp axle
dense eagle
#

wait.. THANK YOU SO MUCH!! i forgot about it...

crude hamlet
#

Sorry if this has been answered before, but I can't seem to find it here or a definitive answer through googling it..
I have a server/client game. However, if the person who is the server (creator of the session), leaves the game, everyone's networking just stops. Is it possible to pass the server-ship to the next available client connected, or do I HAVE to host a server version on unity cloud if I want to avoid this.

dense eagle
sharp axle
crude hamlet
#

Oh I see. So would you suggest it be easier to just use Cloud Multiplayer to host server on there?

sharp axle
crude hamlet
sharp axle
crude hamlet
#

no, but there is a monthly free amount they allow, no? all cloud services do?

teal cedar
crude hamlet
#

gotcha. got me worried there for a second 💀 😭

mint anvil
#

did anyone here make their own host migration for unity networking/relay?

teal cedar
#

How am I supposed to create dedicated servers?

#

Too hard 😭😞

sharp axle
teal cedar
#

Hello, I'm completely lost. How should the server handle multiple game modes? Unity multiplay and matchmaker

sharp axle
dense eagle
#

one more day... same problem...
i cant find any tutorial that teaches how to make mobile multiplayer game...
i made one, and it work good on pc, and i added jump button to canvas, all players are prefab, and its bad idea to put canvas into prefab cuz of multiple canvas and it will look weird, and, how to make jump button trigger function in player script?

teal cedar
# sharp axle The matchmaking payload can contain map and game mode data. So the server can lo...

Is it this? ```var players = new List<Player>
{
new Player("Player1", new Dictionary<string, object>())
};

// Set options for matchmaking
var options = new CreateTicketOptions(
"Default", // The name of the queue defined in the previous step,
new Dictionary<string, object>());

// Create ticket
var ticketResponse = await MatchmakerService.Instance.CreateTicketAsync(players, options);

// Print the created ticket id
Debug.Log(ticketResponse.Id);```

#

Those options

nocturne vapor
#

or just have the ui spereate from the player

dense eagle
#

okay ill try, thx

dense eagle
#

why im getting this error?

#

im getting it when i drag joystick on host

#

i fixed

#

no i didnt, it happen when there is more than 1 player

dense eagle
#

i fixed

vague grove
#

I heard that unity netcode for game objects (so unity multiplayer) was small scale, so that you couldt make a battle royale with 100 players, only a real game with 1-4 players, is that still the case?

fallow zenith
#

I'd expect most multiplayer systems to struggle with 100-player games

#

I'd suggest looking for benchmarks.

sharp axle
west sequoia
#

Guys do you know how can i start a client with an URI instead of an ip and a port on Netcode for GameObjects 1.6.0?
on Mirror i would do this

#

Because i need to connect to a proxy server for securing connection, otherwise it will throw this error: The page at 'https://test.....io/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://34.....90:9000/'. This request has been blocked; this endpoint must be available over WSS.

#

But on Netcode for gameobjects SetConnectionData only accept ip address and port or a NetworkEndPoint

#

I'm on WebGL

west sequoia
#

Or do you guys know an alternative to use a server proxy?

gentle drift
#

Heyo, I have a multiplayer game using Relay and Lobby services, I only have player hosted servers. The game works but after a little while the host timeouts and I get this error: [Lobby]: NetworkError, (16998). Message: Request timeout does anyone know how to troubleshoot this?

nocturne vapor
west sequoia
west sequoia
nocturne vapor
#

I have to admit I never tried to do this in c# tho

west sequoia
#

@nocturne vapor this is my transport settings, i tries to use http(s) o remove it entirely but it gaves me the same error

nocturne vapor
#

idk then honestly, currently I'm working mostly on other stuff not networking related
I also never worked with websockets, these were just ideas that immediatly came to my mind about this

west sequoia
#

well i think i will continue to work with mirror then and see where are the differences

#

@nocturne vapor Seems like Mirror is doing stuff with JS and the Uri it self

#

And this is the jslib function

    // fix for unity 2021 because unity bug in .jslib
    if (typeof Runtime === "undefined") {
        // if unity doesn't create Runtime, then make it here
        // dont ask why this works, just be happy that it does
        Runtime = {
            dynCall: dynCall
        }
    }

    const address = UTF8ToString(addressPtr);
    console.log("Connecting to " + address);
    // Create webSocket connection.
    webSocket = new WebSocket(address);
    webSocket.binaryType = 'arraybuffer';
    const index = SimpleWeb.AddNextSocket(webSocket);

    // Connection opened
    webSocket.addEventListener('open', function (event) {
        console.log("Connected to " + address);
        Runtime.dynCall('vi', openCallbackPtr, [index]);
    });
    webSocket.addEventListener('close', function (event) {
        console.log("Disconnected from " + address);
        Runtime.dynCall('vi', closeCallBackPtr, [index]);
    });

    // Listen for messages
    webSocket.addEventListener('message', function (event) {
        if (event.data instanceof ArrayBuffer) {
            // TODO dont alloc each time
            var array = new Uint8Array(event.data);
            var arrayLength = array.length;

            var bufferPtr = _malloc(arrayLength);
            var dataBuffer = new Uint8Array(HEAPU8.buffer, bufferPtr, arrayLength);
            dataBuffer.set(array);

            Runtime.dynCall('viii', messageCallbackPtr, [index, bufferPtr, arrayLength]);
            _free(bufferPtr);
        }
        else {
            console.error("message type not supported")
        }
    });

    webSocket.addEventListener('error', function (event) {
        console.error('Socket Error', event);

        Runtime.dynCall('vi', errorCallbackPtr, [index]);
    });

    return index;
}```
nocturne vapor
#

malloc, heap, Ptr?
it is wild to see that stuff used in a high level language, didn't even know js allowed memory allocation with malloc xD

wet spindle
#

Is there a way to have a Host have two active scenes but only see one at a time? The clients will also be able to jump back and forth between these scenes.

A simple way to put it would be, have two scenes, outside and inside.

Using Netcode For GameObjects

vocal bane
#

How can I spawn a player item as a prefab (that needs to be seen by other players) on the player under a gameobject inside the player that doesn't have a network object component.

#

Currently, I'm only able to set the parent of the players item to the player itself, with other objects needing a network object component to be a parent, yet I can't have nested network objects or I get errors.

vocal bane
sage tundra
#

is there anyone down to call? ye ik its weird but i really gotta figure out how camera works when spawning client.

#

im not sure. maybe the cinemachine gets overwritten by anotehr spawn or something

nocturne vapor
#

or just have a camera for the scene

sage tundra
#

what does this mean

merry wing
#

Is there an equivalent to OnNetworkObjectParentChanged, for children? ie: NGO's (grand+?)child had NGO added/removed beneath it.
I can't seem to find anything - am I missing something? Or would my alternative just be to manually bubble-up from the NGO that was reparented? (If so, any way to get the previous-parent? Or also have to manually cache that?)

rigid niche
#
    private void PlayerTransform_ClientRpc(Vector3 pos)
    {
        try
        {
            Debug.Log("Im trying...");
            GameObject.FindGameObjectWithTag("NetworkPlayer").transform.position = pos;
        }
        catch (System.Exception e)
        {
            Debug.Log(e);
        }
    }```

Why doesn't this work?
#

It doesnt give of any errors. It just doesnt move a player

#

Im also getting the "Im trying..." in console

mint anvil
#

with unity lobbies, in the lobby every player has a faction and an icon for it, how would i update the icon for all players?

rigid niche
# mint anvil with unity lobbies, in the lobby every player has a faction and an icon for it, ...

https://www.youtube.com/watch?v=-KDlEBfCBiU
At the end of this video you have him go over everything he offers in his template, that you can download. That's what I used as a base. I opened it in a second project and more or less copied and tried to understand what he was writing there. That includes changing profile pictures. What basically is what you want. You can take that as a guideline, if you want.

❤ Watch my FREE Complete Multiplayer Course https://www.youtube.com/watch?v=7glCsF9fv3s
✅ Learn more about Lobby and UGS https://on.unity.com/3XdKEd7
🌍 Get the Project Files https://unitycodemonkey.com/video.php?v=-KDlEBfCBiU
📝 Lobby Docs https://on.unity.com/3OtC0Du
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to mak...

▶ Play video
rich basalt
#

How does Scene Managment with the Network Manager work, I have everything set up in the Main Menu scene and now i want to switch scenes and then spawn the player prefab in there, but the Network manager keeps spawning it in the current scene. How can I spawn it in the Game Scene?

sharp axle
rich basalt
#

no idea what that is

#

ah ok I see yeah that could solve the problem, but then the prefab wouldnt be in the right scene

sharp axle
# rich basalt no idea what that is

The automatic player prefab will spawn immediately when the client connects just before the scene changes. easiest thing would be to disable the player renderer until the game is actually ready to start

rich basalt
#

But again then the prefab wouldnt be in the right scene

#

Of course if it were all in one scene that would work flawlessly but its not

sharp axle
rich basalt
#

thank you

mental pond
#

Hey, anyone know what could be the reason of the jittering?

#

I'm Lerping the position by the elapsed delta since next position

#

var t = elapsedPosition / movementTick;
playerTwo.Position = lastPosition.Lerp(getNextPosition(), (float)t);

#

tick is 60 (60 times per second) and movementTick is 60/1000 which is 0.06

#

When I'm not moving it's clean, when I move along with player, player jittering.

rich basalt
#

It could be your camera... Do you transform it in LateUpdate()?

mental pond
#

Yes camera is in Late

gray pond
west sequoia
#

I was only trying the netcode for gameobjects solutions just to play around

gray pond
west sequoia
mental pond
#

Anyone can help with my problem higher can offer money for help dm me

modern vessel
#

I've tried using the photon transform view classic but it doesn't fix it

#

and yes, i have ticked rotation box for all of them

west sequoia
#

@mental pond Did you tried to make a build and see if the problem persists?

#

@mental pond Did you tried using slerp instead of lerp?

mental pond
haughty crane
#

netcode or photon?

mental pond
#

my own networking

oblique jolt
#

hey, i set it all up and its working great (GITHUB)

how does it actually work with others? if for instance im doing a fps controller and adding a gameobject etc., and my friend is adding a game object with the ability to only jump
how would that work, would it even?
or u just gotta communicate EVERYTHING
and how do we share small updates with each other (for example im adding a door that works, he simultaniously adds sth else)

#

and do i have to constantly download small changes the other person has made and add them back into the fuqin folder?

#

this is horrible

gleaming bloom
stiff zinc
#

Question on Netcode for Gameobjects:

Situation: Say that the server locally updates the state of the game on each network tick, then sends out rpc calls to all clients with the changes so that they can update their own local state. This entire state update/rpc invocation happens in the same frame (on the server).

Question: Will all these rpc calls be bundled into a message at the end of the frame and then send out? Or will it be sending every rpc separately? If separate, is there any issue here with performance, where I should instead combine into a few big rpcs? If big, don't I have to worry about payload size?

I've found a github post saying

NGO sends all pending out bound messages for any given frame as a single batched message.

But i'm not sure whether this also includes rpc calls or not.

source: https://github.com/Unity-Technologies/com.unity.multiplayer.docs/issues/1111

GitHub

Open Source documentation for Unity Multiplayer, which includes Netcode for GameObjects, the Unity Transport Package, Multiplayer Tools and Educational references and Sample Games such as Boss Room...

haughty crane
#

is unity lobby enough for a 2d turn game?

#

multiplayer? or i need something more complex

austere yacht
normal bluff
#

What am I doing wrong that my RPC will not trigger on any clients?

    {
        if(!changes.LobbyDeleted)
        {
            changes.ApplyToLobby(newLobby);
        }
            
        if( newLobby.Players.Count > 1 && IsHost)
        {
            OpenLobbyClientRpc();
        }
    }

[ClientRpc]
    private void OpenLobbyClientRpc()
    {
        foreach (Player j in newLobby.Players)
        {
            GameObject listInfo = Instantiate(playerListInfo, playerList.transform);
            listInfo.GetComponentInChildren<TMP_Text>().text = j.Data["PlayerName"].Value;
            //listInfo.GetComponent<NetworkObject>().Spawn();
        };
    }```
normal bluff
#

If anyone can please assist. I would like to know what the proper way to do an RPC is. I followed the Unity documentation and it has yet to work once. I was using Photon before this and it was quite easy in comparison.

normal bluff
#

Please?

sharp axle
normal bluff
#

The RPC simply won’t work and I’m at a loss for why.

I can’t continue work unless I understand why. Is there a stipulation besides both players being in the same lobby that I am missing

#

Sorry I’m so lost. I’ve been trying to get the RPC to work for weeks now. It was so easy with photon

normal bluff
#

I contacted them and they said they will revert it in 1.2 but it’s not out yet

sharp axle
normal bluff
sharp axle
#

The client should already know when it joins the lobby itself

normal bluff
sharp axle
#

The host is the server

normal bluff
#

Does a lobby automatically have a host when its created? I cant fathom why this code is not being run by the host

sharp axle
#

That not usually the case when working with lobbies

normal bluff
#

So i have to actually start host?

#

Wow...

sharp axle
#

Yep thats how RPCs know where so send messages

normal bluff
#

wtf

#

I didnt see that in any of the documentation

#

Do you have an example code i can see?

sharp axle
#

Lobbies are a completely separate service from NGO

normal bluff
#

God... weeks of time Ive been trying to figure this out

normal bluff
sharp axle
#

Unity Lobbies can be used with any network framework if you want

#

Do you need Lobby samples or RPC samples?

normal bluff
#

Im so sorry to ask this. I'm so confused so i am just going to ask in the absolute most basic, child-like means.

I thought once two players joined a lobby, they were now in a 'game' together. If thats not the case, can you explain in baby terms (or point me where) how i get the two players in the same place to start sending RPC's

sharp axle
#

With Relay you would save the relay join code into the Lobby Data then the clients can use that to join the game

normal bluff
#

I see. So the lobby stores the data but relay is what connects them.

#

Thank you VERY VERY much. This was definitely the part ive been missing. I appreciate it so much.

#

Have a wonderful rest of your day/holiday

normal bluff
sharp axle
sharp axle
normal bluff
sharp axle
# haughty crane is unity lobby enough for a 2d turn game?

Lobby is not meant to be used like that. If you don't need a real time connection to the other players then you can use cloud code
https://github.com/Unity-Technologies/com.unity.services.samples.multiplayer-chess-cloud-code/tree/main

GitHub

Contribute to Unity-Technologies/com.unity.services.samples.multiplayer-chess-cloud-code development by creating an account on GitHub.

tawdry night
#

does some1 have a idea how i can make a seprate inventory for every player i am using netcode

earnest hinge
#

How do I change a client's position in a server RPC on another object? I'm using NGO and the player has a ClientNetworkTransform attached to it

sharp axle
earnest hinge
# tawdry night Can u explain a little more

I have a server RPC on a "spaceship" object where I want to change the player's position based off a playerSpawnPos variable. Preferably I would like to change the player's local position but for now I'm trying to change transform.position instead

[ServerRpc(RequireOwnership = false)] public void AddPlayerServerRpc(NetworkObjectReference playerReference) { var playerObject = (GameObject)playerReference; var player = playerObject.transform; player.parent = playerGroup; player.GetComponent<ClientNetworkTransform>().position = playerSpawnPos; }

sharp axle
haughty crane
#

almost

sharp axle
haughty crane
#

does it have like a video tutorial?

#

❤ Watch my FREE Complete Multiplayer Course https://www.youtube.com/watch?v=7glCsF9fv3s
✅ Learn more about Lobby and UGS https://on.unity.com/3XdKEd7
🌍 Get the Project Files https://unitycodemonkey.com/video.php?v=-KDlEBfCBiU
📝 Lobby Docs https://on.unity.com/3OtC0Du
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to mak...

▶ Play video
#

lobby and ugs?

sharp axle
haughty crane
#

do you know any tutorial for them?

toxic spade
#
 [ServerRpc]
private void DestroyServerRpc(GameObject gameobject, float time)
{
    Destroy(gameobject, time);
}```  i get this error 
Don't know how to serialize UnityEngine.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.
sharp axle
sharp axle
toxic spade
#

why cant i get the animator and rb and why does the rb on the client get set to kinematic

public override void OnNetworkSpawn()
{
    if (!IsOwner) return;
    SpawnServerRpc();


    rb = GetComponent<Rigidbody2D>();
    animator = transform.GetChild(0).GetComponent<Animator>();
    weapon = 0;
    
}

[ServerRpc]
private void SpawnServerRpc()
{
    var ch = Instantiate(character.Prf, transform);
    
    ch.GetComponent<NetworkObject>().Spawn(true);
    ch.transform.parent = transform;
    

}```
sharp axle
tawdry night
sour fiber
#

Hello, I have a code block as follows.
Everything is working correctly but "ConnectionApprovalCallback" is never called, what could be the reason?

NetworkManager.OnClientConnectedCallback += OnClientConnectedCallback;
NetworkManager.OnClientDisconnectCallback += OnClientDisconnectCallback;
NetworkManager.OnServerStarted += OnServerStarted;
NetworkManager.ConnectionApprovalCallback += ApprovalCheck;
NetworkManager.OnTransportFailure += OnTransportFailure;
NetworkManager.OnServerStopped += OnServerStopped;

merry wing
merry wing
#

[Edit: Resolved]
Having a curious issue, myself. I'm not sure if I'm doing something wrong~~, or if I found a "feature" or a "bug". (?)~~

Create a prefab NGO with NetworkTransform using "In Local Space".
A.1) Start a Host.
A.2) Spawn prefab "Root", "Child" and "Grandchild"
A.3) Parent accordingly.
A.4) Translate each so they're in any unique position.
B.1) Start a Client, connected to the Host.

Note: It is important that the Host dynamically spawns the NGO's during runtime (ie: not scene objects), and spawned before the client connects.

Expect: Client spawns 3 objects in the same hierarchy and position as the host.
Actual: Client spawns 3 objects in the same hierarchy, in a different position.

It looks to me as though the objects spawn on the client unparented using the host's 'local position' as the clients 'world position', then reparents the NGO using WorldPositionStays.
ie: clientNGO.position = hostNGO.localPosition~~ -- Which is blatantly incorrect.~~

I see in the docs that it does say NGO uses WorldPositionStays~~, but in this scenario that seems... wrong?~~

Interestingly - as soon as the host moves an NGO, it suddenly updates on the client to the correct position. So, once spawned, it translates correctly... it's just the initial spawn, before anything has moved, seems incorrect.

Edit: Solution: I missed replacing transform.SetParent(...) with ngo.TrySetParent(..., false)
Reparenting in editor or using transform.SetParent(), will equate to:
ngo.TrySetParent(..., true)
I needed to ensure every SetParent() was replaced with ngo.TrySetParent(..., false) for my situation.

sour fiber
sour fiber
merry wing
merry wing
versed rover
#

If I want to test my game with some somewhere else where do I put my public IP address? In Address or in Override Bind IP

sharp axle
versed rover
#

And Override Bind IP can stay empty?

sharp axle
haughty crane
#

this unity Cli its giving me a hard time

#

any idea why i can't deploy the chess sample ?

#

i added all the roles, in the service

sharp axle
haughty crane
#

i can't open the whole project

#

and i can't see the files

#

and i don't know to use it either

toxic spade
#

I mad an Multiplayer game and on my local network it works fine but i cant get it to work online i made a build with my public ip and send it to my friend set portforwarding for udp and tcp on my router and my firewall but he cant connect

mint anvil
#

(i was following a tutorial from codemonkey) so i am using unity lobbies and there is a limit for using it for free i think, but i pull the data every second, because i want to update the list of players the whole time so if someone does leave/join it immediately updates the list.

is there a better way to do it than this every second? (like a function that runs when something happens?)

            heartbeatTimer2 -= Time.deltaTime;
            if(heartbeatTimer2 < 0f)
            {
                previousPlayerCount = joinedLobby.Players.Count;
                Lobby lobby = await LobbyService.Instance.GetLobbyAsync(joinedLobby.Id);
                joinedLobby = lobby;
                previousLobbyName = joinedLobby.Name;
                float heartbeatTimerMax = 1;
                heartbeatTimer2 = heartbeatTimerMax;
            }

sage tundra
#

i cant spawn object on client side (this is a prop hunt game and another player is trying to turn into an object)

#

how do i tackle this? i dont even exactly know which part of my code is causing the problem

mint anvil
sage tundra
#

the LAN across device doesnt work. I also tried the ips in ipconfig and they dont work either

#

i mean which exactly do i even enter?

sharp axle
sage tundra
#

oh i see. in essence the host is connecting to itself and the client it connecting to host

sharp axle
sage tundra
#

doesnt seem to work

#

its supposed to be connecting to the IPV6 as client right?

sharp axle
mint anvil
sharp axle
normal bluff
#

Is this truly the shortest way to update a pre-existing player data?? Why is it so long?

        {
            UpdatePlayerOptions options = new UpdatePlayerOptions();
            options.Data = new Dictionary<string, PlayerDataObject>()
            {
                {
                    "existing data key", new PlayerDataObject(
                        visibility: PlayerDataObject.VisibilityOptions.Private,
                        value: "updated data value")
                }
            };

            string playerId = AuthenticationService.Instance.PlayerId;
            var lobby = await LobbyService.Instance.UpdatePlayerAsync("lobbyId", playerId, options);
        }
        catch (LobbyServiceException e)
        {
            Debug.Log(e);
        }```
hollow sleet
#

Hi, I would like to know how to open new scenes using the networkscene manager. I know, sounds simple. But I just didnt get it to work and it took me way too long for what it acutallly is.

I have this scene. One Host button and one join button. When I press the host button a new Lobby (using the Lobby service) gets generated and when somebody else presses the "join" button they join the lobby.

When one of the players presses the Startbutton I want both to get into the new scene.
How do I manage to do that?

normal bluff
hollow sleet
#

Evertime I execute my script this Error comes up:
NullReferenceException: Object reference not set to an instance of an object
StartGame.JoinScene () (at Assets/MyStuff/Scripts/Networking/StartGame.cs:10)
UnityEngine.Events.InvokableCall.Invoke () (at <17484a9af6b944dea5cd9be4dbb0da2c>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <17484a9af6b944dea5cd9be4dbb0da2c>:0)
UnityEngine.UI.Button.Press () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:530)

This is my script.

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

public class StartGame : MonoBehaviour
{
public void JoinScene()
{
NetworkManager.Singleton.SceneManager.LoadScene("Playground", LoadSceneMode.Single);
}
}

#

But I cant get the heck out of what exactly is missing here!

normal bluff
#

NullReferenceException: Object reference not set to an instance of an object

Something in your scene is null. Either the actual NetworkManager doesnt exist in the scene you are calling it from or the button is using "AddListener" but the button reference is null.

#

StartGame.JoinScene () (at Assets/MyStuff/Scripts/Networking/StartGame.cs:10)
Its the NetworkManager. It says line 10 and the only thing in the method that can be null is the NetworkManager

tawdry night
#

can some dm me bc i need help with a inventory i am stuck on it for 2 weeks it works in singleplayer but idk how to convert it to multiplayer

hollow sleet
#

Oh I may have realised something.
I hosted a lobby and all

    public async void CreateLobby()
    {
        
        try
        {
            string lobbyName = "MyLobby";
            int maxPlayers = 2;
            
            
            Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName, maxPlayers);
            
            hostLobby = lobby;
            
            Debug.Log("Created Lobby! "+ lobby.Name + "Available Slots: " + lobby.AvailableSlots +  "LobbyCode"+lobby.LobbyCode);
            
            
        
        }catch (LobbyServiceException LobbyError)
            {
                Debug.LogError(LobbyError);
            }
    }

But I think the network manager never really hosted the thing, you know?
NetworkManager.Singleton.StartHost();

Is this right? I have never worked with netcode before only with Pun2.

#

How exactly do I implement that, with my Lobby code? Im so confused

normal bluff
#

They give code examples too. Its so different from Photon and in my opinion too convoluted

orchid viper
#

Hello everyone!

Talking about the challenges for MMORPG games, the core is:

  • Network to handle with connections;
  • Database to handle with data;
  • Security to avoid hacks.

Right?

Just for test purposes and to understand better those environment I decided to use for network, Phonton 2 PUN, database Mongodb, and easy the structure/code, Fishnet.

I have some doubts about the update flow works. About to update data, what do you think? Update every specific moment (like each 1 ... 5 seconds? Only with events? Both?) How to avoid hack for those updates?

hollow sleet
normal bluff
#

Im just a little disappointed at how incredibly fractured Unity's solution is. Once you get it, i guess its easier but starting out was VERY very painful and even the documentation doesnt make it clear what parts you need and why

hollow sleet
#

I feel this. This is why I switched from Photon to netcode. Also having every service (Voice, Multiplayer, Accounts, Transactions, whatever) in this nice dashboard, it makes sense. But after over 22 Hours and no progress a part of me really wants to go back.

#

But thanks for the help! Maybe I'll stick with the Unity Services

normal bluff
hollow sleet
#

I appreciate! Have a good one

sharp axle
toxic spade
#
[ServerRpc]
private void AttackDamageServerRpc(float size, float range, float weponDamage, float weponKnockback, Vector2 direction, Vector2 knockbackDirection)
{
    knockbackDirection = new Vector2(knockbackDirection.x + (0.5f * transform.right.x), knockbackDirection.y + 0.5f);
    // so raycast doesnt hit player
    gameObject.GetComponent<Collider2D>().enabled = false;
    RaycastHit2D hit = Physics2D.CircleCast(transform.position, size, direction, range, hitmask);
    gameObject.GetComponent<Collider2D>().enabled = true;
    if (hit && hit.collider.gameObject != gameObject)
    {
        GameObject enemy = hit.collider.gameObject;
        if (enemy.GetComponent<EntityData>() != null)
        {
            enemy.GetComponent<EntityData>().RemoveHealth(weponDamage);
            float enemyhealth = enemy.GetComponent<EntityData>().health.Value;

            float knockback = 0;
            if (enemyhealth <= 10)
            {
                knockback = 30;
            }
            else
            {
                knockback = 2;
            }
            enemy.GetComponent<Rigidbody2D>().AddForce(knockbackDirection * knockback * weponKnockback, ForceMode2D.Impulse);
        }
    }


}``` it gets called in the update function but if the host attacks it adds the damage but not the force but on client it works
versed rover
#

If there is anyone here who uses Facepunch with Steam.
How do you do local testing with a second instance on the same pc?

For now I'm using the default Unity Transport for local testing or testing with my friends. But when I release the game on Steam I will use Facepunch Transport and Steam Matchmaking, but how can I test locally then, without uploading to steam updating the game on another pc with another Steam acc an then testing it? Do I need to switch between Unity and Facepunch Transport every time I want to test locally or want to Upload to steam. Or is there any way that I can use Facepunch Transport and Steam Matchmaking with one Steam Client on the PC but two Instances of the game?

tawdry night
versed rover
ruby latch
#

Hello, I'm planning a multiplayer project and could use some help from those with experience with Unity's Netcode for GameObjects.

The network will be true peer-to-peer. By that I mean that there is no specific host player. Every player is connected to each other. However, I've understood that Netcode for GameObjects requires one player to act as the host if I wanted to make a P2P game with it.

Is there a way around that? Is it possible for me to define each player as host? I would be using SteamNetworkingSockets with symmetric connect mode.

sharp axle
ruby latch
#

I use Steam's relay servers to hide the ips

normal bluff
#

Can you subscribe to the event of a network variable changing?

spiral frigate
#

I'm integrating photon pun to my FPS game but the problem is, the player prefab instantiated has the main camera as a child to it. so multiple cameras getting instantiated casues some weird stuff to happen like the post processing being stacked as well as the players not seeing their own camera but rather other players

#

how do i work around this

regal delta
#

All NetworkVariables have a OnValueChanged event you can subscribe to

spiral mirage
#

Photon Fusion 2:

I have an object in my scene with a script where FixedUpdateNetwork should be called, but it isn't. However, for player prefabs that are spawned when players join the game, FixedUpdateNetwork works fine. It seems to be an issue only with objects that are already in the scene before players join. Can anyone help me understand why this is happening?

public class MovingTarget : SimulationBehaviour
    {
        public float Speed = 20f;
        public float MaxX = 10;
        private float direction = 1f;

        public override void FixedUpdateNetwork()
        {
            Debug.Log("MovingTarget called!"); // This method never gets called

            var position = transform.position;
            position += direction * Runner.DeltaTime * Speed * Vector3.right;

            if (position.x >= MaxX || position.x <= -MaxX)
            {
                direction = -direction;
            }

            position.x = Mathf.Clamp(position.x, -MaxX, MaxX);
            transform.position = position;
        }
    }
#

It's NetworkObject should be correctly set up once the Host starts the game:

#

Found it... The class had to derive from NetworkBehaviour, not from SimulationBehaviour

warped pilot
#

Hello, I have a strange question. I'm fairly new to networking, but does Client Network Transform always refer to the GameObject or also to the Children ? Because I'm making a car racing game and had to add a ClientNetworkTransform to the tires.

normal bluff
#

Is it possible to start NetworkManager in offline mode so I can test stuff without worrying about Host and Client?

sharp axle
sharp axle
normal bluff
sharp axle
normal bluff
neon epoch
#

Hello!
is there a way to link Lobby players with their respective Netcode players? to read the PlayerDataObject

sharp axle
normal bluff
#
  if (networkTransport != null)
  {
       networkTransport.ProtocolType = UnityTransport.ProtocolType.UnityTransport;
  }```

This is as far as I've gotten. But i'm getting an error
sharp axle
normal bluff
#

Ah! thats genius. Im impressed you just knew that

#

This is what it's telling me. It seemed to accept the casting. It just doesnt like how im setting the value

sharp axle
#

networkTransport.ProtocolType should be networkTransport.Protocol

normal bluff
#

Says protocol is { get; } only

sharp axle
# normal bluff Says protocol is { get; } only

Figures it wouldn't be that easy. I guess you'll have to dig into how the Boss Room sample does it.
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/ConnectionManagement/ConnectionMethod.cs

GitHub

A small-scale cooperative game sample built on the new, Unity networking framework to teach developers about creating a similar multiplayer game. - Unity-Technologies/com.unity.multiplayer.samples....

tiny spear
#

hello guys, i want to create a rpg game (most like gta ) in multiplayer, i'm looking for the best way to make it without f3ck my wallet bcs i'm poor (i had a server), are any one know a free framework ?

sharp axle
tiny spear
sharp axle
#

i wouldn't recommend it though

#

You could also self host your own dedicated server

tiny spear
#

withoud the connection service sure

sharp axle
tiny spear
#

thx

sage tundra
#

I'm trying to spawn host as a hider and client as a seeker in a prop hunt game

#

now my player prefab is a hider

#

but spawning as a client i wanna prevent being spawned as a hider but as a seeker instead

#

how do i do that?

#

like i have it in my deafualt prefab list here

#

but i dont know where to start

sage tundra
#
    public override void OnNetworkSpawn()
    {
        if (IsServer) // Make sure we are on the server when spawning objects
        {
            GameObject chosenPrefab = hiderPrefab;
            GameObject spawnedObject = Instantiate(chosenPrefab, transform.position, Quaternion.identity);
            spawnedObject.GetComponent<NetworkObject>().Spawn(); // Spawn the object over the network

            Debug.Log(chosenPrefab);

            // Optionally set the parent of the spawned object
            spawnedObject.transform.SetParent(transform, true);
        }
        else if (!IsOwner)
        {
            GameObject chosenPrefab = seekerPrefab;
            GameObject spawnedObject = Instantiate(chosenPrefab, transform.position, Quaternion.identity);
            spawnedObject.GetComponent<NetworkObject>().Spawn(); // Spawn the object over the network

            Debug.Log(chosenPrefab);

            // Optionally set the parent of the spawned object
            spawnedObject.transform.SetParent(transform, true);
        }
    }
#

Spawning host as a Hider worked. but Spawning client as a seeker didnt

#

it didnt even reach the Debug Log

narrow cloak
#

so if i wanted to damage a player wiht a gun i know i need to send it thru the server first then the client, would i need to make a server script aswell as a script that sits on the player?

sharp axle
sharp axle
hushed hamlet
#

Is it possible to send custom udp packets? I'm using NetworkTransport#Send, but this causes unity to complain:

[Error  : Unity Log] [Netcode] Received a packet with an invalid Magic Value. Please report this to the Netcode for GameObjects team
```Is ``NetworkTransport#Send`` something that should only be used internally by unity? If I *am* allowed to use it, then what packet structure do I follow to make unity ok with it?
#

Hm, I think the issue is that my payload only includes the data that I want to send to the client.
The error message above comes from NetworkMessageManager#HandleIncomingData, which shows the packet structure that I should follow.
Still not sure if I'm supposed to avoid this way of sending packets completely though, but I'll probably try it anyways when I wake up tomorrow (unless someone suggests to do something else)

sharp axle
hushed hamlet
#

Ah that's disappointing. Thanks!

hushed hamlet
#

If i just want the fastest way to send data from server to client, is unreliable rpc too slow?
And what about using NetworkIdentity?

sharp axle
normal bluff
#

Is there a way for. client to spawn/instantiate on the network? If only the host can do it, how does a client tell the host which prefab to instantiate?

sharp axle
normal bluff
warped pilot
#

Hey Im reworking my Singleplayer Game. I have a follow camera script:

` [SerializeField] private ThirdPersonCameraController m_CameraController;
[SerializeField] private PlayerController m_PlayerController;

    private void Start()
    {
        m_JeepVisual.SpringsRestLength = m_Vehicle.Settings.SpringRestLength;
        m_JeepVisual.SteerAngle = m_Vehicle.Settings.SteerAngle;
        m_CameraController.FollowTarget = m_Vehicle.transform;
    }`
#

what is the best way that my camera is following the player ? because it spawns as prefab and i cant reference it

sour fiber
#

I have player class and I have variables such as color, side, coin. How can I initially set this information for each player object?

#

with using Unity.Netcode

hushed hamlet
neat veldt
warped pilot
#

I have it assigned in the NetworkManagers player object

#

this is my prefab, before I have it not as prefab

#

can I make it just as prefab too ?

neat veldt
warped pilot
#

thanks is working

haughty crane
#

ScriptRunner.Exceptions.CloudCodeRuntimeException: Error executing Cloud Code function. Exception type: ApiException. Message: Unauthorized
umm why i'm not authorized to make a lobby?

#

solved, i used accestoken instead of servicetoken

warped pilot
#

What does LocalPlayer mean ?

sharp axle
sharp axle
sharp axle
sour fiber
haughty crane
#

do i need to open the project twice?

sour fiber
#

I'm not sure if I need to do player classic casting.

sharp axle
hushed hamlet
sharp axle
sour fiber
sharp axle
hushed hamlet
#

Yeah my goal was to use Unity Transport directly for minimal overhead, but then that goes back to the issue that I'm not supposed to use it directly 😭

sharp axle
hushed hamlet
#

I guess I'll just try unreliable rpc to see if it fits my usecase first and if it's not good enough, I'll just have to think of a better solution

#

Thanks for the help!

vocal bane
#

How do I sync a list of network objects to all clients?

sharp axle
sharp axle
hushed hamlet
warped pilot
#

` public class VisualsStateUpdater : NetworkBehaviour
{
[SerializeField] private Vehicle m_Vehicle;
[SerializeField] private JeepVisual m_JeepVisual;
[SerializeField] private ThirdPersonCameraController m_CameraController;
[SerializeField] private PlayerController m_PlayerController;

    public override void OnNetworkSpawn()
    {
        if (IsLocalPlayer)
        {
            m_CameraController = FindObjectOfType<Camera>().GetComponent<ThirdPersonCameraController>();
            m_CameraController.FollowTarget = m_Vehicle.transform;
        }
        m_JeepVisual.SpringsRestLength = m_Vehicle.Settings.SpringRestLength;
        m_JeepVisual.SteerAngle = m_Vehicle.Settings.SteerAngle;
    }

    private void Update()
    {
        m_JeepVisual.SteerInput = m_PlayerController.MySteerInput;

        float forwardSpeed = Vector3.Dot(m_Vehicle.Forward, m_Vehicle.Velocity);
        m_JeepVisual.ForwardSpeed = forwardSpeed;
        m_JeepVisual.IsMovingForward = forwardSpeed > 0.0f;

        m_JeepVisual.SpringsCurrentLength[Wheel.FrontLeft] = m_Vehicle.GetSpringCurrentLength(Wheel.FrontLeft);
        m_JeepVisual.SpringsCurrentLength[Wheel.FrontRight] = m_Vehicle.GetSpringCurrentLength(Wheel.FrontRight);
        m_JeepVisual.SpringsCurrentLength[Wheel.BackLeft] = m_Vehicle.GetSpringCurrentLength(Wheel.BackLeft);
        m_JeepVisual.SpringsCurrentLength[Wheel.BackRight] = m_Vehicle.GetSpringCurrentLength(Wheel.BackRight);

        m_CameraController.SpeedRatio = m_Vehicle.Velocity.magnitude / m_Vehicle.Settings.MaxSpeed;
    }
}`

Why does give me this line of code a 0 reference ?

m_CameraController.SpeedRatio = m_Vehicle.Velocity.magnitude / m_Vehicle.Settings.MaxSpeed;

sour fiber
vocal bane
sharp axle
sour fiber
sharp axle
vocal bane
sharp axle
haughty crane
#

does anything here look wrong?

#

because i can't find why i m getting throws

vocal bane
# sharp axle The sample code here should help. The big gotcha is that you must initialize it ...

Thanks thats what I need! Thanks for your help. I've found what I've been doing wrong, I've been trying to make the list hold Network Object refrences. For some insane reason, you can't sync lists of network object references but you can sync a variable holding a network object reference. This page has a workaround to allow you to sync a list of network object refrences, except its like 150-200 lines and is hela complex, kill me now. Its probably easier to just to sync the lists manually via creating a local list on each client, and syncing each index via a clientrpc.

sharp axle
haughty crane
#

isn't that usefull

#

does this 2 be the same?

haughty crane
#

i dont find any topics on google and the documentation suckks

warped pilot
#

When I run this:

`public override void OnNetworkSpawn()
{
if (IsLocalPlayer)
{
m_CameraController = FindObjectOfType<Camera>().GetComponent<ThirdPersonCameraController>();
m_CameraController.FollowTarget = m_Vehicle.transform;
}
m_JeepVisual.SpringsRestLength = m_Vehicle.Settings.SpringRestLength;
m_JeepVisual.SteerAngle = m_Vehicle.Settings.SteerAngle;
}

    private void Update()
    {
        m_JeepVisual.SteerInput = m_PlayerController.MySteerInput;

        float forwardSpeed = Vector3.Dot(m_Vehicle.Forward, m_Vehicle.Velocity);
        m_JeepVisual.ForwardSpeed = forwardSpeed;
        m_JeepVisual.IsMovingForward = forwardSpeed > 0.0f;

        m_JeepVisual.SpringsCurrentLength[Wheel.FrontLeft] = m_Vehicle.GetSpringCurrentLength(Wheel.FrontLeft);
        m_JeepVisual.SpringsCurrentLength[Wheel.FrontRight] = m_Vehicle.GetSpringCurrentLength(Wheel.FrontRight);
        m_JeepVisual.SpringsCurrentLength[Wheel.BackLeft] = m_Vehicle.GetSpringCurrentLength(Wheel.BackLeft);
        m_JeepVisual.SpringsCurrentLength[Wheel.BackRight] = m_Vehicle.GetSpringCurrentLength(Wheel.BackRight);

        m_CameraController.SpeedRatio = m_Vehicle.Velocity.magnitude / m_Vehicle.Settings.MaxSpeed;
    }`

and I join as client. Then I have on this line of code a NullReference:

m_CameraController.SpeedRatio = m_Vehicle.Velocity.magnitude / m_Vehicle.Settings.MaxSpeed;

haughty crane
warped pilot
#

Yes. When I start as Host all is working fine. But when I join as Client the Host loose the "reference" of the camera and the client has it.

#

and the host has after that the nullreference

sharp axle
sharp axle
#

just put another check before that line

warped pilot
#

What is a "Local Player?"

sharp axle
warped pilot
#

But why is it working when I join as Host ?

#

It swaps the reference away

sharp axle
#

OnNetworkSpawn() is checking if this script is on the local player object

warped pilot
#

Which line of code do I have to add as check ?

sharp axle
warped pilot
#

but then it does not work because he returns

sharp axle
#

the non local player objects should not need the local camera

haughty crane
#

and more used?

warped pilot
#

Ok i think i have a mistake

sharp axle
#

but also why does the camera controller have the Speed Ratio for the vehicle

warped pilot
sharp axle
warped pilot
#

how can I acess as client the camera ?

sharp axle
warped pilot
#

And the host ? 😛

sharp axle
#

the host is also a client

warped pilot
#

public override void OnNetworkSpawn()
{
m_CameraController = Camera.main.GetComponent<ThirdPersonCameraController>();
m_CameraController.FollowTarget = m_Vehicle.transform;
m_JeepVisual.SpringsRestLength = m_Vehicle.Settings.SpringRestLength;
m_JeepVisual.SteerAngle = m_Vehicle.Settings.SteerAngle;
}

When I use this and I join then the camera swap from one player to the other one.

sharp axle
warped pilot
#

But when I check
public override void OnNetworkSpawn() { if (IsLocalPlayer) { m_CameraController = Camera.main.GetComponent<ThirdPersonCameraController>(); m_CameraController.FollowTarget = m_Vehicle.transform; } m_JeepVisual.SpringsRestLength = m_Vehicle.Settings.SpringRestLength; m_JeepVisual.SteerAngle = m_Vehicle.Settings.SteerAngle; }

I get a Nullreference on:

m_CameraController.SpeedRatio = m_Vehicle.Velocity.magnitude / m_Vehicle.Settings.MaxSpeed;

#

and only one player has the CameraController reference

#

follow is working

sharp axle
warped pilot
#

yes but then its not working for the client

#

ok its working

#

strange

#

I have tried this but got errors

narrow cloak
#

is there a wokr around for funcs needing monobehaviour but thee rest of the script needs networkbehaviour

haughty crane
#

same logic

#

every player makes a move(2players)

sharp axle
sharp axle
# haughty crane a game like chess game

Could you get the Chess sample working at all?
https://github.com/Unity-Technologies/com.unity.services.samples.multiplayer-chess-cloud-code

There are other serverless platforms you could use like AWS Lamda, or Playfab Could Functions.

But I guess it might be more straightforward to just use Unity Lobby and Relay. You are not likely to go beyond the free tier limits even after you launch

GitHub

Contribute to Unity-Technologies/com.unity.services.samples.multiplayer-chess-cloud-code development by creating an account on GitHub.

haughty crane
#

so i can't deploy the modules

#

from unity.. and by cmd isn't working too

haughty crane
#

can't even host lobby

warped pilot
#

when I starthost how can I change spawn position of the player prefab ? 🙂

weak plinth
#

(using NGO) more of a logic question on how to approach my issue: Network objects can not be a child of a non network object. I need my player to be able to equip a new "gun" when they walk into it on the map. Issue is that I have 2 guns that need to appear, one for the client who collects the gun (they dont see their body, arms or anything just the gun when it spawns) which is easy as you can do this locally without spawning a networkObject. However this second gun is for the other clients to see when looking at the player who collected the gun. The player runs an animation in all states which means I need the gun to be a child object of a transform attached (child of) the Players Rigs hands. But again you can't do this as network objects can only be a child of a network object, and additionally a network object can not spawn with nested network objects. So am I supposed to run a client RPC to tell each client to instantiate and destroy the gun object each time, or is there another way to do it that sounds less bad than instantiating a nested network object in the players hand just for the sake of being able to spawn the gun on it in one ServerRpc?

sharp axle
haughty crane
weak plinth
#

I don't know what I'm talking about but look into asynchronous methods and using the await function in unity (I think this works with RPC's)

sharp axle
#

NGO can only operate on the main thread. You probably shouldn't be calling RPCs every tick in any case

sharp axle
haughty crane
sharp axle
weak plinth
# haughty crane and do i need to use netcode?

You aren't trying to make a multiplayer chess game using lobbies and cloud are you? Netcode is the code that sends data such as a moved piece on the chess board not cloud data. Cloud data is for storing information to then pull at a later date like unlocked chess board skins or something.

sharp axle
sharp axle
weak plinth
haughty crane
#

the best option is still the cloud code.. i ll try to take step by step with the join lobby until it works

#

i hope

sharp axle
#

Right, cloud code is basically a server that runs one function at a time. You'll see it called serverless architecture

weak plinth
# sharp axle You would use an RPC or network variable on the root player object to tell the c...

what I mean is, what is best practice / uses less bandwidth, calling a clientRPC to instantiate the gun locally on each client and then also a clientRPC to destroy the local to the client gun. Or is it better to instantiate a nested network object on each player post character creation in order to allow for a single server RPC to be called creating, parenting and destroying the gun. (or am I digging into this too much)

haughty crane
#

so its too much for what i need? i think?

sharp axle
weak plinth
sharp axle
#

For weapon switching I wouldn't worry about efficiency. It's not like players are doing it every frame.

weak plinth
haughty crane
#

CloudSaveData.SetCustomItemBatchAsync its like a structure where i can find my save data and i can update it or read it when ever i want?

sharp axle
sharp axle
sharp axle
haughty crane
#

so frustrating that i can't get any info from this logger

#

like what's the error thrown

bitter eagle
#

(Unity Lobby Service)

Hey guys, is there something like "unsubscribe" lobby events? Opposite of SubscribeToLobbyEventsAsync method, I mean.

sharp axle
haughty crane
#

but it looks like i dont have a lobby

#

even it is hosted

haughty crane
#

nah, i don't know what to do anymore.. can't find a way to see what's the problem

sharp axle
haughty crane
#

i try quickjoin

nimble drift
#

do i place NetworkObject component on every object in the player?

sour fiber
#

@sharp axle are you here?

sharp axle
sour fiber
# sharp axle I'm around

I did what you said yesterday and it worked successfully, but after adding networkVariables to my player class, I started not being able to connect.

#

this is public class Player : NetworkBehaviour, IPlayer

nimble drift
#

why does this not work?

#

and in another script i have this

#

its giving me an error

#

line 112

sharp axle
sharp axle
nimble drift
#

so just reference it manually?

sharp axle
nimble drift
#

alright

#

thanks

nimble drift
#

so it was initializing before the network manager

#

but still imma stick with manual

haughty crane
# sharp axle yep

hi, did you work with photon? its worth? I'm thinking switching to it instead of the cloud code

sharp axle
sharp axle
haughty crane
#

I'll try tomorrow, ty so much for your time to explain these things 4 me. Happy new year!

nimble drift
#

this is a short script for switching weapons

#

why doesnt it work properly for other players?

#

this is what i mean

nimble drift
#

the owner

#

i mean it looks like its also switching for other players but the old weapon is not getting disabled

nimble drift
#

i think i got it but im not sure

sharp axle
sharp axle
nimble drift
#

do i have to pass it the client rpc through the server one tho?

#

or can i just call the client rpc straight away

sharp axle
#

Has to go through the server

nimble drift
#

then cant i just put all the logic inside the server rpc?

#

im trying to understand it sorry man

sharp axle
nimble drift
#

oh i think i get it

sharp axle
#

You could also just make the activeWeapon a NetworkVariable.

#

then the client can listen for activeWeapon.OnValueChange and do the weapon swapping there.
Either way works

nimble drift
#

could u just help me understand one more thing

#

here im just passing selectedWeapon

#

instead of the weaponIndex

#

and it doesnt work anymore

#

why is that

sharp axle
nimble drift
#

alright

#

thank you man

nimble drift
#

gimme a sec i'll show you what i mean

#

the name of the function is misleading because its not ik

#

all this does is rotates the lowerSpine bone around the x axis

#

accordingly to how much the player is looking up or down

#

and the player can only see this happening on himself

#

and other players cannot see it

#

this is the bone im rotating

#

i tried adding a client network transform

#

to affect the x rotation

sharp axle
#

same issue actually. you would need to send the x rotation as an RPC

nimble drift
#

really?

sharp axle
#

or you could use IK rigging package and just have the IK target have a network transform on it

nimble drift
#

so would this work?

sharp axle
#

Yea. it should

nimble drift
#

its buggin out

#

maybe cause its in LateUpdate?

#

i might just do it with ik

#

all i'd have to do with ik is just have the client network transform on it right?

nimble drift
#

alright

nimble drift
#

instead of IsOwner

#

cause im gonna have 3 players

#

and IsOwner checks if its the player hosting right?

sharp axle
nimble drift
#

oh alright

#

thank you so much man

pure nymph
#

Photon Fusion question: Does anyone know why FixedUpdateNetwork is never being called on my NetworkBehaviour derived class?

#

There's a NetworkObject component on the same gameobject. Not sure what else I'm supposed to do

pure nymph
#

Oh and it IS being called on another class that gets spawned. Just not on this one manager class that's already in the scene

orchid pendant
#

Im using photon PUN 2 and im trying to access a random player's script which is in the room i tried using an array and tried finding a random player by using Random.Range()but that didnt work since PhotonNetwork.PlayerList.Length OR PhotonNetwork.PlayerListOthers.Length isnt a gameObject

#

how would i do this

#
public GameObject[] players;

int randomPlayer = Random.Range(0, players.Length);

GameObject[] playerGameObject = GameObject.FindGameObjectsWithTag("Player");
for (int i = 0; i < players.Length; i++)
{
  players[i] = playerGameObject[i].gameObject;
}

GameObject playerWithTheBomb = players[randomPlayer];

playerWithTheBomb.GetComponent<PlayerBombManager>().bombText.SetActive(true);
``` i tried this but it doesn't work
bitter bough
#

Can someone explain and show me an example of how to synchronize variables via rpc for a health script. Using netcode for gameobject

sharp axle
bitter bough
sharp axle
bitter bough
nimble drift
#

i want to make a isSingleplayer bool

#

which if true would always return the IsOwner to true

#

and if it isnt then let the network decide if IsOwner

#

how can i do that?

#

i tried something like this

#

but i dont know what im doing

weak plinth
#

Are there any helpful resources on sceneloading in netcode. I have it working other than when it doesn't my client will randomly decide every now and then that instead of loading the scene along with the host it will just not.

weak plinth
# nimble drift

you can only change ownership by asking the server/host. To do this you have to send a ServerRpc (a function that runs on the server / host only, but is told to run by the client). Its also worth noting that if you are calling a serverRpc to happen on an object the client doesn't own then you need the parameters [ServerRpc(RequiresOwnerShip = false)].

sharp axle
weak plinth
#

Netcode is server authoritative meaning any changes made are required to be done by the server (instantiation, ownership transfers, etc)

nimble drift
#

and then host

#

cause at the moment i have to hide him before playing

#

then host a game

#

and change stuff

weak plinth
#

Oh your statement confused me lol, you are trying to make a singleplayer vers and a multiplayer vers? Do you need the networkmanager to still run for the game to work?

nimble drift
sharp axle
nimble drift
#

i just wanna be able to start the game and if the player is active to not need to host a lobby

weak plinth
sharp axle
nimble drift
#

the second video is what i wanna be able to do

nimble drift
#

how do i overcome that?

#

it returns false

sharp axle
#

use isSinglePlayer instead of IsOwner

nimble drift
#

but then i also need to check if IsOwner

#

if its not single player

weak plinth
# nimble drift

several approaches, could make a player prefab for the multiplayer vers and a prefab for the singleplayer vers and different scripts. Or you could just copy and paste the code under two different if statements asking if it is singleplayer == true {do singleplayer vers of events} and else {do singleplayer vers of events}

#

you cant ask "IsOwner" without errors if you aren't connected to a game

nimble drift
#

yeah i thought the easiest way would be to check if isSingleplayer is true, and if it is always return the IsOwner to true

#

because the isSingleplayer bool would be for testing

#

only

nimble drift
#

in this script in awake i wanna check if isPlaytesting is true, and if it is to override the IsOwner to always return true;

#

and if isPlaytesting is set to false, to let NetworkBehaviour decide if IsOwner is true or false

weak plinth
#

ok so IsOwner is a network variable instead of using this create a new variable in your player script that asks (isOwner) for all the movement and other actions. instead of using the (isOwner) variable make a new one and call something else like "IsPlayerUsed". At the start of the script take the Isplayerused and make it = isPlaytesting. Then OnNetworkEnable(){IsPlayerUsed = IsOwner}

#

I don't know if that would defnitely work but worth a shot sounds logical

#

let me know how it goes

sharp axle
#

Normally for single player you will just connect to yourself as host

weak plinth
#

by default, clientRpc sends to all clients? I am calling a clientRpc with params to set a singular client to send the rpc to (works fine). but then in this clientRpc i call another clientRpc without any specified params, but it just ends up sending a clientRpc to itself, how can I make it so that it sends to all clients again.

sharp axle
weak plinth
nimble drift
#

and in some script in awake check if isPlaytesting, and if its true return true, and if its false make IsPlayer = IsOwner

#

wait no it would have to be in update as well

#

right?

#

something like this would work right?

#

also whats a better name for the bool

#

other than IsPlayer

#

cause it doesnt really make sense

sharp axle
nimble drift
#

bruh its so broken

#

i dont know what to do

#

like when i wanna make animations

#

i gotta host a lobby

#

and all that

sharp axle
nimble drift
#

so i could just do that

#

the second screenshot

#

automatically start a host

#

if is playtesting

nimble drift
sharp axle
#

pretty much, yea

nimble drift
#

why did it automatically add a network object?

#

when i attach the script

#

and i cant remove it

sharp axle
#

Netowrk behaviors must have a network object

nimble drift
#

it doesnt have one

#

and it still works

#

oh its mono behaviour

#

alright my bad

nimble drift
#

so this is what it looks like

#

i mean it works

#

i had to change awake to start

#

because it was giving me the "NetworkManager is null"

#

cause this was running before network manager was even initialized

sharp axle
#

that's correct. Singletons are normally initialied in Awake()

nimble drift
#

whats a better name for this script

#

DeveloperNetworkBehaviour?

sharp axle
#

lol, naming is the hardest thing in game dev

nimble drift
#

yeah lmao

#

NetworkDeveloperTool

#

maybe

sharp axle
#

I call my script that does all that NetworkConnectionManager

nimble drift
#

yeah could do

#

alright thanks man

#

you'll probably see me here shortly again with another problem 🥲

nimble drift
#

but when they are active by default it works

#

i need them disabled tho

#

i think the network manager isnt initializing them or something because there not active

sharp axle
haughty crane
#

hi, any idea why it says that im already in lobby? i create a lobby on a client and join on 2nd..

sharp axle
haughty crane
nimble drift
#

because i need them to be disabled by default

sharp axle
sharp axle
haughty crane
#

or i need to include other libraries?

sharp axle
haughty crane
sharp axle
#

also that specific is for when you are using ParrelSync to clone the project

haughty crane
nimble drift
sharp axle
sharp axle
nimble drift
#

how do i access that method

haughty crane
# sharp axle You could call it in OnNetworkSpawn() if this is on the player object

hei, i ve got back to the cloud code, but now i can't req anything because i get 422 bad request. I've found this https://forum.unity.com/threads/getting-422-unprocessable-entity-bad-request-in-cloudcode-request.1510301/ and my question is, do i need to sync anything ???/

#

like i can't even get the sayhello to work

sharp axle
haughty crane
sharp axle
haughty crane
sharp axle
# haughty crane

Maybe try commenting out the constructor since is not being used

haughty crane
#

i ll try to remake everything

bitter bough
haughty crane
#

@sharp axle i started from 0 again and got it to work(get lobby, join by code etc), now i don't understand how startgame is called

#

it hans't any command filed..

#

found it

nimble drift
#

cause im new to networking and i wanna see what other people are also using

haughty crane
#

and lobby to make/join lobby

nimble drift
sharp axle
bitter bough
sharp axle
bitter bough
# sharp axle I'm not sure what you mean by record and call functions. By default network vari...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Unity.Netcode;

public class health : NetworkBehaviour
{
    [SerializeField] private NetworkObject NetworkObject;
    [Space]
    [SerializeField] private bool isHitBox;
    [SerializeField] private health basicHealth;
    [SerializeField] private int healthPartsNumber;
    [Header("Basic")]
    [SerializeField] private int[] healthParts; //<--- health counts
    [SerializeField] private Image[] iconParts;

    private void Start()
    {
        iconParts = FindObjectOfType<getIconParts>().getParts(); 
    }

    private void Update() 
    {
        if (!NetworkObject.IsLocalPlayer)
        {
            enabled = false;
        }
    }

    public void GetDamage(int Damage)
    {
        basicHealth.healthParts[healthPartsNumber] -= Damage;
    }
}

You can show me with the example of this script. Please do.

haughty crane
#

any idea why i get a message twice?

sharp axle
bitter bough
#

Why i cant change value

sharp axle
normal bluff
#

ChatGPT is telling me to use NetworkPrefabs to access the prefabs list but Unity is saying that doesnt exist... Did the internet lie to me?

normal bluff
bitter bough
sharp axle
bitter bough
sharp axle
calm geyser
#

Hello, why is my client gameobject floating in air. And the server side camera is not following the GO. I am using netcode for gameobjects

calm geyser
# calm geyser Hello, why is my client gameobject floating in air. And the server side camera i...

this is my movement script. But i dont think its the one causing the issue.

    private PlayerInputActions _playerInputActions;
    private float _speed = 3f;
    
    private void Start(){
        _playerInputActions = new PlayerInputActions();
        _playerInputActions.Player.Move.Enable();
    }
    private void Update(){
        if (!IsOwner){
            return;
        }
        Vector2 inputVector = _playerInputActions.Player.Move.ReadValue<Vector2>();
        transform.Translate(new Vector3(inputVector.x,0,0) * (Time.deltaTime * _speed));
        HorizontalAnim(inputVector.x);
    }
    private void HorizontalAnim(float horizontal) {
        //animator.SetFloat(Speed, Mathf.Abs(horizontal));
        Vector3 scale = transform.localScale;
        if (horizontal < 0) {
            scale.x = -1f * Mathf.Abs(scale.x);
        }
        else if (horizontal > 0) {
            scale.x = Mathf.Abs(horizontal);
        }
        transform.localScale = scale;
    }```
bitter bough
# sharp axle Here is how to use serverRPCs https://docs-multiplayer.unity3d.com/netcode/curre...
    public void GetDamageServerRpc(int Damage)
    {
        basicHealth.healthParts[healthPartsNumber].Value -= Damage;
    }```
If this is the case, the client can damage the server. But the server can't damage the client.




```    [ClientRpc]
    public void GetDamageClientRpc(int Damage)
    {
        basicHealth.healthParts[healthPartsNumber].Value -= Damage;
    }```
And like this, the server can damage the client, but the client cannot damage the server


why so?
bitter bough
sharp axle
bitter bough
sharp axle
sharp axle
# calm geyser anyone?

Looks like the characters are getting spawned on top of each other and gravity isn't triggering. It's still acting grounded

calm geyser
bitter bough
sharp axle
sharp axle
bitter bough
sharp axle
haughty crane
#

if i want to send int data etc i need to sent it like string?

sharp axle
nimble drift
#

hey there guys

#

could you help me spawn this for other players?

#

so im trying to instantiate muzzle flash in different places for different people

#

so for the owner of this object so the player that is shooting i want to instantiate a muzzle flash at the clientBarrel.position and for other people to see it at serverBarrel.position

#

how can i do that?

#

so the first check would be correct

#

because it would only spawn it for the player that is shooting

#

and other player wont be able to see it

#

but now in the else statement i need to spawn it for every client that is NOT THIS PLAYER

nimble drift
nimble drift
#

and it spawns the muzzle flash on every client

#

i just need to spawn it on every client other than the one that shot it

#

so every client other than this one

#

wait i dont have to spawn it as a network object

#

i ended up with this

#

but it still doesnt work because it still spawns the muzzle flash on the player that shot

#

so on the owner

atomic mountain
#

Hello, I am trying to get Vivox setup with Mirror in Unity. My goal is to have proximity chat in my game. I can't seem to find any resources or examples of how to set this up though. Can anyone point me in the right direction as to how I should implement 3D positional audio with Vivox? I have this script in my Game scene that I think is joining the channel but I cannot figure out how to update the players position in game

atomic mountain
#

welp nevermind i got Dissonance lol

calm geyser
neat veldt
#

It works if I make it a ServerRpc instead, but that feels inefficient

haughty crane
#

@sharp axle if i save a bool in cloud when i do this: var HostReady = saveResponse.Data.Results.Find(r => r.Key == "HostReady") it will return a string or bool?

sudden holly
#

I created a short tutorial for anyone who is interested to start with Unity WebSocket and WebRTC networking 🙂 https://www.youtube.com/watch?v=fgQw_sClwVo

A short tutorial of how to use #Unity #WebRTC in combination with #WebSockets. In this project, we'll implement everything from scratch in Unity. NO npm, NO webdev, NO complex setup.

Unity WebRTC package: https://docs.unity3d.com/Packages/com.unity.webrtc@3.0/manual/index.html

WebSocketSharp Github: https://github.com/sta/websocket-sharp

Unit...

▶ Play video
sharp axle
haughty crane
#

it wont let me use the boolean false

sharp axle
haughty crane
#

i m trying with

haughty crane
#

im trying with (bool)HostReady

#

to the value

sharp axle
haughty crane
#

yes, worked. ty

#

one more question

#

when i save data to cloud like this

#

when i want to save anything else, do i need to save the old variables again??

haughty crane
#

right?

round reef
#

how do i make it so each player has its own camera