pub struct NavMeshAgent {
pub position: Vec2,
pub velocity: Vec2,
pub target: Vec2,
pub path: Vec<Vec2>,
pub speed: f32,
pub radius: f32,
pub arrival_threshold: f32,
/* private fields */
}Expand description
An agent that navigates the navmesh, following a computed path.
Fields§
§position: Vec2§velocity: Vec2§target: Vec2§path: Vec<Vec2>§speed: f32§radius: f32§arrival_threshold: f32Implementations§
pub fn new(position: Vec2, speed: f32, radius: f32) -> Self
Sourcepub fn set_destination(&mut self, dest: Vec2, navmesh: &NavMesh)
pub fn set_destination(&mut self, dest: Vec2, navmesh: &NavMesh)
Set a new destination and compute a path on the given navmesh.
Sourcepub fn update(&mut self, dt: f32, _navmesh: &NavMesh)
pub fn update(&mut self, dt: f32, _navmesh: &NavMesh)
Update the agent’s position by stepping along its path.
Sourcepub fn is_at_destination(&self) -> bool
pub fn is_at_destination(&self) -> bool
Returns true when the agent has reached its destination.
Sourcepub fn steer_toward_path(&self) -> Vec2
pub fn steer_toward_path(&self) -> Vec2
Compute a normalised steering direction toward the current path waypoint.
Sourcepub fn remaining_distance(&self) -> f32
pub fn remaining_distance(&self) -> f32
Distance remaining along the current path.
Trait Implementations§
Source§fn clone(&self) -> NavMeshAgent
fn clone(&self) -> NavMeshAgent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
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
Mutably borrows from an owned value. Read more
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>
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.