pub enum RunFixedMainLoopSystems {
BeforeFixedMainLoop,
FixedMainLoop,
AfterFixedMainLoop,
}
Expand description
Set enum for the systems that want to run inside RunFixedMainLoop
,
but before or after the fixed update logic. Systems in this set
will run exactly once per frame, regardless of the number of fixed updates.
They will also run under a variable timestep.
This is useful for handling things that need to run every frame, but also need to be read by the fixed update logic. See the individual variants for examples of what kind of systems should be placed in each.
Note that in contrast to most other Bevy schedules, systems added directly to
RunFixedMainLoop
will not be parallelized between each other.
Variants§
BeforeFixedMainLoop
Runs before the fixed update logic.
A good example of a system that fits here
is camera movement, which needs to be updated in a variable timestep,
as you want the camera to move with as much precision and updates as
the frame rate allows. A physics system that needs to read the camera
position and orientation, however, should run in the fixed update logic,
as it needs to be deterministic and run at a fixed rate for better stability.
Note that we are not placing the camera movement system in Update
, as that
would mean that the physics system already ran at that point.
§Example
App::new()
.add_systems(
RunFixedMainLoop,
update_camera_rotation.in_set(RunFixedMainLoopSystems::BeforeFixedMainLoop))
.add_systems(FixedUpdate, update_physics);
FixedMainLoop
Contains the fixed update logic.
Runs FixedMain
zero or more times based on delta of
Time<Virtual>
and Time::overstep
.
Don’t place systems here, use FixedUpdate
and friends instead.
Use this system instead to order your systems to run specifically inbetween the fixed update logic and all
other systems that run in RunFixedMainLoopSystems::BeforeFixedMainLoop
or RunFixedMainLoopSystems::AfterFixedMainLoop
.
§Example
App::new()
.add_systems(FixedUpdate, update_physics)
.add_systems(
RunFixedMainLoop,
(
// This system will be called before all interpolation systems
// that third-party plugins might add.
prepare_for_interpolation
.after(RunFixedMainLoopSystems::FixedMainLoop)
.before(RunFixedMainLoopSystems::AfterFixedMainLoop),
)
);
AfterFixedMainLoop
Runs after the fixed update logic.
A good example of a system that fits here is a system that interpolates the transform of an entity between the last and current fixed update. See the fixed timestep example for more details.
§Example
App::new()
.add_systems(FixedUpdate, update_physics)
.add_systems(
RunFixedMainLoop,
interpolate_transforms.in_set(RunFixedMainLoopSystems::AfterFixedMainLoop));
Trait Implementations§
Source§impl Clone for RunFixedMainLoopSystems
impl Clone for RunFixedMainLoopSystems
Source§fn clone(&self) -> RunFixedMainLoopSystems
fn clone(&self) -> RunFixedMainLoopSystems
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RunFixedMainLoopSystems
impl Debug for RunFixedMainLoopSystems
Source§impl Hash for RunFixedMainLoopSystems
impl Hash for RunFixedMainLoopSystems
Source§impl PartialEq for RunFixedMainLoopSystems
impl PartialEq for RunFixedMainLoopSystems
Source§impl SystemSet for RunFixedMainLoopSystems
impl SystemSet for RunFixedMainLoopSystems
Source§fn system_type(&self) -> Option<TypeId>
fn system_type(&self) -> Option<TypeId>
Some
if this system set is a SystemTypeSet
.Source§fn is_anonymous(&self) -> bool
fn is_anonymous(&self) -> bool
true
if this system set is an AnonymousSet
.impl Copy for RunFixedMainLoopSystems
impl Eq for RunFixedMainLoopSystems
impl StructuralPartialEq for RunFixedMainLoopSystems
Auto Trait Implementations§
impl Freeze for RunFixedMainLoopSystems
impl RefUnwindSafe for RunFixedMainLoopSystems
impl Send for RunFixedMainLoopSystems
impl Sync for RunFixedMainLoopSystems
impl Unpin for RunFixedMainLoopSystems
impl UnwindSafe for RunFixedMainLoopSystems
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<S> IntoScheduleConfigs<Interned<dyn SystemSet>, ()> for Swhere
S: SystemSet,
impl<S> IntoScheduleConfigs<Interned<dyn SystemSet>, ()> for Swhere
S: SystemSet,
Source§fn into_configs(self) -> ScheduleConfigs<Interned<dyn SystemSet>>
fn into_configs(self) -> ScheduleConfigs<Interned<dyn SystemSet>>
ScheduleConfigs
.Source§fn in_set(self, set: impl SystemSet) -> ScheduleConfigs<T>
fn in_set(self, set: impl SystemSet) -> ScheduleConfigs<T>
set
.Source§fn before<M>(self, set: impl IntoSystemSet<M>) -> ScheduleConfigs<T>
fn before<M>(self, set: impl IntoSystemSet<M>) -> ScheduleConfigs<T>
Source§fn after<M>(self, set: impl IntoSystemSet<M>) -> ScheduleConfigs<T>
fn after<M>(self, set: impl IntoSystemSet<M>) -> ScheduleConfigs<T>
Source§fn before_ignore_deferred<M>(
self,
set: impl IntoSystemSet<M>,
) -> ScheduleConfigs<T>
fn before_ignore_deferred<M>( self, set: impl IntoSystemSet<M>, ) -> ScheduleConfigs<T>
set
. Read moreSource§fn after_ignore_deferred<M>(
self,
set: impl IntoSystemSet<M>,
) -> ScheduleConfigs<T>
fn after_ignore_deferred<M>( self, set: impl IntoSystemSet<M>, ) -> ScheduleConfigs<T>
set
. Read moreSource§fn distributive_run_if<M>(
self,
condition: impl SystemCondition<M> + Clone,
) -> ScheduleConfigs<T>
fn distributive_run_if<M>( self, condition: impl SystemCondition<M> + Clone, ) -> ScheduleConfigs<T>
Source§fn run_if<M>(self, condition: impl SystemCondition<M>) -> ScheduleConfigs<T>
fn run_if<M>(self, condition: impl SystemCondition<M>) -> ScheduleConfigs<T>
Source§fn ambiguous_with<M>(self, set: impl IntoSystemSet<M>) -> ScheduleConfigs<T>
fn ambiguous_with<M>(self, set: impl IntoSystemSet<M>) -> ScheduleConfigs<T>
set
.