I am gonna cast a ray from camera on Right mouse button down to choose unit/position on my screen.
Should I create 2 systems (1 for choosing unit, 1 for choosing position), both have Checking mouse input and casting ray logic in their OnUpdate()?
Or I should create 4 systems:
- 1 singleton data component H that contain RaycastHit and 1 bool.
- 1 system A that is responsible for checking mouse input + Casting ray, if it catch something, it will modify the data H (assign RaycastHit to H + make bool variable True).
- 1 system D will do the clean up work on data H at the end of frame (making bool variable False).
- 2 systems B and C (Choosing unit/position systems) will read the RaycastHit from data H then checking if that entity that hit by ray is Ground or Unit then they will process that data, 2 this systems will UpdateAfter system A and Update before system D.
Or any others design you can suggest me.
Thanks for reading.