pub enum RunFixedMainLoopSystem {
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(RunFixedMainLoopSystem::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 RunFixedMainLoopSystem::BeforeFixedMainLoop
or RunFixedMainLoopSystem::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(RunFixedMainLoopSystem::FixedMainLoop)
.before(RunFixedMainLoopSystem::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(RunFixedMainLoopSystem::AfterFixedMainLoop));
Trait Implementations§
source§impl Clone for RunFixedMainLoopSystem
impl Clone for RunFixedMainLoopSystem
source§fn clone(&self) -> RunFixedMainLoopSystem
fn clone(&self) -> RunFixedMainLoopSystem
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RunFixedMainLoopSystem
impl Debug for RunFixedMainLoopSystem
source§impl Hash for RunFixedMainLoopSystem
impl Hash for RunFixedMainLoopSystem
source§impl PartialEq for RunFixedMainLoopSystem
impl PartialEq for RunFixedMainLoopSystem
source§impl SystemSet for RunFixedMainLoopSystem
impl SystemSet for RunFixedMainLoopSystem
source§fn as_dyn_eq(&self) -> &dyn DynEq
fn as_dyn_eq(&self) -> &dyn DynEq
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 RunFixedMainLoopSystem
impl Eq for RunFixedMainLoopSystem
impl StructuralPartialEq for RunFixedMainLoopSystem
Auto Trait Implementations§
impl Freeze for RunFixedMainLoopSystem
impl RefUnwindSafe for RunFixedMainLoopSystem
impl Send for RunFixedMainLoopSystem
impl Sync for RunFixedMainLoopSystem
impl Unpin for RunFixedMainLoopSystem
impl UnwindSafe for RunFixedMainLoopSystem
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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>
. Box<dyn Any>
can
then be further downcast
into Box<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>
. Rc<Any>
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> DowncastSync for T
impl<T> DowncastSync for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<S> IntoSystemSet<()> for Swhere
S: SystemSet,
impl<S> IntoSystemSet<()> for Swhere
S: SystemSet,
source§impl<S> IntoSystemSetConfigs for Swhere
S: SystemSet,
impl<S> IntoSystemSetConfigs for Swhere
S: SystemSet,
fn into_configs(self) -> NodeConfigs<Interned<dyn SystemSet>>
source§fn in_set(self, set: impl SystemSet) -> NodeConfigs<Interned<dyn SystemSet>>
fn in_set(self, set: impl SystemSet) -> NodeConfigs<Interned<dyn SystemSet>>
set
.source§fn before<M>(
self,
set: impl IntoSystemSet<M>,
) -> NodeConfigs<Interned<dyn SystemSet>>
fn before<M>( self, set: impl IntoSystemSet<M>, ) -> NodeConfigs<Interned<dyn SystemSet>>
source§fn after<M>(
self,
set: impl IntoSystemSet<M>,
) -> NodeConfigs<Interned<dyn SystemSet>>
fn after<M>( self, set: impl IntoSystemSet<M>, ) -> NodeConfigs<Interned<dyn SystemSet>>
source§fn before_ignore_deferred<M>(
self,
set: impl IntoSystemSet<M>,
) -> NodeConfigs<Interned<dyn SystemSet>>
fn before_ignore_deferred<M>( self, set: impl IntoSystemSet<M>, ) -> NodeConfigs<Interned<dyn SystemSet>>
set
. Read moresource§fn after_ignore_deferred<M>(
self,
set: impl IntoSystemSet<M>,
) -> NodeConfigs<Interned<dyn SystemSet>>
fn after_ignore_deferred<M>( self, set: impl IntoSystemSet<M>, ) -> NodeConfigs<Interned<dyn SystemSet>>
set
. Read moresource§fn ambiguous_with<M>(
self,
set: impl IntoSystemSet<M>,
) -> NodeConfigs<Interned<dyn SystemSet>>
fn ambiguous_with<M>( self, set: impl IntoSystemSet<M>, ) -> NodeConfigs<Interned<dyn SystemSet>>
set
.