pub struct NavmeshAgent { /* private fields */ }Expand description
Navmesh agent is a “pathfinding unit” that performs navigation on a mesh. It is designed to cover most of simple use cases when you need to build and follow some path from point A to point B.
Implementations§
Sourcepub fn set_threshold(&mut self, threshold: f32)
pub fn set_threshold(&mut self, threshold: f32)
Sets a new path recalculation threshold (in meters). The threshold is used to prevent path recalculation in case if a target’s position or the agent position haven’t significantly moved. This significance is defined by the threshold.
Sourcepub fn threshold(&self) -> f32
pub fn threshold(&self) -> f32
Returns the current path recalculation threshold (in meters). See Self::set_threshold
for more info.
Sourcepub fn set_radius(&mut self, radius: f32)
pub fn set_radius(&mut self, radius: f32)
Sets a new radius for the navmesh agent. The agent will use this radius to walk around corners with the distance equal to the radius. This could help to prevent the agent from being stuck in the corners. The default value is 0.2 meters.
Sourcepub fn radius(&self) -> f32
pub fn radius(&self) -> f32
Returns the current radius of the navmesh agent. See Self::set_radius for more info
about radius parameter.
Sourcepub fn calculate_path(
&mut self,
navmesh: &Navmesh,
src_point: Vector3<f32>,
dest_point: Vector3<f32>,
) -> Result<PathKind, PathError>
pub fn calculate_path( &mut self, navmesh: &Navmesh, src_point: Vector3<f32>, dest_point: Vector3<f32>, ) -> Result<PathKind, PathError>
Calculates path from point A to point B. In most cases there is no need to use this method
directly, because update will call it anyway if target position has moved.
Sourcepub fn update(
&mut self,
dt: f32,
navmesh: &Navmesh,
) -> Result<PathKind, PathError>
pub fn update( &mut self, dt: f32, navmesh: &Navmesh, ) -> Result<PathKind, PathError>
Performs single update tick that moves agent to the target along the path (which is automatically recalculated if target’s position has changed).
Sourcepub fn steering_target(&self) -> Option<Vector3<f32>>
pub fn steering_target(&self) -> Option<Vector3<f32>>
Returns current steering target which in most cases next path point from which agent is close to.
Sourcepub fn set_target(&mut self, new_target: Vector3<f32>)
pub fn set_target(&mut self, new_target: Vector3<f32>)
Sets new target for the agent.
Sourcepub fn set_position(&mut self, new_position: Vector3<f32>)
pub fn set_position(&mut self, new_position: Vector3<f32>)
Sets new position of the agent.
Trait Implementations§
Source§fn clone(&self) -> NavmeshAgent
fn clone(&self) -> NavmeshAgent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
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>. 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any. Could be used to downcast a trait object
to a particular type.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Any. Could be used to downcast a trait object
to a particular type.fn into_any(self: Box<T>) -> Box<dyn Any>
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<T> ScriptMessagePayload for T
impl<T> ScriptMessagePayload for T
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
self as &dyn AnySource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
self as &dyn AnySource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.