Transform List Sort
Sorts a Transform List using gameplay sort blocks.
This is useful when you want to rank targets by distance, size, data values, or other gameplay criteria before selecting one.
Parameters
| Parameter | Description |
|---|---|
| Transform List | The list of Transforms to sort. |
| Sort By | The primary sort block used to compare entries. |
| Direction | Sort order for the primary sort block: Ascending or Descending. |
| Then By | Optional secondary sort block used when two entries have the same primary result. |
| Then By Direction | Sort order for the optional secondary sort block. |
| Sorted | Optional output set to true when the list was sorted successfully. |
Notes
- The action sorts the list in place.
- If the list has fewer than two items, nothing changes.
- If a sort block cannot evaluate an item, that item is pushed later in the list.
- Secondary sorting is only used when
Then Byis assigned.
Available Sort Blocks
Distance To Target
Measures the distance from each Transform in the list to a target Transform.
| Parameter | Description |
|---|---|
| Target | Transform used as the distance reference. |
| Axis | Axis used for measuring distance, such as XY, XZ, or XYZ. |
This is the default sort block and is useful for nearest-target and furthest-target style ranking.
Size
Sorts the list by each Transform's size.
| Parameter | Description |
|---|---|
| Metric | Controls how size is measured. |
Available size metrics:
Auto: UsesRenderer.bounds.size.magnitudewhen a Renderer is present, otherwise usestransform.lossyScale.magnitude.RendererBoundsMagnitude: Uses the magnitude of the Renderer bounds size.RendererBoundsVolume: Uses the volume of the Renderer bounds size.LossyScaleMagnitude: Uses the magnitude of the Transform's world scale.LossyScaleVolume: Uses the volume of the Transform's world scale.
This is useful when you want to prioritize larger or smaller targets.
Data Field
Sorts the list using a field from a matching Data Component on each Transform's GameObject.
| Parameter | Description |
|---|---|
| Data Definition | Data Definition used to find the matching Data Component. |
| Field Name | Exact name of the field to sort by. |
| Use Defaults If Missing | If true, missing data uses the Data Definition default value for that field. |
This is useful for gameplay-driven ranking such as threat, health, score, or any other data-backed value.
Example
One common setup is:
- Sort a list by distance to the player.
- Add a secondary sort using a data value such as threat or health.
- Read the first item in the list as the best current target.