|
|
|
|
|
by munksbeer
315 days ago
|
|
Could you give some intuition on why this is likely to be the case more frequently than accessing different values from a single entity? I'm not a games developer, so I don't have a good feel for why you'd need to iterate over every monster's health property in a tightly loop vs accessing each monster and calculating their position, what properties they have and updating one or more of their values in an iteration. |
|
Option 2 with something like an Entity-Component-System design would have a "Health" system that handles health updates across the board.
Neither of these options is strictly better than the other. Option 1 is good if you need a lot of bespoke logic for health updates (dragons update differently from humans which are different from vehicles etc.). Option 2 is better if everyone has `newHealth = oldHealth - damage`. Things are generally more similar than they are different, so you end up changing all values of a single "kind" (structures-of-arrays) more often.