NetworkHelper doesn't sync

Started by bosinn 3 posts 152 views

Reply on sbox.game
  1. edited Apr 2026 #1
    bosinn 35
    I've placed spawn points, added NetworkHelper component, selected player prefab which is basically stock player component, pressed play button in editor and then pressed "Join via new instance"

    I've moved around between two instances and position with clothes doesn't synchronize. Is it bug or I'm doing something wrong?

  2. #2
    bosinn Started this 35
    Don't know what happened. I've recreated scene, placed player controller and made it prefab, placed prefab in "Network Helper" and it worked. Cloth still doesn't sync. I've patched "Network Helper" class to use ClothingContainer:
    public void OnActive( Connection channel )
    {
        Log.Info( $"Player '{channel.DisplayName}' has joined the game" );
    
        if ( !PlayerPrefab.IsValid() )
           return;
    
        //
        // Find a spawn location for this player
        //
        var startLocation = FindSpawnLocation().WithScale( 1 );
    
        // Spawn this object and make the client the owner
        var player = PlayerPrefab.Clone( startLocation, name: $"Player - {channel.DisplayName}" );
    
        // Assume that if they have a skinned model renderer, it's the citizen's body
        if ( player.Components.TryGet<SkinnedModelRenderer>( out var body, FindMode.EverythingInSelfAndDescendants ) )
        {
           var clothing = new ClothingContainer();
           clothing.Deserialize( channel.GetUserData( "avatar" ) );
           clothing.Apply( body );
        }
        
        player.NetworkSpawn( channel );
    }
  3. #3
    gasleet 6,923
    I had a similiar problem with the clothing of the players not working properly. Someone was always naked.
    I've fixed this by using the INetworkSpawn interface and applying the dresser. Atleast I think i fixed it...
    public sealed class MyComponent : Component, Component.INetworkSpawn
    {
    	public void OnNetworkSpawn( Connection connection )
    	{
    		dresser.Clear();
    		dresser.Apply();
    	}
    }