Is it possible to Spawn an AssetBundle in HLAPI?

Hello,

I’m using NetworkManager to manage the HLAPI network on my app, so I would like to download a new external 3D model as an AssetBundle and spawn it as I would do with a conventional Asset Prefab and keep all the spawning system features, in order to update the status of the object on clients when the object changes on the server.

I’ve already tried to download the AssetBundle and do a spawn on this object but I had this error:OnObjSpawn netId: 3 has invalid asset Id.

Any thoughts?
Is it really possible spawn an AssetBundle ?

I have the exact same problem… Were you able to figure out how to do this?

You have to register the asset / prefab from your assetbundle in the spawning system. You can use ClientScene.RegisterPrefab. Note that it’s important that this has to be done on each client and on each client the assetID must be the same. I’m not sure if an asset with a NetworkIdentity inside an AssetBundle gets a proper AssetID or not. If it has one you just need to call RegisterPrefab on all peers before you try to spawn them.

If they do not have an assetID you have to provide one yourself and you have to make sure all peers are using the same ID.

In any way all assetbundles have to be loaded and registered before the objects are spawned on the client. At least with the HL API. The spawn mechanic requires to spawn the object at the moment the spawn message arrives at the client. Even if you have a spawn delegate setup you can not delay the spawning until you may have downloaded the required assets. You may need to dig a bit deeper and handle the spawn network message yourself. Though this can result in various other issues. If a client is slow you have to handle the desync with the server until the client is ready to spawn the object. This would be quite tricky.

Since the majority of the HLAPI is open source you may want to get familiar with how it works under the hood.

Hey

Thanks for the info. Yeah that is what I had in mind. I think the problem is the assetID, i’ll see how I can provide an assetID myself.

Thanks a bunch!

Hallo, I have the same issue trying to spawn gameObjects from Asset bundle with network Id.
Can you assist me on how to do it ?
Thank you!