Struct yurei::components::MovingPlatformDriver
source · pub struct MovingPlatformDriver {
pub targets: Vec<Vec3>,
pub target_index: usize,
pub distance_threshhold: f32,
pub moving: bool,
}
Fields§
§targets: Vec<Vec3>
§target_index: usize
§distance_threshhold: f32
§moving: bool
Implementations§
source§impl MovingPlatformDriver
impl MovingPlatformDriver
sourcepub fn with_targets(targets: Vec<Vec3>) -> Self
pub fn with_targets(targets: Vec<Vec3>) -> Self
Examples found in repository?
examples/basic_movement.rs (line 57)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
fn setup_world(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// Spawn camera
commands
.spawn(Camera3dBundle {
transform: Transform::from_xyz(10.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
})
.insert(CameraController::default());
// Ground
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Box::new(200.0, 0.2, 200.0))),
material: materials.add(Color::GREEN.into()),
transform: Transform::from_xyz(0.0, -1.0, 0.0),
..default()
})
.insert(Collider::cuboid(100.0, 0.1, 100.0))
.insert(RigidBody::Fixed);
//Mover
let patrol_route = vec![Vec3::new(-5.0, 0.5, 0.0), Vec3::new(5.0, 0.5, 0.0)];
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Box::new(2.0, 0.2, 2.0))),
material: materials.add(Color::YELLOW.into()),
transform: Transform::from_xyz(25.0, 0.5, 0.0),
..default()
})
.insert(Collider::cuboid(1.0, 0.1, 1.0))
.insert(RigidBody::KinematicPositionBased)
.insert(Velocity::default())
.insert(MovingPlatformDriver::with_targets(patrol_route));
// Spawn Player
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Capsule::default())),
material: materials.add(Color::WHITE.into()),
..default()
})
.insert(YureiBundle::default())
.insert(Player);
// Light
commands.insert_resource(AmbientLight {
color: Color::ANTIQUE_WHITE,
brightness: 0.45,
});
}
pub fn current_target_location(&self) -> Vec3
pub fn update(&mut self, current_position: Vec3)
Trait Implementations§
source§impl Component for MovingPlatformDriverwhere
Self: Send + Sync + 'static,
impl Component for MovingPlatformDriverwhere
Self: Send + Sync + 'static,
Auto Trait Implementations§
impl RefUnwindSafe for MovingPlatformDriver
impl Send for MovingPlatformDriver
impl Sync for MovingPlatformDriver
impl Unpin for MovingPlatformDriver
impl UnwindSafe for MovingPlatformDriver
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist.§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids(
components: &mut Components,
storages: &mut Storages,
ids: &mut impl FnMut(ComponentId)
)
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere
F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>,
fn get_components(self, func: &mut impl FnMut(OwningPtr<'_>))
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates
Self
using data from the given [World]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>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.