Allow Use And Registration of Generic Time Contexts#78
Merged
Multirious merged 71 commits intomainfrom Mar 5, 2026
Merged
Conversation
now tweens can be registered to fire on specific schedules per time context (common use: only fire fixed-ticked tweens on fixed update)
so that curves would only be sampled when relevant, and always sampled when relevant
so that, for example, fixed-time animations would only interpolate their tween values on fixed updates. This is crucial for them to work properly (for example, fixed translation tweens should only move their entities on fixed updates)
by adding a generic constructor and having the previous constructor call it defaultly
* separate plugins that should be registered ones, ones that should be registered per schedule and ones that should be registered per schedule and time context. * allow registering system sets per schedule (necessary for them to take effect) * allow adding tween systems to a specific schedule (necessary for the rest to work)
This prevents unnecessary breaking changes.
(Breaking) Add `schedule` field to `EaseKindPlugin`. Add `TimeCtx` generic to `EaseKindPlugin` with default to () Add `in_schedule` method to `EaseKindPlugin`. implement `Default` for `EaseClosurePlugin<()>` Update plugin to follow `TweenAppResource` deprecation while remaining backward-compatible. `EaseKindTypeRegistrationPlugin` and `EaseKindSystemRegistrationPlugin` is removed.
Add `TimeCtx` generic with default to `()` (Breaking) Add public `schedule` field. Add `in_schedule` method Rename `time_context_marker` to `marker` implement `Default` for `EaseClosurePlugin<()>` where schedule is `PostUpdate` Update plugin to follow `TweenAppResource` deprecation while remaining backward-compatible.
Add `TimeCtx` generic to `apply_asset_tween_system` Update `apply_asset_tween_system`'s query to filter for only tween with `TimeContext` Add `TimeCtx` generic to `asset_dyn_tween_system` Add `TimeCtx` generic to `asset_tween_system`
Add `TimeCtx` generic to `apply_component_tween_system` Update `apply_component_tween_system`'s query to filter for only tween with `TimeContext` Add `TimeCtx` generic to `component_dyn_tween_system` Add `TimeCtx` generic to `component_tween_system`
Add `TimeCtx` generic to `apply_resource_tween_system` Update `apply_resource_tween_system`'s query to filter for only tween with `TimeContext` Add `TimeCtx` generic to `resource_dyn_tween_system` Add `TimeCtx` generic to `resource_tween_system`
Add `TimeCtx` generic with default to `()` (Breaking) Add public `schedule` field and private `marker` field. Add `in_schedule` method implement `Default` for `DefaultInterpolatorsPlugin<()>` where schedule is `PostUpdate` Update plugin to follow TweenAppResource deprecation while remaining backward-compatible. Update systems to use `TimeCtx` Remove `DefaultInterpolatorsSystemRegistrationPlugin` Remove `DefaultInterpolatorsTypeRegistrationPlugin`
Add `TimeCtx` generic with default to `()` (Breaking) Add public `schedule` field and private `marker` field. Add `in_schedule` method implement `Default` for `DefaultDynInterpolatorsPlugin<()>` where schedule is `PostUpdate` Update plugin to follow TweenAppResource deprecation while remaining backward-compatible. Update systems to use `TimeCtx` Remove `DefaultDynInterpolatorsSystemRegistrationPlugin`
* it now takes TimeCtx generic with default of () * for_schedule constructor has been renamed to in_schedule * DefaultTweenEventPlugins now takes schedule as well, to register the default tween event plugins
* it now takes TimeCtx generic with default of () * on_schedule constructor has been renamed to in_schedule
- Add TimeCtx generic that defaults to `()` - Add private `marker` field (Breaking) - Add `in_schedule` constructor - Impl Default for `DefaultTweenEventPlugins<()>`
… + rustfmt format something Rename `animation_for_time_context` to `animation_in_time_context`
Multirious
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature
Previously, bevy_tween systems only support running in the default time context
().This PR adds support to register systems in arbitary time context to support some cases where running in non-default context is necessary, such as, playing animation in Fixed time which is required to be in sync with physic engines.
This PR is a continuation from Multirious/bevy_time_runner#15.
Changes
Breaking:
TimeCtxand fieldschedulewith the constructorin_schedule. This is used to specify the time context and schedule to register all the systems in.For example:
DefaultTweenPlugins::default()remains default for()time context withinPostUpdateschedule.DefaultTweenPlugins::<Fixed>::in_schedule(FixedLast)forFixedtime context withinFixedLastschedule.bevy_time_runner::TimeContext<TimeCtx>marker component with the complementary plugin registered. This also apply to all children of the animation entity. The library currently make sure that all animation spawned through the framework automatically includes this component, but if you do insert any animation components manually, you will have to make sure to include TimeContext component. Consult the docs for more details.enable_debugfield toTweenCorePlugin.BevyTweenRegisterSystems::add_tween_systemsnow expectsscheduleparameter.animation_in_time_context<T>()method toAnimationBuilderExtTimeCtxand changed query to only query for tweens entity withTimeContext<TimeCtx>component.Non-brekaing:
Add
component_tween_system_with_time_contextwhich is the same ascomponent_tween_systembut has the generic parameterTimeCtxAdd
component_dyn_tween_system_with_time_contextwhich is the same ascomponent_dyn_tween_systembut has the generic parameterTimeCtxAdd
resource_tween_system_with_time_contextwhich is the same asresource_tween_systembut has the generic parameterTimeCtxDeprecated
TweenAppResource. Though all plugins will continued to support it to remain compatible except plugin groups.Example
time_context_animationexample.Future Works
We can add additional debug warnings to catch cases where users may insert tween components to children manually but forgot
TimeContextcomponent.