Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Is it a good practice to directly access another system?

Discussion in 'Data Oriented Technology Stack' started by mnarimani, Aug 13, 2019.

  1. mnarimani

    mnarimani

    Joined:
    Mar 27, 2017
    Posts:
    216
    There are two ways for systems to communicate (afaik):
    1- System that wants to give the command creates an entity with specific component, then the system who wants to receive the command reacts on that component.
    2- System that wants give the command gets the other system with "GetOrCreateSystem" method. And calls methods on it directly.

    The second way seems a bit off. Since it creates coupling. But I have seen people doing it now and then.
    Is it a good practice?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    2,175
    Ideally no as it'd be nice to keep systems decoupled and modular and it leads to the question if a system needs to interact with another system should it just not be 1 system?

    However in practice sometimes it's just the best way but it does often lead to the mess of having to manually handle dependencies.
     
    mnarimani likes this.
unityunity