Skip to main content

Shortest Path

Pro Feature

Pro features are only available with a Professional licence. To upgrade, visit cavalry.scenegroup.co.

Intro

Generates Paths by finding the shortest path between a start and end position via a Distribution of Points.

The algorithm calculates the shortest path by:

  1. Starting at a given position along an Input Path.
  2. Searching for neighbouring points within a Distribution. By default this is the nearest 10 points but can also be based on a Search Distance.
  3. Choosing the neighbouring point closest to the end position and moving to it.
  4. Looping through steps 2 and 3 until the path reaches the end position.
Using a Text Shape to generate several Shortest Paths.

UI

Common Attributes +

Input Shape - Connect a Shape to generate the start and end positions from.

Count - Set the number of Paths to generate.

Start Travel - Set the position along the Input Shape for the start of the Shortest Path. If Count is greater than 1, connect a Behaviour to vary the positions for each path.

End Travel - The position along the Input Shape for the end of the Shortest Path. If Count is greater than 1, connect a Behaviour to vary the positions for each path.

Use Search Radius - By default, the closest 10 points are used to calculate the shortest path – with Use Search Radius checked, the Search Radius can be used for greater control.

Search Radius - Set a maximum radius to search within to find 'the next point' the shortest path should travel along.

Use Levels - When checked, determine which level of the Input Shape to use to create start/end positions from.

Level Mode - Choose which level(s) of a Mesh's hierarchy to affect.

  • Custom... - Manually set a Custom Level.
  • Text (Lines) - Used with a Text Shape, this will affect each line.
  • Text (Words) - Used with a Text Shape, this will affect each word.
  • Text (Characters) - Used with a Text Shape, this will affect each character.
Sub-Meshes

If using a Text Shape with the string TEXT as an Input Shape, the Level Mode can be used to determine where the start/end positions are created from/to. For example, if set to Text (Characters), the start and end points must both be positioned along each individual letter (T, E, X or T) whereas if set to Text (Words), the start and end points can be generated anywhere along the whole word. For example, the start could be positioned along the first T with the end being positioned somewhere along the X.

Custom Level - Set a custom level.

Points Distribution - Select a Distribution to create the points for the Shortest Path algorithm to search within.

Draw Debug Information

Shortest Path supports the Draw Debug Information option in the Viewport settings which can be used to preview the Points within the Points Distribution.

Example
  1. Create an Ellipse.
  2. Set its Radius to 200,200.
  3. Create a Shortest Path.
  4. Connect ellipse.idshortestPath.inputShape.
  5. Set the Shortest Path's Count to 20.
  6. Right click on the Start Travel Attribute and choose Add Behaviour > Random.
  7. Set the Random's Maximum to 1.
  8. Change the Random Distribution's Seed value on the Shortest Path.
Mask Distribution

A Mask Distribution can be used to ensure only the points inside the Shape will be considered for the Shortest Path.