Position doesn't have any behaviour, it's just accessed by a bunch of things. Should it even be a component?
Just data without behavior is pretty much the definition of a component in ECS.
I have the components Position and Gravity. Gravity needs to access Position.
No, it doesn't. In an idiomatic ECS architecture, components don't have dependencies because they don't contain any logic. Components are just dumb data. All the logic is in the systems.
The Gravity System, however, is a different story. It needs access to the Gravity component and the Position component of all entities which have both these components. Systems which implement interactions between two components are pretty common in ECS architectures. Such systems of course depend on both of those components. The ECS architecture is responsible for providing such systems with access to all the component-tuples that are relevant for them.
You say that
Position
does not have any behaviour, but so doesGravity
: it's just a value. Behaviours should be stored in the Systems.Do your entity each need a different value for the
gravity
? If it's the same for all entities, then it should be set as a parameter to yourPhysics
system.I'm not sure we have enough details about the issue you're facing, and about your architecture to give you a definitive answer.
– Vaillancourt Jan 28 '23 at 11:44