Search Unity

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:
    184
    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:
    1,560
    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.