This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

PathRoute Class

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.

This class calculates the shortest 2D or 3D route around the obstacles within connected navigation areas and sets the size and velocity of the point moving along this route.

  • In case of 2D route, a point moves in the lower plane of the navigation area. The Z coordinate is not taken into account when calculating the 2D route. The height and radius values set for the point via the setHeight() and setRadius() functions are used to check whether the navigation area can take part in pathfinding: if the height or radius set for the point is greater than the size of the navigation area, such navigation area will be discarded. If the height difference between the connected areas exceeds the maximum height, the navigation area is also discarded from calculations.
  • In case of 3D route (available only for navigation sectors), a point moves in 3 dimensions. The radius set for the point via the setRadius() function is used to check whether the navigation sector can take part in pathfinding: if the radius set for the point is greater than the size of the navigation sector, it will be discarded. Also the point cannot rise up higher than the maximum height set for the navigation sector.

Functions of the PathRoute class enable to ignore the specified navigation areas and obstacles. Also the maximum time acceptable to get to the destination point and the maximum danger factor can be limited as well.

Notice
To choose between navigation areas, A* algorithm is used.
Warning
  • There is no connection between functions of the PathRoute class and functions of the Path class.
  • 3D navigation feature is experimental and not recommended for production use.

See Also#

  • The Creating Routes usage example demonstrating how to create routes and recalculate them considering obstacles
  • A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/paths/ folder

PathRoute Class

Members


static PathRoute ( float radius = 0.0f ) #

Constructor. Creates a new 2D or 3D route. The radius is used to check whether the point can move inside a navigation area or this navigation area should be excluded from pathfinding.

Arguments

  • float radius - Radius of the point moving along the route.

float getDangerous ( ) #

Returns the highest danger factor of the navigation areas met along the route.

Return value

Highest danger factor

float getDistance ( ) #

Returns the length of the route.

Return value

Distance in units.

void setExcludeNavigations ( ) #

Sets the list of navigation sectors and navigation meshes to be ignored during pathfinding.

