#archived-networking

1 messages · Page 29 of 1

unkempt crow
#

Actually pretty helpful 👍

lavish walrus
#

But isn't this even more exposed than hardcoding, or does unity have an option for encryption?

spring crane
#

Are you trying to send logs from clients to your email?

lavish walrus
spring crane
vital hill
#

How can i Sync in unity objekts that are already in the scene? with mirror;

I have a gameobjekt in my scene, with a key press i can add child objekts. now how can i take the childobjekts and sync them to the client with mirror.

i tried NetworkServer.Spaw() and NetworkServer.SpawnObjects(). also i tryed to clone the gameobjekt withe the children but that also didnt work.

pliant bluff
#

does in-scene networkobject automatically spawn on other client?

sharp axle
pliant bluff
#

so what if both client having the same networkobject betfore starting host-client

sharp axle
pliant bluff
#

i see

#

thank

pliant bluff
#

can i set networkvariable beforespawning?

#

i know it gonna say that i couldnt edit it before it spawn

#

work around?

tame slate
#

Why do you need to access a NetworkVariable before the object is spawned?

pliant bluff
#

just thinking it would be more convenience to spawn object with value set by the server

#

like spawning an enemy with half health

sharp axle
# pliant bluff can i set networkvariable beforespawning?

NetworkBehaviour is an abstract class that derives from MonoBehaviour and is primarily used to create unique netcode or game logic. To replicate any netcode-aware properties or send and receive RPCs, a GameObject must have a NetworkObject component and at least one NetworkBehaviour component.

pliant bluff
#

ooooo nice

lavish scaffold
#

I am making an online ultimate tic tac toe game

but when i am calling Rpc from the host side it is not updating on the client side

Is it necessary to make my play board a network prefab?

lavish scaffold
#

sending

lavish scaffold
#

oh i forget
my bad

#
[Rpc(SendTo.Everyone)]
    public void SetActiveGridRpc(string grid)
    {
        if (activeGrid == -1 && gridState[GetGrid(grid)] == 0)
        {
            activeGrid = GetGrid(grid);
            LoadGrid(GetGrid(grid));
        }
    }
tame slate
lavish scaffold
#

I want it so that when a grid is selected
it is highlighted on both sides
and is loaded in the play area
the total board is of 9 * 9 and the playboard is of 3 * 3

#

3*3

pliant bluff
#

is in-scene object is automatically own by server regard of whether its on client or server?

#

if so how to make the in-scene object own by the client ?

#

[server rpc] in onnetworkspawn?

lavish scaffold
pliant bluff
#

network object in the hierachy

lavish scaffold
#

if it is in hierarchy
then both server and client will have there own instance of that object

pliant bluff
#

yeah but they both own by the server

lavish scaffold
pliant bluff
#

yeah but its alittle convolutedd

lavish scaffold
# pliant bluff yeah but its alittle convolutedd

you cant make direct changes from client side to server side objects
and if you want to have seperate objects for the server and client use the Spawn() function to spawn it on the client side

#

the client will be able to make changes to that object
but if you want them both to be synced
then you would have to use ServerRpc to make the similar changes on the server side too

pliant bluff
#

nvm im dumb

#

use NetworkManager.Singleton.LocalClientId instead lol

#

turn out i just needd the client id

lavish scaffold
#

if it works then there's no problem in that

lavish scaffold
#

what game are you working on?

pliant bluff
#

just some coop game

#

rouge like ...

lavish scaffold
#

oh, nice

lavish walrus
gray peak
#

Hello guys, hope you are having a good day!
Are there any know issues/complications when using NGO + Relay and trying to have a mobile player as a host?
We have tried:

  • PC Host / PC client -> Sucess
  • PC Host / Android client -> Success
  • Android host / pc client -> Fail
  • Android host / Android client -> Fail

Hence why I believe the issue lies with Mobile trying to host the game.

sharp axle
gray peak
#

Turns out quantum console had a missing reference that caused expensive async code to be called every frame, which was dwindling performance to the point of a crash, the hosting failing was a consequence not a cause xD. But thanks

wispy thorn
#

Hey, i am trying to get the local player but this is always null, also the network manager spawns the player and player prefab is set

NetworkManager.Singleton.LocalClient
tame slate
wispy thorn
#

OnNetworkSpawn

tame slate
wispy thorn
#

on an object which is spawned by the host

#

and also tried to debug log that on network spawn on the player itself

#

An workaround that i did is on network spawn for the player owner is this

tame slate
tame slate
#

Hey, i am trying to get the local player

uncut wren
#

using NGO, and I'm trying to get the player to throw a grenade.
The grenade needs to be spawned and "given" back to the weapon manager component, so it can track it

#

i guess the flow would be
player presses grenade throw button
server spawns grenade for the player
player releases grenade throw button
server launches grenade with force, etc etc etc

#

is there a less delay-inducing way to do it than sending an rpc to spawn it, and then an rpc to give the reference back to the player?

tame slate
uncut wren
#

i feel like i'd then need to find all the grenades in the scene, see which ones are owned by that player, then filter out the ones that haven't been thrown

tame slate
uncut wren
#

There's no way for the client to "know" when its been spawned on its own, though

tame slate
uncut wren
#

i think I have figured out a roundabout way to do it

#

Is there a way to pass a network prefab via rpc?

tame slate
uncut wren
#

yeah, or an unspawned network object/game object

#

the server has no way of knowing which grenade the player is trying to spawn

tame slate
uncut wren
#

that's

#

gonna be a big enum

#

I'm also going to have to map each grenade prefab to each enum entry

tame slate
#
public enum GrenadeType
{
  GrenadeOne = 0,
  GrenadeTwo = 1,
  GrenadeThree = 2
}
uncut wren
#

I don't know how many grenades im going to have yet

tame slate
#

You can add more without issue

#

The server would just store a list of the grenade prefabs, and do something like:

var grenadeToSpawn = grenadeList[(int)grenadeType];

uncut wren
#

to avoid hardcoding the numbers of grenades, the player and server both have a reference to the grenade prefab, and then the player finds the index of that grenade prefab

#

because i know for a fact im going to forget which number is which

tame slate
sage ore
#

I can't get my unity app to receive data over udp

using UnityEngine;
using System.Net;
using System.Net.Sockets;

public class UDPListener : MonoBehaviour
{
    private UdpClient clientData;
    private int portData = 50505;
    private IPEndPoint ipEndPointData;
    private System.AsyncCallback AC;
    private byte[] receivedBytes;

    void Start()
    {
        InitializeUDPListener();
    }

    public void InitializeUDPListener()
    {
        ipEndPointData = new IPEndPoint(IPAddress.Any, portData);
        clientData = new UdpClient(portData);
        
        Debug.Log($"UDP client listening on port {portData}");
        
        AC = new System.AsyncCallback(ReceivedUDPPacket);
        clientData.BeginReceive(AC, null);
    }

    void ReceivedUDPPacket(System.IAsyncResult result)
    {
        receivedBytes = clientData.EndReceive(result, ref ipEndPointData);
        ParsePacket();
        clientData.BeginReceive(AC, null);
    }

    void ParsePacket()
    {
        Debug.Log($"Received packet from {ipEndPointData}. Length: {receivedBytes.Length} bytes");
        // Here you can add code to process the receivedBytes as needed
        // For example, converting to a string:
        string message = System.Text.Encoding.UTF8.GetString(receivedBytes);
        Debug.Log($"Message: {message}");
    }

    void OnDestroy()
    {
        if (clientData != null)
        {
            clientData.Close();
        }
    }
}```
i can receive the data with a similar script if i don't run it in unity, but as soon as i try to use it in unity it won't receive the data
so unity must be blocking it somehow i just can't figure it out
waxen quest
#

Is it better to upgrade from Unity Transport 1.4.1 to 2.3.0. Since the package manager does not show update and Unity Transport is installed as dependency because of NGO.

Should I update it?

waxen quest
sharp axle
waxen quest
sharp axle
wet ginkgo
#

Hey guys im learning NetworkVariable but i got an issue where it just doesnt update the variable for clients, im using multiplayer play mode to test.
Pressing T update the variable ONLY for the one who pressed it

sharp axle
wet ginkgo
sharp axle
wet ginkgo
sharp axle
fading stag
#

Hey I was having some problems with lag after I switched my game to relay and I was just wondering if the fact that I'm running both host and client on the same pc would be significantly contributing to that

tame slate
#

Host and client being on the same PC will be more networking intensive, but shouldn't really cause significant lag I would say

fading stag
#

ok so if I'm planning to launch with relay, the lag I'm getting would be basically the average experience?

tame slate
#

If you're allowing it to autoselect a region, make sure it's doing so correctly and is selecting a region that's close to you

fading stag
#

ok, great. I know I have some optimization issues since its my first time networking so it's probably mostly from that

#

thanks

marsh musk
#

does NGO work with the new input system?

sharp axle
marsh musk
#

Do i still need to make the input actions in awake?

sharp axle
marsh musk
#

so I fiddled with it and

#

I don't know when I need to set it's refrence to itself, normally I would just have the input actions equals new input actions, but I'm getting some timing(?) issues where on enable and on disable run before the input actions has gotten a refrence to itself

#

er go creating null refrence exceptions

#

does it need to intialize in on network spawn instead?

sharp axle
marsh musk
#

@sharp axle what's the difference in player input and

InputActions inputActions;
void Awake(){
inputActions = new InputActions();
}
weary stag
#

how do people recommend handing unit actions like a Move() action, an Attack() option or a CastSpell(Spell spell)? I've tried the command pattern but recently learnt that that doesn't work because you cant derive from INetworkSerializable.

sharp axle
weary stag
#

tyvm

sacred schooner
# marsh musk <@86985386886201344> what's the difference in player input and ```CSharp InputAc...

You're talking about using the generated c# input, which is what I do. Let me share some snippets of how I did it and basically have to never worry about it

I create a static instance of the generated input (this is to avoid issues, when more than 1 script want to access some actions, an easy hack to never worry about it)

public static class InputManager{
    public readonly static PlayerInputGenerated PlayerInput = new();
}

then in the playercontroller

