Closed thombruce closed 11 months ago
Problems:
First: In order to support moons and other satellites, the Orbit system needs to be able to query first for orbiting bodies then for bodies these are attached to (via the parent attribute on the orbit component). However I am unable to come up with a satisfactory solution to querying these similar entities twice... it's just not allowed. I'm probably trying to apply an OOP mindset to an ECS problem.
I had a second issue, but I've forgotten it. It might be covered above; will add if I recall it.
Okay, so I've had a little brainwave and I think the ECS way to do this is...
Orbitable
component with a Vec2 or Vec3The orbitable_update_system can be very simple:
pub fn orbitable_update_system(mut orbitables: Query<(&mut Orbitable, &Transform)>) {
for (mut orbitable, transform) in orbitables.iter_mut() {
orbitable.position = transform.translation;
}
}
And we would query this orbitable for the position of the "parent" body instead of the Transform which conflicts with querying for the same value as a mutable...
It's confusing. It's counter-intuitive... sort of. But it seems to work.
closes #37
By submitting this pull request, you agree to follow our Code of Conduct: https://github.com/thombruce/.github/blob/main/CODE_OF_CONDUCT.md
Internal use. Do not delete.