Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Visibility affect children entities #3874

Closed
nicopap opened this issue Feb 6, 2022 · 4 comments
Closed

Make Visibility affect children entities #3874

nicopap opened this issue Feb 6, 2022 · 4 comments
Labels
A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible

Comments

@nicopap
Copy link
Contributor

nicopap commented Feb 6, 2022

What problem does this solve?

It's useful to "bulk" toggle the visibility of a group of entities.

What problems does it introduce?

User may want to toggle visibility of parent without affecting the visibility of the children. Typically, you might want some parent to become invisible while the children are still visible in cases where you also take advantage of parent/child relationship for Transform/GlobalTransform.

What solution would you like?

  • My best guess would be a ActualVisibility non-public component that is given to all children of Changed<Visibility> entities. This would also require updating the component on hierarchy changes.
  • To be able to decouple transform hierarchy from visibility hierarchy, it would be advisable to add a Inheritance component or as an additional field to Parent and Children that let the user select which property is inherited (as suggested by @alice-i-cecile ) Note: this might be worth it's own separate PR

What alternative(s) have you considered?

  • It might be possible to walk the hierarchy at render time to infer then whether to display or not the concerned entity.
  • Relations 🌈

Additional context

@nicopap nicopap added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Feb 6, 2022
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets D-Trivial Nice and easy! A great choice to get started with Bevy and removed S-Needs-Triage This issue needs to be labelled D-Trivial Nice and easy! A great choice to get started with Bevy labels Feb 6, 2022
@forbjok
Copy link
Contributor

forbjok commented Feb 9, 2022

I kinda feel like shoehorning multiple different types of hierarchical relations into one component is less than ideal. I can think of at least 3 different use cases for it, which in some cases may be mutually exclusive.

The most obvious, and main one it's already used for is transforms. In addition to that, there's also the organizational purpose of being able to easily despawn a related group of entities (which can also currently be done with it), but you may not necessarily always want that group of objects to be anchored to each other position-wise or inherit visibility from each other.

For example, you may want to spawn a boss that consists of multiple entities, where some of them are lesser enemies that should move independently of the main boss entity. I suppose in most cases you could work around this by using container entities that have no visual component and make the "main" boss entity a child of that component alongside the other associated enemies, but it still kinda feels to me like these different use cases should just be entirely separate things.

@SUPERCILEX
Copy link
Contributor

@alice-i-cecile This might be a duplicate of #838.

@alice-i-cecile
Copy link
Member

Agreed. Closing as a duplicate of #838.

@nicopap
Copy link
Contributor Author

nicopap commented Jun 22, 2022

Note that as discussed in #3723 For UI entities, it's possible to get that behavior by setting the display field of the Style component to Display::None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

4 participants