public override void OnNetworkSpawn()
    {

    [...codecodecode...]
    if(!IsOwner)
        {
            return;
        }
     InputManager.PlayerInput.Player.SetCallbacks(this);

     InputManager.PlayerInput.Player.Enable();
     InputManager.PlayerInput.UI.Disable();

    base.OnNetworkSpawn();
    }
#

so you set the callbacks to be received only by the "local player" after it is spawned and knows its the one

sacred schooner
rapid oak
#

is mirror still the way to go or has it changed over the years

austere yacht
carmine geyser
#

Hello! Quick question: I am using NGo + Relay + Lobby, and I want to handle when a client crashed (meaning they do not send any disconnection messages). My issue is that right now, NGO timeout the player correctly, but the lobby does not. What is the correct way to check if a client is not responding anymore and remove them from the lobby?

austere yacht
carmine geyser
tame slate
#

By default I believe it’s quite long.

carmine geyser
sharp axle
oak flower
#

@dry maple Save statements for a blog, please.

dry maple
oak flower
dry maple
#

But if such discussion is not allowed, it's fine. Though I'd like to know which rule/guideline prohibits it so I don't repeat it?

oak flower
dry maple
oak flower
dry maple
ornate creek
#

So, I am using PhotonTransformView to sync the positions of all the Coins on my Carrom Board between both the players. So, when the turn switches and the ownership of the coins' PhotonView gets transferred to the player whose turn it is, there is a slight glitchy effect where the coins randomly move a bit then get back to the right place as if it's synchronizing between the scenes. How can I fix this?

https://cdn.discordapp.com/attachments/1250024800756301838/1269592945670099078/CarromDuels_Bugs.mp4?ex=66b0a012&is=66af4e92&hm=38896e3d9480b3e1e6cff049347d2388ee2d9bb5b11988d746f602e52d4f56a0&

You can look at 1:20 and 2:40 to see what I mean

#

I tried adding Interpolation but doesn't chnge anything.

tame slate
ornate creek
tame slate
ornate creek
#

Yeahh, I also wanted to do that but I was unable to figure it out

sharp axle
marsh musk
#

I have an issue with clients connecting at I'm not sure how it happened, it used to work fine, but now the host works fine, then if a client connects then the host freezes but is still being updated on the clients screen

#

and the client is fine

wet ginkgo
#

Is there any other way to run code on the server beside rpcs ?

tame slate
ornate creek
ornate creek
# ornate creek So, I am using PhotonTransformView to sync the positions of all the Coins on my ...

I have a development on this, that jittering only happens in the previous PhotonView's owner's side. So, if Player 1 is the owner and player 2 requests the ownership, the jittering happens to play 1 when the ownership is transferred. Jittering as in, the objects go back to their initial position then come back to the correct position.

Edit: I removed Photon Transform View and added a script to handle the synchronization but it still happens 😔

sudden birch
#

Yall should check out PlayFab for online gameplay and management. Its quite awesome.

#

Im using it to implement a TCG I designed and its really been great.

gray peak
#

Hey guys, I have an issue:

...
         else
            {
                Debug.Log("Sending Move to Server");
                SendMoveToServerRpc(new int[] { _currentMove.MoveCoords[0], _currentMove.MoveCoords[1], coords.x, coords.y });
            }

[ServerRpc(RequireOwnership = false)]
    private void SendMoveToServerRpc(int[] move)
    {
        Debug.Log($"Inside SendMoveToServerRpc, turn manager: {ServerTurnManager.Instance != null}");
        ServerTurnManager.Instance.ValidateMove(move, NetworkManager.Singleton.LocalClientId);
    }

This was previously working as intended, my changes were that NetworkManager, ServerTurnManager and SessionManager are now being spawned in another scene and added to DontDestroyOnLoad. But now, I don't get to the Debug inside the RPC, only the previous one, and in the console I get:
"KeyNotFoundException: The given key 'ThisClassName' was not present in the dictionary."

Anyone got any ideas of what the issue might be?

mighty dirge
#

can someone help me out pls

#

can soneone help me out pls

sharp axle
gray peak
mighty dirge
#

when ever i click the button leave room i get the responce "Operation leave room not allowed on current server(Master server) can someone please help. i also get the warning "Photonnetwork.currentroom is null and that you dont have to call leaveroom() when your not in one . i know that i am in a room tho.

weak plinth
#

What is networking?

stiff ridge
green wadi
#

I am pretty new to NGO and I am trying to make an object that acts sort of like a game manager class over the network. I need a way to access it through a singleton sort of how NetworkManager can be accessed so I am currently using this logic to get it, however I feel like the way I am doing it is probably wrong.

In my NetworkController class I have:

public static readonly NetworkVariable<ulong> singletonID = new();

And then to retrieve it:

public static NetworkController Singleton()
{
    return NetworkManager.Singleton.SpawnManager.SpawnedObjects[singletonID.Value].GetComponent<NetworkController>();
}

And then in an OnNetworkSpawn method in a NetworkBehaviour attatched to my player I have:

if (IsHost || IsServer)
{
    Debug.Log("Spawning Network Controller");
    var prefab = Instantiate(networkController);
    prefab.Spawn(true);
    NetworkController.singletonID.Value = prefab.NetworkObjectId;
}
sharp axle
soft bridge
#

Hey all. In NGO, Is there a way to send packets between client without a NetworkObject or a NetworkBehaviour? My project is mostly not dependant on GameObjects (Data and GameObject visuals are very decoupled), but from what i see, RPC would need to be under a NetworkObject and Custom Messaging requires a NetworkBehaviour.

#

I can also hack it by having a surrogate game object for each client, but i'd rather not go that route if possible

sharp axle
# soft bridge Hey all. In NGO, Is there a way to send packets between client without a Network...

Custom messages don't need a network behavior or network objects at all. The samples here in the docs only use them for the OnNetworkSpawn convenience
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/message-system/custom-messages/

A brief explanation of Custom Messages use in Netcode for GameObjects (Netcode) covering Named and Unnamed messages.

soft bridge
weary stag
#

My code for turns:

public struct Turn : INetworkSerializable {
    public bool hasMoved;
    public bool hasAttacked;

    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref hasMoved);
        serializer.SerializeValue(ref hasAttacked);
    }
}

public class TurnManager : NetworkBehaviour
{
    public NetworkVariable<Turn> turn;
...

What I'm trying to do:

turnManager.turn.Value.hasMoved = true

How can I set hasMoved to true in my server RPC for moving a unit? Do I have to basically reinstantiate the turn object each time I want to change a single variable like turn = new Turn(...)? I've tried looking at the docs but I don't really understand

#

is it a custom NetworkVariable I need?

sharp axle
weary stag
restive plinth
#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Unity.Netcode;

public class NetworkUI : MonoBehaviour
{
    [SerializeField] private Button hostBtn;
    [SerializeField] private Button clientBtn;
    [SerializeField] private Button serverBtn;
    [SerializeField] private InputField nickFld;

    private static HashSet<string> usedNicknames = new HashSet<string>();

    private void Awake()
    {
        hostBtn.onClick.AddListener(() => {
            if (IsNicknameValid(nickFld.text))
            {
                usedNicknames.Add(nickFld.text);
                NetworkManager.Singleton.StartHost();
            }
        });

        clientBtn.onClick.AddListener(() => {
            if (IsNicknameValid(nickFld.text))
            {
                usedNicknames.Add(nickFld.text);
                NetworkManager.Singleton.StartClient();
            }
        });

        serverBtn.onClick.AddListener(() => {
            NetworkManager.Singleton.StartServer();
        });

        nickFld.onValueChanged.AddListener(delegate { ValidateInput(); });
    }

    private void ValidateInput()
    {
        if (nickFld.text.Length > 12)
        {
            nickFld.text = nickFld.text.Substring(0, 12);
        }
    }

