Search Unity

Third Party Mod object spawning with Mirror Networking

Discussion in 'Multiplayer' started by Sethtek_Dev, Dec 13, 2019.

  1. Sethtek_Dev

    Sethtek_Dev

    Joined:
    Feb 4, 2017
    Posts:
    44
    Hello!
    I'm currently trying to make a system that will spawn objects loaded in from a mod (AssetBundle), and then be spawned on the server and across all clients for them to play around with.

    I have a "ModContentManager" which is on every client. It does what its name represents. haha
    Inside that manager, it has a few lists which contain the mod's content by their type. But there's also just a basic GameObject list called "Prefabs". This script is on every client, including the server.

    I have made a semi-working system where the client will load the map that the server has loaded, by the server sending the map's name to the client. Then the client's MCM attempts to see if it has that map. And if it does, it will load it.

    Now the next step for my game is to incorporate custom objects such as Props, Vehicles, GameObjects, etc.
    I originally created a system where the NetworkManager would register every prefab from the server/client's ModContentManager in the "RegisteredSpawnablePrefabs" list.

    I would run the game in singleplayer mode, which is just one player, localhost server. And everything runs fine.

    Then I run into a problem when trying to get the spawned object to the clients for them to play with.

    I've attempted to get this working with multiple attempts over a couple of months now. My mind is just bogged down with confusion... and I need a bit of help understanding how to get this to work if possible. (Which I'm pretty sure it is)

    Some explanation of how I could do this, along with some examples would be very helpful.
    Side note: I do somewhat understand how to properly use [Command] and [ClientRpc]. But I'm not exactly sure if I am making a mistake with those somewhere.

    If you need any more information, or would like to see some of the code, just tell me what you need and I'll be glad to provide it.

    Thank you :>