Netcode scene objects not spawning as expected

I’ve been using netcode with unity 6 and am having trouble understanding how to get scene objects on the server to spawn completely when clients connect. From reading the documentation, I put an enemy object with a network object and network transform in the scene. The enemy object prefab is listed in the network prefab list. When the scene loads on the server and a client connects the prefab is supposed to instantiate and run it’s “on network spawn”. The enemy is just a cube.

Currently the enemy cube loads on the client but none of the “on network spawn” or “start” methods run. When I run in force server mode I can see that the new work object needs to be manually spawned.

I don’t understand why this is happening. My expected result is that the enemy would not spawn until the client connects. When the client connects it’s network spawn would run.

You can see that the network manager scene management is checked.

Does anyone else have a way to have scene objects automatically spawn and have their start methods run?

You implemented those methods with the correct name (Start, not start) and signature (no parameters) in a class derived from NetworkBehaviour and that script is added to the game object being spawned, and the script is enabled on that object?

Yes, I created a new behavior that only runs network spawn and start and am running it in force server.

using UnityEngine;
using Unity.Netcode;

public class SpawnTest : NetworkBehaviour
{
   
    void  Start()
    {
        if (IsServer) { Debug.Log($"{gameObject.name} Start Spawn on Server"); } 
        if (IsClient) { Debug.Log($"{gameObject.name} Start on Client"); } 

    }
    
    public override void OnNetworkSpawn()
    {
        if (IsServer) { Debug.Log($"{gameObject.name} Network Spawn on Server"); }
        if (IsClient){Debug.Log($"{gameObject.name} Network Spawn on Client");
        }
        
    }
    
}

When I run force server and connect a client the enemy cube instantiates, syncs but doesn’t on network spawn until the “Spawn” button in the inspector is hit. My expected result is that it automatically runs on network spawn after it instantiates on the client. This behavior only happens when the enemy is a scene object. Instatiating through code works fine. I’m trying to understand how scene objects can be instantiated correctly and if that is supported by netcode.

I think I understand now. If I put the enemy in a scene with the network manager it will be automatically spawned as a scene object when the clients connect.

If it is in a scene object of a scene that is loaded additively that does not contain the network manager it will need to be explicitly spawned by code.

When first reading the documentation it says scene objects will be automatically spawned and I assumed this worked for additive scene objects.

Is this the expected result for other people? Thank you.

No. If the additively loaded scene contains an object with a NetworkObject component, and you load that scene on the server using NetworkSceneManager, then this object will get spawned.

If it’s not doing that for you, then perhaps the additive loading was done through UnityEngine.SceneManager or there’s no NetworkObject component.