    private bool IsNicknameValid(string nickname)
    {
        return !string.IsNullOrEmpty(nickname) && nickname.Length <= 12 && !usedNicknames.Contains(nickname);
    }
}

Why can't I drop my InputField into inspector?

soft bridge
#

could be that you are using TextMeshPro's input field, in which case, you should be using TMP_InputField instead of InputField

soft bridge
#

I am a bit confused with reading this documentation
https://docs-multiplayer.unity3d.com/netcode/1.10.0/advanced-topics/fastbufferwriter-fastbufferreader/

Does this mean that FastBufferWriter does not dynamically resize, and we have to manually resize them ourselves?

Does anyone have an example of a dynamically growing buffer?

The serialization and deserialization is done via FastBufferWriter and FastBufferReader. These have methods for serializing individual types and methods for serializing packed numbers, but in particular provide a high-performance method called WriteValue()/ReadValue() (for Writers and Readers, respectively) that can extremely quickly write an en...

restive plinth
#

worked, thanks!

carmine geyser
#

Hi! I might need a bit of help because I am going crazy: I am using the classic combination of NGO/Lobby/Relay/Auth, and I am able to connect player together and play in the same session perfectly. HOWEVER if the Lobby host crashes, the clients never receive the Player Left lobby event, and the lobby itself is also never updated with the player leaving. Anyone managed to handle a host crashing with this combo of packages ?

tame slate
carmine geyser
tame slate
deep shale
#

Hi! Question.. In Distributed Authority mode, is it possible to restrict the spawning of certain NetworkObjects to be allowed by the session owner only?

tame slate
#

how are you "crashing" your application?

carmine geyser
soft bridge
sharp axle
soft bridge
#

quick question is there a way to get the server's client id from the Network Manager?

#

or is it only for the UnityTransport? (if so, how would it work on other transport?)

deep shale
sharp axle
soft bridge
sharp axle
tame slate
soft bridge
soft bridge
tame slate
#

The host is not timing out, leaving the rest of the clients in an unresponsive lobby with no new host being selected

sharp axle
#

The lobby host will eventually time out.

mint anvil
#

[Netcode] [Invalid Destroy][RTS Networking(Clone)][NetworkObjectId:2] Destroy a spawned NetworkObject on a non-host client is not valid. Call Destroy or Despawn on the server/host instead.

i am spawning an object with a network object, and then loading a new scene (with networking ofc), but then this happens and the object is only destroyed on the client not the server

sharp axle
soft bridge
#

quick question
In my project, when you enter by default it does StartHost()
And then when you want to connect to another host, it does Shutdown(), waits for OnServerStopped, and then does StartClient()

Is this correct? or am i supposed to use a whole new NetworkManager?

soft bridge
# sharp axle That should work fine

For some reason when i do this, OnClientConnected i print the networkManager.LocalClientId and both client and server is saying 0 (despite being on different clients/editor)

#

is it even possible to start a client and then having its id 0?

#

wait... is the client id only unique for its own client? not that it is unique for the whole connection? Did i miss something in the documentation?

sharp axle
soft bridge
#

I guess i'll try experimenting on a separate blank project

sharp axle
restive plinth
#

Hello, I have faced an issue that when joining as next client, host's camera is stuck on it's player camera which is the right thing, and there is new player spawned when client joins, but client only sees that their game is frozen while in reality the host now controls new player even tho I check if (!IsOwner) return;

#

why does this happen?

#

Here are scripts

#

(sending files cuz characters for each are too long)

#

bruh discord doesn't allow me to send any file for some reason

raw stormBOT
restive plinth
#

i did that

#

still too long

#

it says

#

I did use code block

tame slate
restive plinth
#

Movement.cs

#

NetworkUI.cs

#

PlayerNickname.cs

#

SerializableString.cs

restive plinth
#

help will be appreciated

tame slate
#

@restive plinth how are your players being spawned?

restive plinth
#

player has Movement, camera, and PlayerNicknames.cs

tame slate
#

Hello, I have faced an issue that when

lethal beacon
#
playerID in body must match authenticated player```
After creating a lobby, when I exit play mode, start the game again and try to create a lobby, I get this error.

Here is my code https://pastebin.com/LbwDqQzs
timber beacon
#

Has anyone messed with Matchmaker and Relay instead of MultiPlay? Documentation seems to be lacking around Relay use with Matchmaker.

mint anvil
soft bridge
#

sounds obvious but did catch me offguard xP

mighty dirge
#

can someone help me out beacuse i am working on this game and when i tried to test the multiplayer it is not showing me any rooms for me to join even though on the game i have created an room. and when trying to join from the room ist i cant find it there

pearl girder
#

Haven't done a local server build for a while, but when I do a local dedicated server build on my windows machine targeting window platform with il2cpp backend chosen it builds, but when i run it i get "failed to load il2cpp" error and the process ends.

closest thing i could find on google was this https://discussions.unity.com/t/dedicated-server-build-for-linux-from-silicon-mac-unity-editor-fails-to-run/868567 but it mentions the issue about building from a mac or linux machine.

Any ideas?

uSing netcode for entities 1.2.3

oak flower
#

@pearl girder Don't cross-post. Remove the post when moving.

deep tangle
#

i need help with photon

oak flower
#

!ask

raw stormBOT
rough folio
lethal beacon
#
playerID in body must match authenticated player```
After creating a lobby, when I exit play mode, start the game again and try to create a lobby, I get this error.

Here is my code https://pastebin.com/LbwDqQzs
#

I cant find anything about this error on the net

austere yacht
lethal beacon
#

Yeah

austere yacht
lethal beacon
#
new Dictionary<string, PlayerDataObject> { { "Name", playerDataObjectName }, { "Character", playerDataCharacter } });```
austere yacht
#

that doesn’t prove that the player ID is actually the authenticated one, or that any ID is authenticated at the moment.

#

You may have to re-auth that ID

lethal beacon
#

What do you mean by Player ID? If you are talking about the ID of the creator of the lobby or a player in the lobby, yes they match.

private Player playerData;
...
CreateLobbyOptions options = new CreateLobbyOptions();
options.IsPrivate = false;
options.Player = playerData;
public async void CreateLobby()
{
    Debug.Log(playerData.Id);
    Debug.Log(AuthenticationService.Instance.PlayerId);
#

Logs show they match @austere yacht

austere yacht
lethal beacon
left elbow
#

Hello guys, I'm having a synchronization problem, I'm using unity netcode and the Client Network Transform on the Player, Network Transform on the platform.
What is happening:

  • I have a player that is synchronized between host and client, using the Client Network Transform

  • I have a movable platform that uses NetworkTransform

  • When the player stands on the platform he follows the movement of the platform and can move freely on top of it, this works on the host and the client
    THE PROBLEM:

  • on the client screen, both the host and the client are synchronized on the platform, without sliding or getting in the middle of the platform

  • on the host screen, the client slides and enters the middle of the platform when it moves on the Y axis
    I will attach the codes and a video that shows this happening.
    In the video, the left side (unity editor) is the client, and the right side (native application) is the host.

Player script: https://hatebin.com/emfgmdtqtm
Moving Platform: https://hatebin.com/wutluodqls
video: https://drive.google.com/file/d/1WdQs_H9rGNTFq_vEiSana5AXm7iWI8lG/view?usp=sharing

sharp axle
# left elbow Hello guys, I'm having a synchronization problem, I'm using unity netcode and th...

moving platforms are hard. The best solution might be to reparent the player to the platform. But that has its own issues
https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/networkobject-parenting/

A NetworkObject parenting solution within Netcode for GameObjects (Netcode) to help developers with synchronizing transform parent-child relationships of NetworkObject components.

austere yacht
#

it is likely that this ID is cached and persists accross sessions, but the signed-in state doesn't.

#

The API's signed in user could very well be undefined for your API/user token and to not leak secrets the API just pretends the name was wrong

neat totem
#

hey all, not sure if this is the right channel for this, point me elsewhere if so.

I'm working on a multiplayer project using mirror, but my main conern is that I want to be building my project with the idea of a headless dedicated host server in mind.

What design patterns/considerations should I have when designing my scenes/netcode for a dedicated headless server?

#

another thing I read was that it is possible to build a server backend as just a C# appliaction, or even C++, to communicate with unity over the network. has anyone here attempted anything like this?

austere yacht
sharp axle
neat totem
neat totem
austere yacht
#

this is much easier if you have partial classes with .server, .shared and .client parts

#

or just server/shared/client component NetworkBehaviours on the same game object

neat totem
#

in general my workflow should look like this:

  1. player issues commands to units, these commands are batched and RPC to server every 1 second
  2. server takes commands and updates values on units, then updateds postions for moves/targets for damage
  3. only need to update units on local grid so interest management based on parent game objects
austere yacht
neat totem
#

its real time just batched

#

things will be a bit slow

#

long ttk

austere yacht
#

well, if you can get away with some lag, just send the inputs to the server and have it do everything

#

that is certainly the simplest approach

#

but not always the nicest for the player

neat totem
#

idk how to model inputs to ther server, I'm not doing like wasdd movement, I'm clicking on a unit and right clicking on a grid to assing a destinaion positon

#

sry my typing is terrible today for some reason

austere yacht
#

you can represent all that with integers

#

each unit has an ID, each kind of input action has an ID

#

you dont need to send raw inputs, but if you worry about cheating, you should, and validate those agains what is actually possible for the player in its current state

neat totem
#

see I was working with photon right and I wanted to push this over input
namespace SpaceGame.DTO.Commands
{
public struct MoveCommandDTO
{
public int UnitId;
public int LocalGridID;
public Vector3 Position;
}
}
they told me 'my use case didnt fit with fusion'

#

so I thought this wasnt possible

#

I figured I could represent this as ints but i figured I would jsut batch these commands and RPC them to the server as an array

austere yacht
#

why would you manually batch them?

neat totem
#

from what I was reading frequent RPC are bad and should be limited in send rate. was going to batch to stop them from choking my server

austere yacht
#

then you may have misunderstood something

sharp axle
austere yacht
#

mirror does automatic batching, you just should not do more RPCs than you have actual messages

#

also don't send data in the RPC args that you don't need

neat totem
#

haha I'm very comforable with the vector math and game logic but still learning netcode

austere yacht
#

all your messages (RPCs) are aggregated into a tick and sent more or less together

neat totem
#

i see, so then I can jsut reduce the tick rate to achieve the same effect

austere yacht
#

yes

neat totem
#

well that much simpler haha

austere yacht
#

but only if you don't do it because its turn based

#

or you actually want to control that delay

#

its a very low-level thing, not something you would expose to your game design

neat totem
#

okay so if I want to send a move command over the network like the struct I pasted before, I just need to convert the vector3 into ints?

austere yacht
#

you just should not use reference types or strings

#

all your entities need/have an integer ID you can use to send references

neat totem
#

yeah I have everything working by ID already in my management calsses

austere yacht
#

that goes a long way

neat totem
#

yeah syncing ints cheap, I know that

austere yacht
#

not just that, it makes everything much simpler

neat totem
#

I have been gathering info for about 2-3 days, you have been very helpful

#

I think I am prepared to start my net implementation

spice breach
#

What’s good networking package that have updates don’t break your game?

sharp axle
broken sable
#

I'd reccomend Photon Fusion

waxen quest
#

Unity ngo v1.10 have some new methods but after updating it still don't have that methods. Those are OnNetworkPreSpawn, etc

tame slate
waxen quest
spice breach
#

thank

tame slate
sharp axle
waxen quest
tame slate
waxen quest
#

Yeah It just updated with new LTS automatically

#

Ima try deleting Library folder

sharp axle
#

if its still not working, then delete the Library folder and restart

waxen quest
tame slate
sharp axle
waxen quest
waxen quest
sharp axle
tame slate
waxen quest
waxen quest
tame slate
#

That's why I'm curious as to how you're trying to define them

waxen quest
tame slate
#

Just try typing in the override definition, and if it doesn't error that means it's a valid override

waxen quest
tame slate
# waxen quest Yeah I will do this
protected virtual void OnNetworkPreSpawn() { }

public override void OnNetworkSpawn() { }

protected override void OnNetworkPostSpawn() { }

These were all valid for me

waxen quest
#

Yeah, OnNetworkSpawn and Despawn works for me in intelliSense too just the new methods doesn't show

#

Thanks for your time Dylan

sharp axle
waxen quest
#

I was just keep trying to get it on IntelliSense using public

terse idol
#

best free networkign solution that doesn't require port forwarding?

terse idol
ripe mesa
#

all can be doable without port forwarding, by using relay sdk such as: Steamworks, EOS, and unity relay. OR client-app relay such as: ngrok, hamachi

#

but fusion is built-in

jaunty shell
#

Hey guys, I haven't done multiplayer before, I am making a fps shooter I know very original, and I want to implement multiplayer early on, so i dont face many issues

#

I have the controller built guns are not implemented yet, but I want a system that is scalable but not limited to an eco system like photon, etc. I want to implement dedicated servers like minecraft and cod4, where players can download server files and host the server themselves as well as official servers using quickplay which I will host myself.

#

What should I do and can you link any good resources to learn multiplayer?

rustic lotus
#

noob question, I'm trying to figure out how I can get two separate players detected in the same lobby (this is in the VR Multiplayer template) using parallel sync. I get this after I already have first player joined

tame slate
# rustic lotus noob question, I'm trying to figure out how I can get two separate players detec...

Unity anonymous Auth grants unique ID's by editor/build and machine

https://github.com/Unity-Technologies/com.unity.services.samples.game-lobby/blob/main/Assets/Scripts/GameLobby/Auth/UnityServiceAuthenticator.cs

Their sample shows how to get around this issue.

GitHub

A sample showcasing a minimal implementation of a lobby experience using the Lobby and Relay packages. - Unity-Technologies/com.unity.services.samples.game-lobby

rustic lotus
#

I will test it out

tame slate
rustic lotus
tame slate
#

It's ParrelSync built in to the editor, but faster, easier to use and more efficient

rustic lotus
#

I like the sound of that

sharp axle
timber beacon
# tame slate If you're referring to this: https://docs.unity.com/ugs/en-us/manual/mps-sdk/ma...

I haven't been able to get this working with Relay and WebSockets yet. When configuring to use WebSockets for the Transport, Relay doesn't get setup to use websockets, so you just get an error. Since you don't have any control over the relay allocation, it's seemingly a big gap. That said, it's super easy to implement and will remove some of the confusion new developers may have when trying to setup multiplayer in their game.

tame slate
timber beacon
#

So far, websockets is the only area that I think it's lacking. Everything else works great 🙂

sharp axle
#

Be sure to ask about this in the Dev Blitz next week. Seems like it should be a fairly easy add

timber beacon
olive mason
#

Hello 👋 Here's something that got me stuck for a bit now, maybe someone has an idea!

I'm using Unity NGO 1.9.1 on Unity 2021.3.37f1. I first start a host using NetworkManager.Singleton.StartHost() then I'm loading a scene using NetworkManager.Singleton.SceneManager.LoadScene(sceneName, LoadSceneMode.Additive); and everything works great until I call NetworkManager.Singleton.Shutdown() upon exiting my first game session and attempting to load another. From that point on, after starting the host again, attempts to load the same scene again leads to the returned status of the loading method to be SceneEventProgressStatus: SceneEventInProgress.

What am I doing wrong?

For context, everything works fine without the Shutdown call, but from then on my NetworkManager IsHost is true, which messes up with a lot of the logic I have, as I ultimately would like players to be able to initialize a Host session or join another game without closing the game.

#

also the LoadScene() method crashes (after Shutdown and StartHost anew) with this Exception: Failed to find any loaded scene named PlayScene! in Unity.Netcode.NetworkSceneManager.GetAndAddNewlyLoadedSceneByName (System.String sceneName) (at Library/PackageCache/com.unity.netcode.gameobjects@1.9.1/Runtime/SceneManagement/NetworkSceneManager.cs:909)

sharp axle
olive mason
#

the game goes through the menu and I start the new game via the interface. It's not 10s .. but several at least. Is there a way to check the state? I'm already awaiting await UniTask.WaitWhile(() => NetworkManager.Singleton.ShutdownInProgress); which only lasts one frame

tame slate
#

May have to check that it's true before waiting for it to not be true

#

Because it should definitely be true for longer than a single frame

olive mason
#

maybe I can investigate that, but I just tried waiting for a full minute now, and I just got the same issue

sharp axle
olive mason
#

afaik there's only one, it's initially in my loading scene and gets put into DontDestroyOnLoad. I'm only additively loading the scene containing the level

#

I also stumbled upong NetworkManager.Singleton.SceneManager.Dispose() and I'm not even sure what it does ^^ I don't know why I would have a SceneEventInProgress on the second load attempt. I'm tracking every SceneEvent in the game and the last one I receive is always UnloadEventCompleted for unloading the previous instance of the Scene

rustic lotus
sharp axle
#

just make sure the tags are unique to each clone

rustic lotus
mild torrent
#

So I had a thought, my game is already a online game. It downloads some definitions for costs and stuff, but could I also define and download icons this way? Then save and load them to display on an Image component

tame slate
mild torrent
tame slate
mild torrent
#

at least for the dynamically loaded icons

tame slate
sweet junco
#

I am working with Mirror and I don't know how to setup drop and pickup correctly. I have those two methods set up already and NetworkIdentity and NetworkTransform on item. Where can I find examples of this being done, or tutorials, because there is little to none on Youtube.

sweet junco
#

Read through it already and it wasn't really helpful.

tame slate
sweet junco
#

Just a simple pickup and drop.

#

And Interaction

#

Now when I pick it up it disapears.

tame slate
noble spindle
#

Hello I'm trying to make a game with my own websocket multiplayer, and I show a bit of my code, and everyone seemed appalled that I worked with string, So I made some research and I wanted to know if instead of sending the data as string like that

ws.Send("GID"+GameID+positionString+"!"+rotationString+"IsAiming"+fpsController.IsAiming()+"IsWalking"+fpsController.IsWalking()+"IsRunning"+fpsController.IsRunning()+"IsHigh"+fpsController.IsHigh()+"IsReloading"+fpsController.IsReloading()+"$");

will it be better if I send the data like that ?

public void SendPlayerData(Vector3 position, float rotationY, bool isAiming, bool isWalking)
{
    using (var memoryStream = new MemoryStream())
    {
        using (var writer = new BinaryWriter(memoryStream))
        {
            writer.Write(position.x);
            writer.Write(position.y);
            writer.Write(position.z);
            writer.Write(rotationY);
            writer.Write(isAiming);
            writer.Write(isWalking);

            ws.Send(memoryStream.ToArray());
        }
    }
}
latent imp
#

Hello,
I am making a board game with a turn based multiplayer, how do i go about it for changing the turn from one player to another like if there are 4 to 6 players

noble spindle
sly lily
#

Hey, im making a multiplayer shooter where the bullets are very slow and i wanted to add server rewind or "lag compenstation". I have not found a single tutorial on this and have no idea how to make it, does anyone know?

tame slate
# sly lily Hey, im making a multiplayer shooter where the bullets are very slow and i wante...

There's a good explanation of it here:
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking#Lag_compensation

Using NGO, a very simple starting point would probably mainly involve storing a list of colliders that represent players previous positions and making use of NetworkTime

https://docs-multiplayer.unity3d.com/netcode/current/advanced-topics/networktime-ticks/

sly lily
sharp axle
tame slate
gaunt beacon
#

anyone have any advice for making lobbies in unity service?

tame slate
gaunt beacon
gaunt beacon
tame slate
#

This also wraps NGO, Relay and Lobby all in to one easy to use package if you're interested in that

gaunt beacon
sly lily
ripe mesa
sly lily
ripe mesa
#

😂

sly lily
#

only photon?

ripe mesa
#

Fusion and Netick is the only lagCompensation raycast I've tried

lethal beacon
sly lily
ripe mesa
sharp axle
ripe mesa
#

between ticks?

#

thanks for sharing the information @sharp axle

sharp axle
#

If you need the accuracy, it will give you the exact time between ticks when you call this

latent imp
#

Hello,
I am making a board game with a turn based multiplayer, how do i go about it for changing the turn from one player to another like if there are 4 to 6 players

sharp axle
spice breach
#

turn number can be list of player so index 0, 1, 2, etc

gaunt beacon
#

how do I use lobby quickjoin

#

public async void QuickJoin()
{
try
{

      LobbyJoined = await LobbyService.Instance.QuickJoinLobbyAsync();

     
  }
  catch
  {

  }

}

this is what I have so far, I want to start a client in the lobby now

#

idk if this is even right, my brain hurts\

tame slate
gray peak
#

Hello, not sure if I should be asking this here or in the Mobile section, but I'm trying to handle disconnect responses and right now players are sent back to the main menu whenever anyone disconnects. This is working on PC fine, if either the client or the host close the game unexpectedly the other is sent back to the main menu and the session terminated. This logic is hooked to OnClientDisconnectCallback if server and to the OnDestroy on the client side (since this object is owned by the server/host).

On mobile however, when I minimize the game and then clear it from the "opened apps tray", it seems like the player isn't actually disconnecting or even running the Destroy/OnApplicationQuit methods, or even disconnecting from the network session. Do I need a different approach to application quitting on mobile?

fluid walrus
gray peak
#

Hm, but even the NetworkManager isn't detecting a disconnection... I kinda need to be able to know when this happens so the other player isn't just held hostage

fluid walrus
#

is your example when the host quits and it doesn't lcean up properly on the client? there might just be a different event you need to listen to

#

usually if the other end disconnecting doesn't immediately remove the client, there should be some kind of timeout depending on the transport you're using

gray peak
#

I'm using relay, and I hadle both client disconnection and host disconnection. If host disconnects -> NetworkObject is destroyed -> Clients React. If Client disconnects -> Host recieves event -> Disconnects other cliesnts (not relevant cause there's only 2 but wtv) -> Handles self disconnection

#

The issue is that closing the game on the phone, as either entity, does not result in a disconnect

#

Yhea, so I just tested, if I leave it there it disconnects after a while

#

I assume there's something somewhere that pings everyone occasionally and that ping fails

#

but still, it's a significant (tens of seconds) delay

#

Hm, it's the "disconnect timeout" property in the transport... But still would be nice to be able to know if someone closed the game xD

olive mason
#

I've had a similar issue as I wanted to know if a player is 'asleep' before reaching the disconnect timeout. On the Host I listen to unityTransport.OnTransportEvent and I update a table of activity per client. One issue is that transport uses ulong transportClientId and not clientId , and the mapping is not exposed. It's in the NetworkConnectionManager : "TransportIdToClientIdMap". I had to get it using Reflection, which is a bit of a pain. but it works fine Android.

pliant bluff
#

how do i work around this?

#

it weird that clientconnectioncallback doesnt provide a way to get the connected client id

gray peak
#

do that via subscription

#
NetworkManager.Singleton.OnClientConnectedCallback += CreateRandomGenerator;
#

you can either put the IsServer check before the event subscription itself or inside the Method it calls

pliant bluff
#

i got error Cannot assign to 'OnClientConnectedCallback' because it is a 'method group'

gray peak
#

can you show?

pliant bluff
gray peak
#

hm, thats because now you have an object as parameter and the event passes a ulong

pliant bluff
gray peak
#

if you need it to be an object instead of a ulong then do

 NetworkManager.Singleton.OnClientConnectedCallback += (x)=> Try(x);
#

that's strange

#

either way I see you have 3 refs to where you are subscribing, events should only be subscribed once and then unsubscribed once

#

probably need to check that

#

wait

#

that seems to want to call a method inside the NetworkManager

#

not the event

#

stupid question but, is that the NetcodeGO NetworkManager.Singleton?

#

because this should be what it reads when you place your cursor on top of OnClientConnectedCallback, an event Action

gray peak
#

okay there you go xD

#

recompiling issue?

#

or did you have another class called NetworkManager with a singleton?

pliant bluff
#

nah i may accidentally create an empty method via the action tab

#

to the network manager

gray peak
#

ohh

#

xD

pliant bluff
#

lol

gray peak
#

that funny because if you ran the game it would've probably worked, because changes made to the NetworkManager script are lost

#

so it might've compiled correctly

pliant bluff
#

yea thank worked

pliant bluff
#

what is this error?

#

im using parrelsync to testing

gray peak
#

do you have an issue associated with it or you just don't like the warning?

pliant bluff
#

the client doesnt connect

gray peak
pliant bluff
#

nvm fixed, it seem that i put a networkobject into a prefab and then place it on scene give the error somehow

#

remove the prefab to turn it into a normal inscene place object fixed it

gray peak
#

Im by no means experienced in NGO, working on my first project with it now, but what I have noticed is that quite often issues arrise with network objects that are fixed by adding and removing the NetworkObject component from the prefabs/scene objects

#

I don't understand it

#

I don't like it

#

but sometimes it's needed and it works

pliant bluff
#

hyah same

gray peak
#

so if you want it as a prefab, remove it from the scene

#

create the prefab with a new NO

#

and add it to the scene

#

don't do it in the scene then save the prefab

pliant bluff
#

ahhh okay okay

covert zinc
#

hello guys !!
I need some help to wait correctly the scene load to complete

NetworkManager.Singleton.SceneManager.OnLoadComplete += SceneManagerOnOnLoadComplete;
NetworkManager.Singleton.SceneManager.LoadScene("Gameplay", LoadSceneMode.Single);

private void SceneManagerOnOnLoadComplete(ulong clientId, string sceneName, LoadSceneMode loadSceneMode)
{
    if (sceneName != "Gameplay") return;
    InitializeClientOnConnection(clientId);
}

I am working on my game flow (so a lot of scene transition) in my GameManager StateMachine. I have not monobehavior attached.
I know this is a bad way to wait for the scene to be ready.

#

How are you waiting the scene to be ready ?

pliant bluff
#

how to set inscene placed object to be own by the client instead of server?

sharp axle
sharp axle
pliant bluff
#

call this in OnNetworkSpawn?

sharp axle
gray peak
#

That function does serve that purpose but you need to know when you should and how you should do it

#

is the server the one who knows when X authority should be changed to Y authority?

#

is the client who is requesting this change from the server?

#

if you think the right place to do it is OnNetworkSpawn, than you probably should already Spawn it with the correct ownership as evilotaku was suggesting

pliant bluff
spring pilot
#

hey guys, this is more of a general question than an actual technical issue I'm having, but after following codemonkeys lobby tutorial I noticed that the same function used to leave a lobby "LobbyService.Instance.RemovePlayerAsync(playerID)" may also be called to remove any player from the lobby, in my specific use case for the host to kick a player from the game. My concern is that someone with a hacked client would potentially be able to call this function themselves in order to kick any player from the game. I've had no luck finding an answer online to this question. Is this a potential issue? Or is it only possible for the host client to call this function for other players? Many thanks for anyones time or insight.

sharp axle
novel stratus
#

can someone help me with multiplayer
so im trying to do like a test of doing multiplayer

#

and when i join from another laptop nothing updates when i move

#

also as the host, the camera switches to the client that joins

#

for example: ill have two pcs number 1 is the host client and pc number 2 is the client that joins

#

pc 1 starts hosting; pc 2 joins; pc 1 camera switches to pc 2's camera pov; pc 1 moves but nothing of the actions are updated on pc 2 and viece versa;

heavy swan
#

What is generally the tick rate I should aim for in a 2 player online game?

sharp axle
heavy swan
#

no clue exactly what to call it but it's similar to the "bullet hell" style of games

#

2d in a limited area though, and a decent bit of precision is needed

tame slate
#

This is the tooltip for Mirror's NetworkManager

heavy swan
#

ah perfect that works for me

sharp axle
heavy swan
#

ah perfect, I'm using 50fps for fixedupdate for now but I've been using time.fixeddeltatime so I might change it in the future if it seems necessary

mortal oak
#

Hey everyone can anyone help me with this error.

[Netcode] Deferred messages were received for a trigger of type OnAddPrefab with key 439981654, but that trigger was not received within within 10 second(s).
UnityEngine.Debug:LogWarning (object)
Unity.Netcode.NetworkLog:LogWarning (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.10.0/Runtime/Logging/NetworkLog.cs:28)
Unity.Netcode.DeferredMessageManager:PurgeTrigger (Unity.Netcode.IDeferredNetworkMessageManager/TriggerType,ulong,Unity.Netcode.DeferredMessageManager/TriggerInfo) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.10.0/Runtime/Messaging/DeferredMessageManager.cs:97)
Unity.Netcode.DeferredMessageManager:CleanupStaleTriggers () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.10.0/Runtime/Messaging/DeferredMessageManager.cs:82)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.10.0/Runtime/Core/NetworkManager.cs:82)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.10.0/Runtime/

#

Okay I figured it out. The prefab which I am spawning is not in network prefab list. I don't know the reason but network prefab list scriptable object is behaving strangely. The prefabs in it are getting removed automatically. I added prefab to it but now when I checked it is not in there. Now i added it again which fixed the above issue.

Thanks

void fiber
#

is it possible to give a command in discord and run this command in unity? for example, when i type /jump in discord i want my character to jump
and if its possible what can i use for this

fluid walrus
void fiber
#

does unity already have a system to do this?

fluid walrus
#

no

void fiber
#

thanks 🙂

warm bone
#
public override void OnJoinedLobby()
{
    base.OnJoinedLobby();
    Debug.Log("Connected: Room found");

    GameObject _player = PhotonNetwork.Instantiate(player.name, spawnPoint.position, Quaternion.identity);
}

Im using Photon to create a multiplayer game. I get Can not Instantiate before the client joined/created a room. State: JoinedLobby error, even though i joined a room?

hallow lark
warm bone
hallow lark
#

from what I know OnJoinedRoom is the proper callback for when the client enters a room, not OnJoinedLobby

warm bone
hallow lark
#

do the tutorial, it'll save you time in the long run

twilit frigate
#

Can someone help me understand Netcde for gameobject... i have watched so many tutorial but can't really get my head around it : (

haughty heart
twilit frigate
#

sorry for misunderstanding : (

haughty heart
#

Then you can post your questions here and if anyone wants to take the time to answer, they can. A general "help me" isn't enough information.

twilit frigate
#

Ok Ok lemme specify my question in detail 🫡

#

If i'm calling "IsServer" from a client then it's not going to run on that machine which client is using right ?

private void Update()
{
  if(IsServer)
    if (networkPosition.Value != Vector3.zero)
       updateServer();
}

private void updateServer()
{
   transform.position += networkPosition.Value;
}```

In the code above when I press the Arrow keys (which basically changes the networkPosition.Value) the "updaeServer()" will run on the server machine (Host in this case) and will not run on the client machine from my understanding so when it's running in the Host/Server machine I'm modifying the transform.position, which moves the client... How so ? the code runs on the host which says transform.position++ shouldn't the host move ? why client moves
sharp axle
elder kestrel
# twilit frigate If i'm calling "IsServer" from a client then it's not going to run on that machi...

the engine I used to use you could essentially open two instances of the game window in the editor press play and run two seperate instances of the project in the editor. This made it extremely easy to test multiplayer code. It seems like in unity you either keep the server/client in the same project and build a client or server when you want to test, or seperate the client/server into two projects with all shared code going in a dll. Is there a better way i am not aware of?

elder kestrel
#

you can make an editor script to update these values

#

then your code would look like this

#
private void Update()
{
#if SERVER
    if (networkPosition.Value != Vector3.zero)
       updateServer();
#endif
}


#if SERVER
private void updateServer()
{
   transform.position += networkPosition.Value;
}
#endif
#

the code wrapped in #if SERVER will only be included in the project if you define SERVER in the player settings, this prevents the client from ever having the built server code on their machine.

#

Them being able to decompile your code and find the server code will make it very easy for them to find vulnerabilities in any cheat prevent methods you emplace on the server

