- Home /
Question by
Mantikator · Nov 28, 2020 at 03:54 PM ·
networkingspawningmirror
Mirror: Spawn dynamically created objects (not prefabs)
hey guys! I'm trying to spawn dynamically generated objects (not prefabs) during runtime, the same way on all clients and could use a hint!
I found out that I should use ClientScene.RegisterSpawnHandler() for that, but I don't know how to link the assetId to the NetworkIdentity...
_currentPiece = child.gameObject;
NetworkIdentity nwid = _currentPiece.AddComponent<NetworkIdentity>();
Guid pieceAssetId = Guid.NewGuid();
ClientScene.RegisterSpawnHandler(pieceAssetId, SpawnPiece, UnspawnPiece);
NetworkServer.Spawn(_currentPiece);
as you see, the pieceAssetId is newly generated, and has no connection to the NetworkIdentity the docs don't seem to explain this any further
Comment