Closed as duplicate of#19564
Closed as duplicate of#19564
Description
Global command vs event:
commands.add(command);
commands.trigger(event);
Entity-local command vs event:
commands.spawn(bundle).add(entity_command).set_parent(parent);
{
let entity = commands.spawn(bundle).id();
commands.trigger_targets(event, entity);
commands.entity(entity)
}.set_parent(parent);
Or with a more ergonomic API (#14233):
commands.spawn(bundle).add(entity_command).set_parent(parent);
commands.spawn(bundle).trigger(event).set_parent(parent);
The difference remains that commands statically distinguish Command
and EntityCommand
, while events only have Event
, with observers having to determine at runtime whether their Trigger
includes an entity (currently that entails checking trigger.entity() == Entity::PLACEHOLDER
, see #14236).