tame slate
elder kestrel
tame slate
elder kestrel
elder kestrel
#

wait

#

it exists

#

for unity 6 already

tame slate
#

Mhm

elder kestrel
#

oh shit mppm + dedicated server build target and multiplayer roles is a huge win for unity

sacred schooner
#

safe to say watchout what you push after git add . lol

heavy swan
#

I'm trying to make my game work for 50hz online connections, but it seems that "OnValueChanged" isn't working very well since I only end up recieving position information every two-ish frames now (though occasionally it'll still recieve info 2 frames in a row)

#

Is there something besides OnValueChanged I should use to update the position

#

This is using a Vector2 NetworkVariable btw

elder kestrel
heavy swan
#

What do you mean?

elder kestrel
#

im asking you to explain what your definition of a 50hz connection is

heavy swan
#

Doesn't 50hz mean 50 times per second (in this case, once every FixedUpdate frame)?

elder kestrel
#

ok you're right, so why are you only receiving updates every two frames?

heavy swan
#

I've got no clue

#

That's why I was asking here

hasty rain
#

is there a place i can ask people to join my server and be a dev

elder kestrel
#

i dont think you need something other than onvaluechanged and probably should debug to find out whats going on. Is the value indeed being sent etc

heavy swan
#

my code essentially boils down to

    {
        if (IsServer) serverSidePosition.Value = transform.position;
        else if (IsClient)
        {
            transform.position = serverSidePosition.Value;
        }
    }```
#

I've also been trying it using the OnValueChanged but neither one seems to work

heavy swan
#

okay for some reason if I put it in the regular update loop, it updates every 6-7ish frames

#

which is smoother since the game runs at a very high fps, but my point is that the problem is still around

sacred schooner
#

perhaps there is a threshhold, so that 0.0001 value changes are not evaluated, there is a setting for that in the NetworkTransform component afaik

#

it has to decide on some value above which to send an update, otherwise traffic would be 90% garbage for bigger scenes where most things are static most of the time

#

it's there for a reason tho, so you seeing those updates less frequently than literally every update is a good thing

#

I know you can change some of those thersholds in some of the provided network components, but if you really need it you can look around project settings, or wherever you can (if you can) configure such settings globally

elder kestrel
heavy swan
#

yeah that's how I was testing the online

#

I think I've got it working now though

elder kestrel
#

what did you do?

heavy swan
#

I'm just using ClientRPCs instead of the NetworkVariable

elder kestrel
#

i mean yeah thats deff an option

#

but finding out why its happening may be beneficial in the long run

#

wait

heavy swan
#

Haven't done much testing though, maybe I'm just going mad

elder kestrel
#

idk tbh

#

this is why I always roll my own networking library

#

makes it a lot more apparent when its user error or bug

heavy swan
#

What do you mean by "roll my own networking library"

elder kestrel
#

i write my own code to handle the networking isntead of using a built in solution

#

using raw sockets

heavy swan
#

ah so not using netcode for gameobjects or anything?

#

does sound pretty nice after hours on end of dealing with unity's stubborness

elder kestrel
#

what kind of game you making?

heavy swan
#

1v1 pvp "bullet hell" style game

#

I had it running at 10hz before while first implementing multiplayer which is why I never had this problem

elder kestrel
#

show me where you're setting this hz setting lol

heavy swan
#

it's not an actual setting

#

I just had it set up so that the host would send info to the client every 5 frames

#

meaning that at 50fps (the fps of FixedUpdate), the client would recieve data 10 times per second

#

Now I have it so that the client is sent data 50 times per second, at once per frame

heavy swan
#

anyways, using a ClientRpc definitely seems to have been the solution

noble spindle
#

hello ! I made a websocketsharp server for my fps, and i don't know why but after a while, even if the server keeps receiving messages, the server goes to sleep, nothing is displayed in the console and the server doesn't send any more messages, what's really strange is that the serveur don't shut down because I don't have any error inside unity telling me that "The current state of the connection is not Open." and also the serveur shut down only after I press any key on my keybord:

internal class Program
{

    static void Main(string[] args)
    {
        WebSocketServer wsnds = new WebSocketServer("ws://127.0.0.1:8000");

        wsnds.AddWebSocketService<Lobby>("/Lobby");

        wsnds.Start();
        Console.WriteLine("WS serveur started on ws://127.0.0.1:8000/Lobby");

        Console.ReadKey();
        wsnds.Stop();
    }
}

do you know what's appening and also how can I solve this issue ?

elder kestrel
tame slate
elder kestrel
#

im not using parrel sync but i found a way around it!

fluid meteor
#

(I'm assuming that Photon also applies to Networking). I'm a new dev (Meaning I don't know how to code lmao), but I'm following a tutorial on creating Multiplayer using Pun. And anything related to Photon.Pun or PhotonNetwork isn't working. Is Pun not supported anymore? Or is it just a me problem.

sharp axle
soft herald
#

Hello, I get an error like this when printing netcode variable data in netcode, and it gives the error constantly, not just once. The object is a network object, I spawn it later, the permissions are only open to the server and I change it only on the server. What is the reason?

#

Thats my variables

#

Btw thats not giving error

#

But when i try change it like that it always give error

soft herald
soft herald
#

It fixed when i did permission to owner 🤯

#

Does it make sense ?

twilit frigate
weary stag
#

I dont even know what to share to help people help me with this issue?
Playing the game from the editor as either host or client just doesn't work with built versions? It removes a bunch of objects (all the ones with network objects) and disconnects the client instantly.
Playing the game with two built versions works fine though

#

I don't even know what I've changed to cause this

sharp axle
#

Playing the game from the editor as either host or client just doesn't work with built versions

finite remnant
#

Hi, I am having a very interesting problem while sending ws between two computers in the same network using the input of a pen x,y and pressure the two programs lag a lot (using new InputSystem). But if its with a mouse that doesnt happen. And more over if its in the same computer sending the websockets to the apps it goes ok. Anyone has any idea what can be happening?

elder kestrel
#

what features do you all think the current big networking solutions for unity are lacking?

covert zinc
#

Hello guys !
I have worked on a state machine, but it's not a networkbehavior or a monobehavior,

So i wanted to serialize the current state, and handle the transition each time the state change,

But my state type is an inferface, IState, how do i serialize that ?
maybe serialize the name of the state, then in a switch method find the state based on the name

but it's smells right ?

#

What are my options, convert my state machine to inherit from a network behavior ?

#

Or change my interface to a abstract class ?

austere yacht
#

for example:

// declare the machine
enum State { Foo, Bar }
enum Trigger { Continue }
IState fooStateImpl = new FooState();
IState barStateImpl = new BarState();
FSM.Configure(State.Foo)
  .Permit(Trigger.Continue, State.Bar)
  .OnEnter(fooStateImpl.OnEnter)
  .OnExit(fooStateImpl.OnExit)
;
FSM.Configure(State.Bar)
  .Permit(Trigger.Continue, State.Foo)
  .OnEnter(barStateImpl.OnEnter)
  .OnExit(barStateImpl.OnExit)
;

// to trigger a transition:
FSM.Signal(Tigger.Continue);
covert zinc
#

Ohh yeah i see ! 😮

uncut wren
#

I need to stop players shooting themselves in a server authoritative game - so the server handles the shooting stuff. Players are able to look downwards and shoot at their own hitboxes

#

has anyone dealt w this kind of thing before?

sharp axle
uncut wren
#

i think ive figured it out, im checking for hitboxes (which are network behaviours) and then ignoring any colliders hit with a hitbox owned by the owner of the weapon

#

ye olde RaycastAll

dark vortex
#

When I print debug.log(transform.position) from my player object and then put an empty at that position, it does not match the position of the player object. This is only happening to my client player objects. I'm having trouble figuring out why this is... Any ideas?

median gale
#

Hello!
Goal: I'm working on a multiplayer project using Photon Fusion 2 in SHARED mode with Unity 2021.3.34f1. I am trying to spawn 2 players and have each user move their own player. I am currently testing using 2 PC player but eventually want to move to 1 PC and 1 VR player.
Problem: The issue I am having is when I spawn 2 players. Player 2 cannot move the player, however player 1 can move both players.

What I've tried and observed:
-I have a GameController script that spawns the player. I originally did not have the else statement. However, the second player would not spawn so I added the else statement. This allowed the second player to spawn. I feel like this is my first mistake adding that else statement.
-I did notice that Player 2's state authority is still player1. So I'm 99% sure that's the problem but I can't figure out how to get to have state authority be player 2. See Player2prefab.png (this is during player mode)
-I've also tried changing CharacterController component to NetworkCharacterController component but same result (which makes sense, because that has nothing to do with authority). See PlayerPrefabComponents.png
-I have a GameController script in my Game Scene that spawns the players. See GameController.png.
-In my Lobby Scene, I have a FusionLobby script that sets GameMode to Sharedmode. See FusionLobby.png
-The way I move my player is in PlayerMovement script. See PlayerMovement.png
If anyone has any ideas, let me know. Thank you!

golden shard
#

i have a maze that gets generated but it wont generate for all players the same

sharp axle
golden shard
sharp axle
golden shard
#

okay i try it

finite remnant
# elder kestrel show your websocket code
public void SendMessageWs(TouchData message, string command)
        {
            string messageJson = JsonUtility.ToJson(message);

            JsonMessage jsonMessage = new JsonMessage
            {
                data = messageJson,
                command = command
            };

            string json = JsonUtility.ToJson(jsonMessage);

            if (_ws != null && _ws.IsAlive)
            {
                _ws.Send(json);
                //Debug.Log("Sent message: " + json);
            }
        }
pliant bluff
#

how to serialize random.state to turn it into a networkvariable?

#

i guess turning it into json string

sharp axle
pliant bluff
#

reset the seed to a new one??

sharp axle
pliant bluff
sharp axle
pliant bluff
molten hazel
#

Hello, is it default behaviour for my clients to not receive Network Manager Scene Events when the host calls NetworkManager.SceneManager.LoadScene()?

they only receive messages after the host has already loaded into the scene?? (which seems odd considering its meant to be synchronous)

molten hazel
sharp axle
unique moss
#

Does anyone have any good resources to help me get the hang of netcode for gameobjects?

I want to use steam for matchmaking and etc but I don't understand how using steam as the transporter actually works... I just end up with a weird situation where I have to handle 2 connections and can't wrap my head around what I'm meant to be using to do what?

EG: I start a steam host. I start a unity host... Then what? I don't understand how I'm meant to manage the connection if you get what I meant?

sharp axle
# unique moss Does anyone have any good resources to help me get the hang of netcode for gameo...
GitHub

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

unique moss
#

I've watched a lot of videos on it but they mostly seem incomplete, out of date or just wrong?

#

As soon as I get my 2nd account to connect, I get these

#

It confuses me because on both games I can clearly see the 2 players spawned, I connect to them through steam but I am getting that warning that client 0 isn't in a connected state? Which is what.. Me the host?

#

Oh okay... so when I disable the movement script on !IsOwner instead of destroying the script, it doesn't all break... Why is that?

sharp axle
unique moss
#

I see, makes sense. Well it seems the networking stuff is actually working after all.

I guess now that I can join lobbies via steam, I just have to do all the networking using the Netcode for gameobjects way

#

Okay I think I have the hang of it now. Thanks Moon_JJ_Love

molten hazel
molten hazel
#

Would you know another way of holding back the host from loading into the scene?

sharp axle
molten hazel
molten hazel
#

unless youre referencing other scene events...

sharp axle
molten hazel
molten hazel
molten hazel
molten hazel
#

so any event called should show a sign

sharp axle
molten hazel
#

and i use NetworkManager.SceneManager.LoadScene() to load a scene

molten hazel
sharp axle
molten hazel
molten hazel
#

cuz i haven't set it to false at any point

molten hazel
sly lily
#

Hey, i have a problem, i have a game with 2 players with lobby and relay and it works normally, but when one of the players quits to menu, i disconnect the connection with Network.shutdown(), but when the players connect again and go to the gamescene, i get this error

#

and the client player doesnt spawn

wicked tundra
#

Does anyone know how to join games via P2P by using a generated code rather than IP address?

wide girder
noble sapphire
wicked tundra
#

So for my current P2P i have to connect via IP address but for games like among us they connect via a code to join a host lobby so i was wondering if theres a way to "disguise the IP with a generated code"

wide girder
#

You should be clear about that.

wicked tundra
#

Ye

sharp axle
wicked tundra
#

Like game code but still sounds progammy so dont know the right term

#

Oh really?

#

even like small games

wide girder
#

Probably a relay or matchmaking service/server.

noble sapphire
#

Well i did say that wrong, i probably should have said session IP

#

my bad

wicked tundra
tough loom
#

hey guys, im using unity relay for multiplayer but somthing weird is happening, it used to work perfectly but now the player spawns for the host, but on the clients side nothing happens. im not sure when this error started happening but recently i went from unity version 2022 to 2023 so does that have to do with it ?

#

and if not do you guys have any solutions ?

sharp axle
tough loom
tough loom
# sharp axle You are seeing the player objects for the other clients on the host? You'll need...

public async void JoinRelay(string joinCode)
{
try
{
Debug.Log("Joining Relay with " + joinCode);
JoinAllocation joinAllocation = await RelayService.Instance.JoinAllocationAsync(joinCode);

     RelayServerData relayServerData = new RelayServerData(joinAllocation, "dtls");

     NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);

     NetworkManager.Singleton.StartClient();

 }
 catch (RelayServiceException e)
 {
     Debug.Log(e);
 }

 //StartMenu.SetActive(false);

}
this is the code and it doesnt give any errors

#

it just says Joining Relay with XXXXXX

sharp axle
#

Any errors would be happening sometime after Start client. If the players are spawning on the host then there is no issue with the connection.

tough loom
#

the player spawns at the host

#

but on the client nothing happens

tough loom
#

do you know what it is ?

sharp axle
rare ivy
#

Hey guys, I'm trying to make a 2D multi-player side scroller but I'm having camera issues. I've tried making it into a child of the player but due to the player's rotation flipping when they go left, the camera flips as well. Is there anyway to fix that or another method I could follow?

faint cedar
sharp axle
sharp axle
quasi obsidian
#

Hey so ive had this bug for over a month and i cant fix it. I think I had it in the past but I cant remember how I fixed it. So my player uses
-Network Rigidbody
-Client Network Animator (Only thing working properly)
-Network Object
-Client Network Transform
The player is Client authourative and it is completely broken. It stays in the same spot that it spawns in and doesnt fall, which makes me think the Net Rigidbody is broken.
Its rotation and position also updates with huge gaps which makes me think the transform is messed up in some way. The Net Object might also have issues. It was working fine on my old player and all the settings are EXACTLY the same. I completely redid the prefab with a new model and ragdoll and it just doesnt work anymore. I also verified that it isn't just the separated body that isn't catching up but the whole Object itself. Any reason why this might happen??
(For reference I am using NFGO with steamworks)

pearl girder
#

any guides for connecting to UGS from a Netcode dedicated server?

unique moss
#

Figuring out networking is a pain... I'm not sure what is synced and what isn't, so far it seems that practically nothing is synced and I feel I'm definetely going the wrong route to try and sync things...

I was thinking of having a PlayerConnectionHandler which would have this clas

    public class Player
    {
        public string name;
        
        public ulong clientID;
        public int playerId;
        public ulong steamID;

        public GameObject character;
    }
    ```
And then I'd store it in a dictionary
```csharp
public static Dictionary<ulong, Player> players = new();```
Can just use the client ID to get all the players information then but I have no idea how to sync this dictionary
#

So to populate that I have the event

    private void OnClientConnected(ulong clientID)
    {
        Debug.Log($"Unity: New client connected with ID {clientID}");
        if (IsHost)
            playerConnections.AddPlayer(clientID);
    }```
Which calls this function
```csharp
    public void AddPlayer(ulong clientId)
    {
        Player newPlayer = new Player();

        newPlayer.clientID = clientId;
        newPlayer.playerId = AssignPlayerNumber(clientId);
        
        GameObject playerInstance = Instantiate(playerPrefab);
        playerInstance.GetComponent<NetworkObject>().SpawnAsPlayerObject(clientId);
        
        players.Add(clientId, newPlayer);
    }```
And a script on the player
```csharp
public override void OnNetworkSpawn()
    {
        Debug.Log("On network Spawn", this);
        if (!IsOwner) return;
        PlayerConnectionHandler.FinalizePlayerSetupServerRpc(NetworkManager.Singleton.LocalClientId, SteamClient.SteamId, SteamClient.Name);
    }```
which goes back to my connection handler
```csharp
    [Rpc(SendTo.Server)]
    public static void FinalizePlayerSetupServerRpc(ulong clientID, ulong SteamID, string name)
    {
        players[clientID].steamID = SteamID;
    }```
And that's where I am at....
#

This all seems like way too overcomplicated for what I want to do

#

At this point, none of it is even synced with the players, not even sure how to go about doing that

dapper eagle
pearl girder
#

hmm, damn, we've got a hybrid of self hosted and amazon fargate hosted game servers

#

probably just roll a basic api interface for now and make the rest calls myself

sharp axle
sharp axle
unique moss
#

I'm not sure what I'm meant to be looping though? So I have a script on my players with the network variable for their steam ID and Player ID but I don't understand what you mean about looping through all the players?

#

Wouldn't I just have it on the "OnNetworkSpawn" to call a server RPC with the details and then the server update the dictionary? But how do I give all the players it? Can I just pass it with [Rpc(SendTo.NotMe)] when it's done?

sharp axle
#

You can use SendTo.Everyone if you still want to use RPCs

unique moss
#

The problem that I've had before is that I went the OnNetworkSpawn route which would then call all clients to update the textMeshPro.text and then when people joined after, they didn't have any of the names of people from before they joined

#

So I'm worried if I rely on locally updating the dictionary, that people who join late will be missing the players before them? like the text does

unique moss
sharp axle
#

You would send the player id and steam id in the RPC.
And I would have the player loop that Connected clients dictionary to get already connected players and grab their player id and stream id network variables

#

ConnectedClients[] might be server only though. In that case I would use FindObjectsByType()

unique moss
#

Do I always have to micro manage sending all the information back out when people join mid game? It's a hassle...

So what it seems I have to do is

  1. New Player Joins and sends their information to the server
  2. Server sends the new information to everyone
  3. Server sends all the player information to the new player
unique moss
#

I honestly thought unity would automate this, I thought the whole idea was that people join and then Unity makes sure that the new client matches the state of the game as they joined, I didn't realize I had to handle syncing everything up myself, I'm not quite sure what is kept synced and what isn't? Is there a rule of thumb with that?

sharp axle
#

You can make a NetworkVariable<Dictionary> but it's currently buggedr

unique moss
#

So scripts that need to sync, I would be best off having an "Awake" in it which sends a request to the server to be updated and have the server send the information of the object back?

sharp axle
#

A fix is in develop but not yet released

unique moss
#

Lets do an example with NetworkVariables because I haven't used them yet.. If I have enemies spawn and the player jumps in late, if I set the HP text in Awake would that be correct when the player joins?

Basically is the NetworkVariable updated before or after Awake?

rich basalt
tame slate
tame slate
rich basalt
#

Yeah I undestand that but latency is allready way to much

#

and interpolating would just higher it even more

tame slate
rich basalt
#

so its normal what I am getting here?

tame slate
#

The delay between the local and remote clients, yeah.

The jittering, not so much. Not sure how FishNet’s interpolation works but adjusting it should help to make the movement jitter-free.

rich basalt
#

Hm ok but lets be honest even if I move the background the situation wont be much better. Isnt there any solution to this? arent there any host/client games that need to have low latency because my kind of has to not in a competetive way but atleast a bit

tame slate
#

It means your players will be right next to each other the whole time without delay or jitter.

sharp axle
tame slate
#

And it’s also important not to fall in to the trap of comparing delay in side by side windows. As long as it isn’t effecting gameplay, latency is normal.

Something like a slight delay in background scrolling will be largely unnoticed by two clients playing on separate machines.

rich basalt
#

And for example idk if you know the game "stick fight: the game" but its a fighting game and with my latency im producing here that would be unplayable and its also client/host.

#

Sorry guys youre just trying to help

#

but thats disappointing

tame slate
rich basalt
#

no they have to go in circle round first fall down and then get up with ventilators and stuff

#

and flying rounds

tame slate
tame slate
rich basalt
#

No its host/client

tame slate
#

I’m aware that it is currently. I’m saying a dedicated server is probably the ideal choice for what you want to make.

rich basalt
rich basalt
rich basalt
tame slate
sharp axle
rich basalt
tame slate
#

The only reason it’s noticeable is because you’re only applying a constant downward force and staring at the windows side by side.

#

If the players were moving around the screen and only looking at their own screen, the delay is going to be a whole lot less noticeable.

rich basalt
#

I hope its ok that i send it here but as you can see this is a p2p game and I believe that the latency is 1/4 of mine

tame slate
#

If you're really unhappy with the delay, you can try increasing the tick rate of your server. It looks like in FishNet you can change that on TimeManager.

rich basalt
#

Ok thanks for your time I think Iam just trying to do the best out of it with: smoothing out, googeling about this prediction thing slowing the players down and hoping for the best! thanks

tame slate
stark hazel
#

Seemingly simple question, but I cannot find a good answer in the documentation. What is the idiomatic way to estimate server-client latency in Netcode for gameobjects ?

fluid walrus
sharp axle
#

Its in the NGO 2.0 branch. I don't know if it works with 1.x.

worthy harness
#

Hi everyone, I am researching for a top down 2d shooting game(ANDROID) that I am going to start working on, I want to add offline multiplayer in it where users can host/join the match by connecting to the same network with or without internet, I am trying this for the first time but am unable to find any good resources for this I was wondering if anyone here has worked on it before and can guide me through this or provide links to articles or tutorials. All that I found is at least 3,4 years old

sharp axle
# worthy harness Hi everyone, I am researching for a top down 2d shooting game(ANDROID) that I am...
GitHub

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

worthy harness
#

BTW thanks for the link I didn't know about this repo it will help a lot

sharp axle
worthy harness
rare ivy
#

Hey guys, I'm using Netcode for Gameobjects and everything is working with the exception of the character flipping. To flip I rotate the player but it doesn't show the other player flipping on their screen, it only shows them facing 1 way. ``` private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);

    // rotate if we're facing the wrong way
    if (movement.x > 0 && !facingRight)
    {
        flip();
    }
    else if (movement.x < 0 && facingRight)
    {
        flip();
    }

}




private void flip()
{
    facingRight = !facingRight;
    playerSprite.transform.Rotate(0, 180, 0);
}```
rare ivy
unique moss
#

Am I blind? I remember networking in the past, the network manager would have latency simulation options but I can't find any

unique moss
#

https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator/
Why can't I add this component to anything? It doesn't exist and I urgently need it

The Network Simulator tool allows you to test your multiplayer game in less-than-ideal network conditions, enabling you to discover issues in simulated real-world scenarios and fix them before they surface in production. It facilitates simulating network events, such as network disconnects, lag spikes, and packet loss.

fluid walrus
unique moss
#

Yep

fluid walrus
#

do you have any errors in the log?

unique moss
#

None

#

I can start my game, I can play, I just can't add that

#

I have issues where some of my network stuff isn't syncing with clients not in my house and it's impossible for me to debug and fix it because I can't get latency locally... I can't get my friends to download my game every 2 minutes to test things and yeh... I have the package but that component just isn't showing up

tame slate
unique moss
#

Debug simulator?

tame slate
unique moss
#

Does that even need the package?

#

I thought that was a seperate thing

tame slate
unique moss
#

It lacks a lot of things though like testing disconnects and etc

#

I'm not using unitys transport anyway... But I'll see if I can use it just for testing, thanks. I still think it's weird that the scripts are not showing up in my add components at all

#

Even if it was deprecated, it should still be there?

tame slate
tame slate
#

Don't think it's built to work with other Transports

unique moss
#

Oh wait mine has unity transport 1.4.1 but I don't have the option to update

#

Nvm I see it

#

Thanks

#

Yeh that fixed it

#

I didn't realize my transport was outdated

raw stormBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

novel stratus
#

uhhh can someone help me a bit

tame slate
#

!ask

raw stormBOT
novel stratus
#

so with netcode, how do I synchronise rigidbodies and objects between clients?

tame slate
novel stratus
tame slate
novel stratus
#

prob missed smth

tame slate
novel stratus
#

headslapemoji

#

thank you

#

oop nothing changed

#

i thought it resolved for a sec

#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Netcode;
public class spinObject : NetworkBehaviour
{
public bool hammer = false;
public float rotationSpeed = 100f; // Speed in degrees per second

void Update()
{   
    if (!hammer)
        transform.Rotate(0.0f, rotationSpeed * Time.deltaTime, 0.0f, Space.Self);
    else
        transform.Rotate(0.0f, 0.0f, rotationSpeed * Time.deltaTime, Space.Self);

}

}

tame slate
novel stratus
#

shit

tame slate
#

NetworkTransform is designed to move objects from the server and it will automatically sync the position changes to all clients

#

You just need if (!IsServer) return; at the top of your Update function

novel stratus
#

ok ill just check if it is the local player

#

yeah

#

thanks

#

it stopped rotating

vagrant glade
#

Hi everyone 🙂
Anyone know some resources or tutorials about the Dedicated Server ?

sharp axle
shrewd violet
#

Hi, question. I want to use the Unity Cloud services Relay, Player Auth, and Lobby. With NGO
And I have "Multiplayer Services" (1.0.0-pre.1 with Unity 6000.0.15f1) installed, I also installed "Relay" and "Lobby" deps, but it throws ambigious reference everywhere
So I gess Multiplayer Services already includes this two deps? which one should I use?

sharp axle
tame slate
shrewd violet
#

ok, thank you

sharp axle
#

I would install the Widgets package as well.

neat surge
#

yo in what channel I could ask for help in general stuff?

shrewd violet
#

Im not sure if you were talking to me or someone else

sharp axle
shrewd violet
#

The only problem I see reading this, it that is uses matchmaker and multiplayer hosting, which afaik does not have free tier

sharp axle
severe ruin
#

Not able to get Network Transform in Owner Authority Mode to syncronize from the joining players side (that owns the transform), only the host clients character transform is syncornized.

Whenever i update the joning players "Slerp Position" settings through the inspector it seems to force the Network Transform to send an Update to the host....

Unity 6000.0.15f + Netcode For Gameobjects 2.0.0-pre.4

severe ruin
#

Is this a bug with these versions of netcode/unity? It seems tow work fine with the "AnticipatedNetworkTransform" but plain does not sync (unless fucking with it in the inspector) with a regular one? I cannot figure out why it is not syncing client -> host, only host -> client, it is owner autorative, and the client owns the object, everything else works, just not the networktransform.

unique moss
#

Can anyone help me figure out why this code doesn't work properly?

If there is no latency, like if I join from a local network laptop, the name updates.. But if I add artificial lag, when a player joins, they don't update the names of any players that joined before them? How am I meant to do this?

#

I really don't understand how I am meant to sync up the players...

severe ruin
sharp axle
sharp axle
unique moss
#

Oh I think that is left over when I tried to manually spawn objects myself, but it ended up harder

#

And the value is set, it's in the code in "IsOwner" and the host always stays up to date... Like if 4 people join then it has all 4 names correct

#

But if a 3rd player joins it doesn't have player 1 or 2's

sharp axle
high night
#

Hello, what's the current state of networking assets in unity?

I am looking to have this sort of an architecture:

  • Client Server
  • Fully server authoritative
  • Tick based and fixed delta time
  • Clients rollback on predicted object(s)

I have been trying out fishnet for quite some time but its predictive features seem to change quite often.
And the latest version doesn't seem to have any examples.

dry maple
high night
analog tide
#

Hello, i'm trying to make a system where :
When you lunch the game you spawn in a lobby where you can move (this is done)
When you join an other lobby you spawn at a specific coord and the player who joinded he can see the other players (here is my problem)

I can't manage to spawn the players for the one who is joining and i have this message
NetworkPrefab could not be found. Is the prefab registered with NetworkManager?

#
if (NetworkManager.Singleton.IsServer)
  {
    foreach (var client in NetworkManager.Singleton.ConnectedClientsList)
    {
        if (client.ClientId == NetworkManager.Singleton.LocalClientId) continue;
        player = Instantiate(playerPrefab);
        player.GetComponent<NetworkObject>().SpawnWithOwnership(client.ClientId);
    }
 }``` here is the code where i try to spawn the player
tame slate
sharp axle
analog tide
#

well it was saved but got deleted i'm trying by re binding it

#

well it worked that was quite fast

#

thank's guys

pliant bluff
#

why this not working

sharp axle
# pliant bluff

Is what not working? Is it not connecting or the debug simulator not working?

shrewd violet
#

Hi.
Im trying to hide a player object (from ALL people on the session including himself).
so, im doing this:

public class PlayerHiding : NetworkBehaviour
{
    public override void OnNetworkSpawn()
    {
        if (IsOwner)
            gameObject.SetActive(false);
    }
}

But this gives a problem the second time, not the first time, I start the network manager. It starts spamming this error every frame:
MissingReferenceException: The object of type 'Unity.Netcode.NetworkObject' has been destroyed but you are still trying to access it.

When I remove this line, everything works perfectly. how can I achieve this?

#

NGO: 2.0.0 Pre.4
Unity: 6000.0.15f1
just in case

waxen quest
#

Is there a way to buffer RPC in Netcode?

dry maple
waxen quest
dry maple
waxen quest
#

I think Netcode in built does not support it yet

waxen quest
#

Buffered RPC are actually very useful

ripe mesa
ripe mesa
#

I once tied with buffered RPC, but they are actually bad

waxen quest
# ripe mesa whats your use case

The Timer starts for other player via RPC. And when new player join the timer does not start for it because that player was not there when RPC triggered

#

I know a workaround for it but wanted to know if RPC buffering can be done

waxen quest
dry maple
ripe mesa
#

the buffered RPC was the workaround. The solution is using timestamp

waxen quest
dry maple
#

Buffered RPCs in my opinion is one of the worst ideas in game networking.

waxen quest
ripe mesa
waxen quest
waxen quest
dry maple
tame slate
waxen quest
tame slate
pliant bluff
stray moth
#

Anyone here messed with client side prediction alot,I have a few questions regarding principles you should follow when doing client side prediction

ornate zinc
#

I am currently trying to figure out, how to share webcamtextures from different users across the network. Is there any reasonable solution available or should I just fetch the webcamtextures data and send it over websocket or similar?

dry maple
stray moth
#

because with it i need to do the replicate OnTick and reconcile OnPostTick but when i use the time manager instead of unity physics alot of bizzare stuff happens

dry maple
#

Unless there are mispredictions bugs etc.

stray moth
dry maple
stray moth
#

You think it will be a problem if i transfer over the fixed update code over to the replicate method that it might fix the issue?

stray moth
dry maple
stray moth
dry maple
grim carbon
#

Socket IO implementation in unity

stray moth
#

So its the same as fixed update

dry maple
# stray moth I wonder if it could be a bit of both

You could ask the author of that asset to help you find what the issue might be.

Ask them what variables change over time, that affect the movement of the vehicle?

Then you simply network those variables.