Skip to content

Make Visibility affect children entities #3874

Closed

Description

@nicopap

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

Activity

  1. added
    C-FeatureA new feature, making something new possible
    S-Needs-TriageThis issue needs to be labelled
    on Feb 6, 2022
  2. added
    A-RenderingDrawing game state to the screen
    A-UIGraphical user interfaces, styles, layouts, and widgets
    D-TrivialNice and easy! A great choice to get started with Bevy
    and removed
    S-Needs-TriageThis issue needs to be labelled
    D-TrivialNice and easy! A great choice to get started with Bevy
    on Feb 6, 2022
  3. forbjok commented on Feb 9, 2022

    @forbjok
    Contributor

    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.

  4. SUPERCILEX commented on May 9, 2022

    @SUPERCILEX
    Contributor

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

  5. alice-i-cecile commented on May 10, 2022

    @alice-i-cecile
    Member

    Agreed. Closing as a duplicate of #838.

  6. nicopap commented on Jun 22, 2022

    @nicopap
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenA-UIGraphical user interfaces, styles, layouts, and widgetsC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions