Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Can I separate the player script into clientplayer and serverplayer?

Discussion in 'Multiplayer' started by oyy, Sep 6, 2015.

  1. oyy

    oyy

    Joined:
    Sep 2, 2015
    Posts:
    6
    UNet is awesome. But I don't think mixup the client and server script is a good idea.

    When my project grow bigger, the player script become unmaintainable.


    For example,

    1 Two different methods belong two client and server can't have same name, I have to add Svr and Cli prefix to almost every methods.


    2 I can't designate member vars as server-only or client-only vars.


    In my code, Almost every method have a explicit designation.


    Glad to hear feedback. Thanks.
     
  2. Firoball

    Firoball

    Joined:
    Aug 6, 2015
    Posts:
    60
    You can always do some shared data exchange behaviour for using SyncVars and RPCs.
    Reference it in both client and server behaviour.
    You won't get around having a shared behaviour, but you should be able to seperate it from pure client / server functionality to some maintainable level.