Prefer using Events to notify end of animations #37
Replies: 1 comment
-
Hi, thanks for the suggestion :-) Yes, using events is better for performance. Though the question is not really "should we use event instead of a But before going into performances, my main concern is ergonomy. And I think relying on the presence of a component makes it easy to query alongside other components. Like I can easily get all enemies that are animated, or all vehicles that are not animated, and directly access the other components too. Then when it comes to performance, I think there are two important things to consider:
Lastly, still trying to evaluate the cost-benefit balance, we have to consider that it may require a breaking change. And if it does, then it must come with obvious benefits. So, to summarize: I am open for it. But, I first want to observe a clearly compelling cost-benefit balance. P.S: Make sure to use the version 2.0.1 which actually contains an optimization to make the play component faster to insert/remove. |
Beta Was this translation helpful? Give feedback.
-
I found this incredible crate and use it for some cool game dev, it was really fun!
However, I also worked with the newly released
bevy_tweening
crate and needed a way to detect the end of animations to do some stuff. I proposed that we could use the same technique as you are using: removing aPlay
component. Unfortunately, we asked some ECS peeps about doing that compared to usingEvents
instead, their answer was that we should prefer usingEvents
for performances reasons.I know that the
Play
component plays more than this role of detecting the end of an animation, but maybe you would be interested in this. As I understand it is preferable to avoid adding/removing components too much from the ECS and prefer doing things like inbevy_tweening
by using theAnimator
and changing its state.Beta Was this translation helpful? Give feedback.
All reactions