#Data design for Selecting unit/position feature in strategy game as AOE.

1 messages · Page 1 of 1 (latest)

timid mesa
#

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.

lunar drum
#

i would start with less systems and if things grow unwildly or you require it for a specific feature set then split

#

i would have 1 system for managing selection (individual click, drag box around a bunch of units, cancel selection, selecting UI, etc)

#

then other systems can use this selection data without caring about how it was obtained

timid mesa
lunar drum
#

it should react to input

#

you don't usualyl select an object unless you click

timid mesa
lunar drum
#

no?

#

do you deselect all your units if you don't click them every frame?

#

hitting esc or something generally deselects things

timid mesa
lunar drum
#

esc would probably clear all selections?

#

but you could just deselect a single element if you want

#

and yeah that'd just be a remove from list

timid mesa
lunar drum
#

the escape key

#

on your keyboard

timid mesa