pub struct NavMeshAgent {
pub current_path: Vec<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>,
pub current_waypoint_index: usize,
pub target_position: Option<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>,
pub movement_speed: f32,
pub arrival_threshold: f32,
pub path_recalculation_threshold: f32,
pub agent_radius: f32,
pub agent_height: f32,
pub current_triangle: Option<usize>,
pub state: NavMeshAgentState,
pub distance_to_destination: f32,
pub avoidance_velocity: Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>,
}Expand description
Navigation agent component for navmesh-based movement.
Attach to an entity with a transform to enable pathfinding. Set a destination
via set_destination and the navigation system
will compute and follow a path.
Fields§
§current_path: Vec<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>Computed path as a list of waypoints.
current_waypoint_index: usizeIndex of the next waypoint to reach.
target_position: Option<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>Target destination (if any).
movement_speed: f32Movement speed in units per second.
arrival_threshold: f32Distance at which waypoints are considered reached.
path_recalculation_threshold: f32Distance target must move before path is recalculated.
agent_radius: f32Agent collision radius for navmesh queries.
agent_height: f32Agent height for navmesh queries.
current_triangle: Option<usize>Current navmesh triangle (for height sampling).
state: NavMeshAgentStateCurrent navigation state.
distance_to_destination: f32Remaining distance to final destination.
avoidance_velocity: Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>Velocity adjustment for local obstacle avoidance.
Implementations§
Sourcepub fn new() -> NavMeshAgent
pub fn new() -> NavMeshAgent
Creates a new navigation agent with default settings.
Sourcepub fn with_speed(self, speed: f32) -> NavMeshAgent
pub fn with_speed(self, speed: f32) -> NavMeshAgent
Sets the movement speed.
Sourcepub fn with_radius(self, radius: f32) -> NavMeshAgent
pub fn with_radius(self, radius: f32) -> NavMeshAgent
Sets the agent collision radius.
Sourcepub fn with_height(self, height: f32) -> NavMeshAgent
pub fn with_height(self, height: f32) -> NavMeshAgent
Sets the agent height.
Sourcepub fn with_arrival_threshold(self, threshold: f32) -> NavMeshAgent
pub fn with_arrival_threshold(self, threshold: f32) -> NavMeshAgent
Sets the distance threshold for reaching waypoints.
Sourcepub fn set_destination(
&mut self,
destination: Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>,
)
pub fn set_destination( &mut self, destination: Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>, )
Sets a new destination and triggers pathfinding.
Sourcepub fn clear_destination(&mut self)
pub fn clear_destination(&mut self)
Clears the current destination and stops movement.
Sourcepub fn current_waypoint(
&self,
) -> Option<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>
pub fn current_waypoint( &self, ) -> Option<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>>
Returns the current waypoint position.
Sourcepub fn remaining_waypoints(&self) -> usize
pub fn remaining_waypoints(&self) -> usize
Returns the number of waypoints remaining.
Sourcepub fn advance_waypoint(&mut self) -> bool
pub fn advance_waypoint(&mut self) -> bool
Advances to the next waypoint. Returns true if destination reached.
Trait Implementations§
Source§fn clone(&self) -> NavMeshAgent
fn clone(&self) -> NavMeshAgent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§fn default() -> NavMeshAgent
fn default() -> NavMeshAgent
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<NavMeshAgent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NavMeshAgent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 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<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<T> FromFormData for Twhere
T: DeserializeOwned,
impl<T> FromFormData for Twhere
T: DeserializeOwned,
Source§fn from_event(ev: &Event) -> Result<T, FromFormDataError>
fn from_event(ev: &Event) -> Result<T, FromFormDataError>
submit event.Source§impl<CustErr, T, Request> FromReq<GetUrl, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<GetUrl, Request, CustErr> for T
Source§async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Source§impl<CustErr, T, Request> FromReq<Json, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<Json, Request, CustErr> for T
Source§async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Source§impl<CustErr, T, Request> FromReq<PostUrl, Request, CustErr> for T
impl<CustErr, T, Request> FromReq<PostUrl, Request, CustErr> for T
Source§async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
async fn from_req(req: Request) -> Result<T, ServerFnError<CustErr>>
Source§impl<CustErr, T, Response> FromRes<Json, Response, CustErr> for T
impl<CustErr, T, Response> FromRes<Json, Response, CustErr> for T
Source§async fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>
async fn from_res(res: Response) -> Result<T, ServerFnError<CustErr>>
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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> 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<CustErr, T, Response> IntoRes<Json, Response, CustErr> for T
impl<CustErr, T, Response> IntoRes<Json, Response, CustErr> for T
Source§async fn into_res(self) -> Result<Response, ServerFnError<CustErr>>
async fn into_res(self) -> Result<Response, ServerFnError<CustErr>>
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SerializableAny for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§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.