Skip to content

Target::target and Target::target() return different entities #17112

Open
@aevyrie

Description

Bevy version

0.15

What you did

Added a picking observer.

What went wrong

.observe(|trigger: Trigger<Pointer<Click>>| {
            info!(
                "Clicked: picking target:{}, target():{}, observer():{}",
                trigger.target,
                trigger.target(),
                trigger.observer()
            );
        });

This prints out three different entities.

Additional information

Discussion on discord:

https://discord.com/channels/691052431525675048/749335865876021248/1324499473098870896

Consider renaming:

  • target: the entity on which the event is fired
  • listener/observed: the entity to which the observer is attached (was target)
  • observed_by: the entity which holds the observer component (was observer)
    • Can we just hide this entirely, and instead provide remove_observer? The fact that the observer lives on its own entity and is not actually a component on the listener is a confusing implementation detail that I think we should hide from the user.
    • As far as the user is concerned, they have no idea that .observe() spawns a new entity, to them, the API looks like they are attaching something to the "listener" entity.

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorC-DocsAn addition or correction to our documentationS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions