Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Spawning objects from AssetBundle

Discussion in 'Connected Games' started by mr_okk, Apr 13, 2017.

  1. mr_okk

    mr_okk

    Joined:
    Feb 13, 2014
    Posts:
    2
    Hello everyone!

    Maybe someone did such task and can suggest some solution.
    I have two projects (i have more, but for this topic only two is important), first is a game client, second is for weapons.
    From second I build bundles with weapon prefabs. I want to use them in my game, but here is a little (maybe not so little) problem:
    I receive bundles, read information, register weapon with ClientScene.Register(weapon) and try to spawn it on server NetworkServer.Spawn(obj).
    In such case i have an error on a client: Failed to spawn server object, assetId=ca1770f47edb46c40935df64801824ee netId=3 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate().

    If I register object with assetId from this error (ClientScene.Register(weapon, assetId)), everything works fine. When assetId have any difference, nothing is spawning.

    Does someone know, how can I get right assetId? Or is there another way to spawn such objects.
     
  2. LTK

    LTK

    Joined:
    Jul 16, 2015
    Posts:
    22
    I have same issue, and my solution is write a editor to serialize assetId, and register when load asset.
    You can get assetId with NetworkIdentity.assetId :)
     
  3. Togias

    Togias

    Joined:
    Jul 17, 2017
    Posts:
    5
    Does assign a assetID during spawn overcomes that error?