Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Multiplayer Mod Support?

Discussion in 'Multiplayer' started by Sethtek_Dev, Mar 12, 2020.

  1. Sethtek_Dev

    Sethtek_Dev

    Joined:
    Feb 4, 2017
    Posts:
    44
    I'm trying to make a multiplayer game somewhat similar to Garry's Mod, but I'm running into an issue during testing/planning.

    I'd like to structure it similar to Minecraft Forge's server system. Where the server contains the mods people will play with. And it requires them to have those mods. But I'm not sure how to sync everyone's mod objects together.

    Currently, I have a ModContentManager that takes the content from the mod (An AssetBundle) and puts them into their own list. (Vehicles, Maps, Props, etc.) But none of the objects are synced.

    I originally ran a test where a player would spawn an object, but only sometimes it would spawn for the other players.

    I'm not sure what I should do... Could someone give me some insight on this? I'm currently very confused.
    If you need any info like code or screenshots, just ask and I'll be glad to give it.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Most games prevent joining a server without having the required mods. I'd suggest a similar system. Whether you want to just tell the user what mods they need to get, or automate the download/install of these mods on first join to the server, is up to you.

    I'm not clear if you're referring still to not having the required mods, or some network spawn syncing issue. If the latter the solution is probably specific to whatever network API you are using. For all I know you're just sending network spawn messages as unreliable messages and they are getting lost along the way.

    I'd tackle the network syncing issue first, without involving mod support, as a network syncing issue you can't fix will end up a deal breaker for any game.
     
  3. mineboy2468

    mineboy2468

    Joined:
    May 17, 2019
    Posts:
    12
    unrelated question for my current game, what system are you using for the multiplayer and how do you get it to sync player movements with little latency. i am currently using Photon (PUN) and have a script to Sync player movements but its very laggy even tho i have removed the rigid body from the player if its not thiers. thanks for the help and hopefully you do good on your game, maybe send the link so i could try it for my self one time. it seems fun!
     
  4. mineboy2468

    mineboy2468

    Joined:
    May 17, 2019
    Posts:
    12
    unrelated question for my current game, what system are you using for the multiplayer and how do you get it to sync player movements with little latency. i am currently using Photon (PUN) and have a script to Sync player movements but its very laggy even tho i have removed the rigid body from the player if its not thiers. thanks for the help and hopefully you do good on your game, maybe send the link so i could try it for my self one time. it seems fun!
     
  5. Sethtek_Dev

    Sethtek_Dev

    Joined:
    Feb 4, 2017
    Posts:
    44
    I'm using Mirror for my networking solution.

    For syncing, I'm just using Mirror's standard NetworkTransform component, and it works most of the time... But I haven't put it through any tough testing yet. I do have a few ideas though once I test it.
     
  6. mineboy2468

    mineboy2468

    Joined:
    May 17, 2019
    Posts:
    12
    Thanks so much, I’ll try mirror also is it hard or...
     
  7. Sethtek_Dev

    Sethtek_Dev

    Joined:
    Feb 4, 2017
    Posts:
    44
  8. Sethtek_Dev

    Sethtek_Dev

    Joined:
    Feb 4, 2017
    Posts:
    44
    Hey @Joe-Censored... I have been testing and fiddling with stuff. Syncing seems to work properly, but clients and servers can't send information to each other.

    I've found out about NetworkMessages from this forum post:
    I have tried following Mirror's documentation page about it, constructed something similar and attempted to test it... But I get this error:

    Unknown message ID 61784 connection(0)
    UnityEngine.Debug:LogError(Object)
    Mirror.NetworkConnection:InvokeHandler(Int32, NetworkReader, Int32) (at Assets/Mirror/Runtime/NetworkConnection.cs:275)


    The code for the message I send is inside of a Player Manager. Currently, I'm trying to make the client grab the server's map, check if it has it, and then load it if so.
    It's called for each player from an event in my Custom Network Manager called EventPlayerAdded which is called in the OnPlayerAdded method of the network manager.
    Code (CSharp):
    1. public class PlayerEventAnnouncement : MessageBase
    2. {
    3.     public string message;
    4. }
    5.  
    6. public void Announce(string message)
    7. {
    8.     PlayerEventAnnouncement announcement = new PlayerEventAnnouncement()
    9.     {
    10.         message = message
    11.     };
    12.  
    13.     NetworkServer.SendToAll(announcement);
    14. }
    15.  
    16. public void OnAnnouncement(NetworkConnection conn, PlayerEventAnnouncement announcement)
    17. {
    18.     Debug.Log("Announcement: " + announcement.message);
    19. }
    What's causing this error, and how could I fix it?
    Also do you have any tips on how I could get the most out of these NetworkMessages? Because I think they might just be the solution I've been looking for all along. :)