Arguments

    getExcludeNavigations ( int exclude_navigations ) #

    Returns the list of navigation sectors and navigation meshes excluded from pathfinding.

    Arguments

    • int exclude_navigations - Array to store the excluded navigation areas.

    Return value

    void setExcludeObstacles ( ) #

    Sets the list of obstacles to be ignored during pathfinding.

    Arguments

      getExcludeObstacles ( ) #

      Returns the list of obstacles ignored during pathfinding.

      Return value

      Container for obstacles.

      void setHeight ( float height ) #

      Sets the height that is required to move the point along the 2D route inside the navigation area. If the specified height exceeds the height of the navigation area, the point will not move inside it.

      Arguments

      • float height - Height that is required to move the point inside the navigation area. If a negative value is provided, 0 will be used instead.

      float getHeight ( ) #

      Returns the current height that is required to move the point along the 2D route inside the navigation area.

      Return value

      Height that is required to move the point inside the navigation area. If the returned height exceeds the height of the navigation area, the point will not move inside it.

      Obstacle getIntersection ( PathRouteIntersection intersection ) #

      Returns the first intersected obstacle.

      Arguments

      • PathRouteIntersection intersection - PathRouteIntersection node.

      Return value

      Intersected obstacle.

      void setMaxAngle ( float angle ) #

      Sets cosine of the maximum possible angle between navigation mesh polygons. For example, this option enables to exclude walls when calculating a valid route.

      Arguments

      • float angle - Maximum angle cosine.

      float getMaxAngle ( ) #

      Returns cosine of the maximum possible angle between navigation mesh polygons. For example, this option enables to exclude walls when calculating a valid route.

      Return value

      Maximum angle cosine.

      void setMaxDangerous ( float dangerous ) #

      Sets the maximum danger factor acceptable for moving along this route. If the navigation areas have a higher danger factor, the point will not move along it.

      Arguments

      • float dangerous - Maximum danger factor.

      float getMaxDangerous ( ) #

      Returns the maximum danger factor acceptable for moving along this route. If the navigation areas have a higher danger factor, the point will not move along it.

      Return value

      Maximum danger factor.

      void setMaxHeight ( float height ) #

      Sets the maximum height difference between the connected navigation areas acceptable when finding the 2D route. In case of the 3D route, it is the maximum height the point can move up to.

      Arguments

      • float height - Maximum height.

      float getMaxHeight ( ) #

      Returns the current maximum height difference between the connected navigation areas acceptable when finding the 2D route. In case of the 3D route, it is the maximum height the point can move up to.

      Return value

      Maximum height.

      void setMaxTime ( float time ) #

      Sets the maximum time for reaching the destination point. If the route takes longer, the point will not move along it.

      Arguments

      • float time - Maximum movement time.

      float getMaxTime ( ) #

      Returns the current maximum time for reaching the destination point. If the route takes longer, the point will not move along it.

      Return value

      Maximum movement time.

      Navigation getNavigation ( int num ) #

      Returns the navigation sector or mesh within which the specified route point is located.

      Arguments

      • int num - Point number.

      Return value

      Navigation sector or navigation mesh.

      void setNavigationMask ( int mask ) #

      Sets the navigation mask. The navigation mask of the navigation area must match the navigation mask of the route that is calculated within it. Otherwise, the area will not participate in pathfinding.

      Arguments

      • int mask - An integer value, each bit of which is used to set a mask.

      int getNavigationMask ( ) #

      Returns the current navigation mask. The navigation mask of the navigation area must match the navigation mask of the route that is calculated within it. Otherwise, the area will not participate in pathfinding.

      Return value

      An integer value, each bit of which is used to set a mask.

      int getNumPoints ( ) #

      Returns the number of turning points along the route.

      Return value

      The number of points.

      Obstacle getObstacle ( int num ) #

      Returns the obstacle around which the route is turning.

      Arguments

      • int num - Point number.

      Return value

      Obstacle.

      void setObstacleMask ( int mask ) #

      Sets the obstacle mask. The obstacle is taken into account if its obstacle mask matches the obstacle mask of the route.

      Arguments

      • int mask - An integer value, each bit of which is used to set a mask.

      int getObstacleMask ( ) #

      Returns the current obstacle mask. The obstacle is taken into account if its obstacle mask matches the obstacle mask of the route.

      Return value

      An integer value, each bit of which is used to set a mask.

      Vec3 getPoint ( int num ) #

      Returns the coordinates of the turning point in the route.

      Arguments

      • int num - Point number.

      Return value

      Point coordinates.

      int isQueued ( ) #

      Returns a value indicating that a route is queued to be calculated.

      Return value

      1 if the route is queued; otherwise, 0.

      void setRadius ( float radius ) #

      Sets the radius that is required to move the point along the route inside the navigation area. If the specified radius exceeds the size of the navigation area, the point will not move inside it.

      Arguments

      • float radius - Radius that is required to move the point inside the navigation area. If a negative value is provided, 0 will be used instead.

      float getRadius ( ) #

      Returns the current radius that is required to move the point along the route inside the navigation area.

      Return value

      Radius that is required to move the point inside the navigation area. If the returned radius exceeds the size of the navigation area, the point will not move inside it.

      int isReached ( ) #

      Returns a value indicating that a destination point of the route is reached.

      Return value

      1 if the destination point is reached; otherwise, 0.

      int isReady ( ) #

      Returns a value indicating that a route is calculated.

      Return value

      1 if the route is calculated; otherwise, 0.

      float getTime ( ) #

      Returns the time that is required for the point to move along the route.

      Return value

      Time in seconds.

      void setVelocity ( float velocity ) #

      Sets the velocity of the point that moves along the route.

      Arguments

      • float velocity - Velocity of the point that moves along the route.

      float getVelocity ( ) #

      Returns the current velocity of the point moving along the route.

      Return value

      Velocity of the point that moves along the route.

      void addExcludeNavigation ( Node navigation ) #

      Sets a navigation sector or a navigation mesh to be ignored during pathfinding. Excluded sectors/meshes are added into the list.

      Arguments

      • Node navigation - A navigation area to be ignored.

      void addExcludeObstacle ( Node obstacle ) #

      Sets an obstacle to be ignored during pathfinding. Excluded obstacles are added into the list.

      Arguments

      • Node obstacle - An obstacle to be ignored.

      void create2D ( Vec3 p0, Vec3 p1, int delay = 0 ) #

      Calculates a 2D route between the given points with the specified delay.

      Arguments

      • Vec3 p0 - The starting point.
      • Vec3 p1 - The destination point.
      • int delay - The number of frames which is possible to delay pathfinding calculations. 0 means the pathfinding should be calculated immediately.

      void create3D ( Vec3 p0, Vec3 p1, int delay = 0 ) #

      Calculates a 3D route between the given points with the specified delay.

      Arguments

      • Vec3 p0 - The starting point.
      • Vec3 p1 - The destination point.
      • int delay - The number of frames which is possible to delay pathfinding calculations. 0 means the pathfinding should be calculated immediately.

      void removeExcludeNavigation ( Node navigation ) #

      Removes a navigation sector or a navigation mesh from the list of ignored ones during pathfinding.

      Arguments

      • Node navigation - A navigation area.

      void removeExcludeObstacle ( Node obstacle ) #

      Removes an obstacle from the list of ignored ones during pathfinding.

      Arguments

      • Node obstacle - An obstacle.

      void renderVisualizer ( vec4 color ) #

      Renders the route in a given color.
      Notice
      You should enable the engine visualizer by the show_visualizer 1 console command.

      Arguments

      • vec4 color - Route color.
      Last update: 2020-07-31
      Build: ()