NavMesh Character
Description
The NavMeshCharacter
component extends a Character
through composition, incorporating NavMesh
-based navigation. This enables a Character
to intelligently navigate through the world.
This component replaces the AgentCharacter
class from previous versions.
Properties
/// <summary>
/// Cached NavMeshAgent component.
/// </summary>
public NavMeshAgent agent
/// <summary>
/// Cached Character component.
/// </summary>
public Character character
/// <summary>
/// Should the agent brake automatically to avoid overshooting the destination point?
/// If this property is set to true, the agent will brake automatically as it nears the destination.
/// </summary>
public bool autoBraking
/// <summary>
/// Distance from target position to start braking.
/// </summary>
public float brakingDistance
/// <summary>
/// The ratio (0 - 1 range) of the agent's remaining distance and the braking distance.
/// 1 If no auto braking or if agent's remaining distance is greater than brakingDistance.
/// less than 1, if agent's remaining distance is less than brakingDistance.
/// </summary>
public float brakingRatio
/// <summary>
/// Stop within this distance from the target position.
/// </summary>
public float stoppingDistance
Public Methods
/// <summary>
/// Does the Agent currently has a path?
/// </summary>
public virtual bool HasPath()
/// <summary>
/// True if Agent is following a path, false otherwise.
/// </summary>
public virtual bool IsPathFollowing()
/// <summary>
/// Returns the destination set for this agent.
/// If a destination is set but the path is not yet processed,
/// the returned position will be valid navmesh position that's closest to the previously set position.
/// If the agent has no path or requested path - returns the agents position on the navmesh.
/// If the agent is not mapped to the navmesh (e.g. Scene has no navmesh) - returns a position at infinity.
/// </summary>
public virtual Vector3 GetDestination()
/// <summary>
/// Requests the character to move to the valid navmesh position that's closest to the requested destination.
/// </summary>
public virtual void MoveToDestination(Vector3 destination)
/// <summary>
/// Pause / Resume Character path following movement.
/// If set to True, the character's movement will be stopped along its current path.
/// If set to False after the character has stopped, it will resume moving along its current path.
/// </summary>
public virtual void PauseMovement(bool pause)
/// <summary>
/// Halts Character's current path following movement.
/// This will clear agent's current path.
/// </summary>
public virtual void StopMovement()
Events
/// <summary>
/// Event triggered when agent reaches its destination.
/// </summary>
public event DestinationReachedEventHandler DestinationReached;
Last updated