Add Network Object to a scene dynamically

Hey,

i have a scene where i am importing models on runtime (OBJ / FBX).

When importing a model on the host i would need to give the information what model it is to the client, so the client could import the same model.

Now I want to use those on runtime imported models as Network Objects to do some collaborative work with the models on Host or Client (transformation).

But they are not registered prefabs. Is there a way to register those new objects on runtime? Can i set the GlobalObjectIDHash myself on those imported objects so they would match?

Any help would be great,

Thanks,

Hank

You can just make a stand-in prefab for your models with a NetworkBehaviour and a NetworkVariable that contains the path to the model, and of course a MeshFilter and MeshRenderer but it suffices to assign it a cube.

You can then spawn as many of these stand-ins as you like, assign the path to the NetworkVariable which causes clients to receive the OnValueChanged event upon which they load the appropriate model.

However, you will have to transfer the model to the clients in some way. I'm working on a FileTransfer for Netcode asset that'll allow you to do that at runtime.

1 Like

Wow yes thanks thats a good idea, your FileTransfer for Netcode Tools sounds very cool - Thanks !