Skip to content

Get Entity from scene hierarchy #16201

Description

@Fidius-jko

What problem does this solve or what need does it fill?

For example i have player with sprite, and player have Hp and HpBar. I use separate entity for render HpBar . And when i update hpbar, i am getting player children and get first child. This is not comfortable.

What solution would you like?

Add functions for world:

impl World {
     fn get_entity_from_path(&self, path: &str) -> Entity {...}
     fn get_path_from_entity(&self, entity: &Entity) -> String {...}
     ...
}

Path will be like "EntityId or Name/EntityId or Name/...."

Example:

fn update_hp_bar(world: World) {
     ... Get Player entity
     let hpbar_entity = world.get_entity_from_path(world.get_path_from_entity(&player_entity) + "/hpbar");
     ... Process hpbar
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions