#0.17 trigger generic T: Event

3 messages · Page 1 of 1 (latest)

low trench
#

For 0.17 the internals of Event changed to have an associated type Trigger. If I try to trigger a generic Event like so:

fn generic_system<T: Event>(mut commands: Commands, query: Query<&Something<T>>)
{
  for event in &query {
    commands.trigger(event);
  }
}

I am running into this issue:

the trait bound `<T as bevy::prelude::Event>::Trigger<'_>: std::default::Default` is not satisfied

And with the suggestion I am not so sure what to do with the lifetime. All things I did not have to worry too much until now :D.

This is the real world usecase https://github.com/KirmesBude/bevy_trickfilm/pull/49

ionic wasp
#

This is most likely because you're trying to trigger an entity event as if it was a generic event.
Try:
commands.entity(entity).trigger(event)
or
commands.trigger_with(event, EntityTrigger)

low trench
#

I dont think that is a thing anymore in 0.17. I am running into the issue with non-EntityEvent (Event) as well