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

Dedicated Server Collision Rpcs

Discussion in 'Multiplayer' started by everystone, Feb 26, 2016.

  1. everystone

    everystone

    Joined:
    Jan 30, 2014
    Posts:
    7
    Hi,

    Im working on a 2d Multiplayer sidescroller, and up until now I have only worked with a Host(server+client), and a couple of Clients, which works fine. Now I want to implement a headless Dedicated Server mode.
    Currently a Player object calls a Cmd(), which invokes a ClientRPC on the player which locally instantiates a weapon object, and parents himself to the weapon. In OnCollisionEnter2D of the player, I check if (IsServer), and do collisions. This works.

    But when using StartServer() instead of StartHost() in my NetworkManager class, I discovered that ClientRPC's are not ran on the server ( because there are no local players, which I guess is logical).
    In my case I do collision detection only on server, but without it receiving the clientrpc's, the server-side players are missing weapon objects etc so of cource no collisions are registered.

    What are the best practise in this situation? Do i need to do a check for "if in dedicated server mode, run all these methods twice, locally on server and then in Rpc's to clients" ? Or should I just do collisions client-side and report hits via Cmds? How are you doing it?

    Cheers