pub struct NavigationAgent<V: NavVec> {
pub path: Vec<V>,
pub waypoint: usize,
pub max_speed: f32,
pub arrival_radius: f32,
pub waypoint_advance: f32,
pub desired_velocity: V,
pub avoidance: AvoidanceConfig,
pub avoidance_enabled: bool,
}Expand description
Follows a path returned by NavMesh::find_path
or NavMap::find_path.
desired_velocity seeks the current waypoint and slows into the final one
by arrival_radius. avoidance_velocity then feeds that desired velocity
through the reciprocal velocity obstacle resolver.
Fields§
§path: Vec<V>Current path, first point nearest the agent.
waypoint: usizeIndex of the waypoint being sought.
max_speed: f32Desired speed toward a waypoint.
arrival_radius: f32Distance to the final waypoint within which the agent stops.
waypoint_advance: f32Distance within which an intermediate waypoint counts as reached.
desired_velocity: VLast velocity produced by NavigationAgent::desired_velocity.
avoidance: AvoidanceConfigAvoidance tuning.
avoidance_enabled: boolWhen false, avoidance is a pass-through.
Implementations§
Sourcepub fn set_path(&mut self, path: Vec<V>)
pub fn set_path(&mut self, path: Vec<V>)
Replace the path and reset following to its first point.
Sourcepub fn clear_path(&mut self)
pub fn clear_path(&mut self)
Drop the path.
Sourcepub fn is_finished(&self, position: V) -> bool
pub fn is_finished(&self, position: V) -> bool
Whether the path is empty or the final waypoint is within
NavigationAgent::arrival_radius.
Sourcepub fn advance(&mut self, position: V)
pub fn advance(&mut self, position: V)
Advance past every waypoint the agent has already reached.
Sourcepub fn desired_velocity(&mut self, position: V) -> V
pub fn desired_velocity(&mut self, position: V) -> V
Seek the current waypoint, slowing into the final one. Caches the result
in NavigationAgent::desired_velocity.
Sourcepub fn avoidance_velocity(
&self,
position: V,
neighbors: &[AgentNeighbor<V>],
) -> V
pub fn avoidance_velocity( &self, position: V, neighbors: &[AgentNeighbor<V>], ) -> V
Apply avoidance to the cached desired velocity.
Avoidance runs in the navigation plane, so a 3D agent dodges on the ground plane while keeping the vertical component of its desired velocity (the slope). Deterministic for a given neighbour list.
Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
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> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.