![]() |
PathBerserker2d
1.0
Platformer pathfinding solution
|
A link from one segment to another. More...
Public Types | |
enum | VisualizationType { Linear = 0, QuadradticBezier = 1, Projectile = 2, Teleport = 3, None } |
Public Member Functions | |
void | UpdateMapping () |
Update the mapping for both link instances. Call after link positions have been changed. More... | |
void | SetStartToGoalLinkTraversable (bool traversable) |
Set the link instance from start point to goal traversable. More... | |
void | SetGoalToStartLinkTraversable (bool traversable) |
Set the link instance from goal point to start traversable. This link only exist, if the link is bidirectional. More... | |
![]() | |
float | TravelCosts (Vector2 start, Vector2 goal) |
MUST BE THREAD SAFE! Calculates the cost of traversing from start to goal. More... | |
Public Attributes | |
bool | IsAddedToWorld => linkStartToGoal?.IsAdded ?? false |
![]() | |
float | Clearance => clearance |
float | AvgWaitTime => avgWaitTime |
float | CostOverride => costOverride |
GameObject | GameObject => gameObject |
int | NavTag => 0 |
float | MaxTraversableDistance => maxTraversableDistance |
Protected Member Functions | |
override void | OnValidate () |
Properties | |
Vector2 | GoalWorldPosition [get, set] |
Vector2 | StartWorldPosition [get, set] |
Vector2 | StartLocalPosition [get, set] |
Vector2 | GoalLocalPosition [get, set] |
VisualizationType | CurrentVisualizationType [get] |
bool | IsBidirectional [get, set] |
![]() | |
int | LinkType [get] |
Additional Inherited Members | |
![]() | |
float | costOverride = -1 |
int | linkType = 1 |
float | clearance = 2 |
int | navTag = 0 |
Pro-version only. | |
float | avgWaitTime = 0 |
float | maxTraversableDistance = 0 |
A link from one segment to another.
NavLink gets added to the pathfinder at runtime. It can be loaded and unloaded by enabling / disabling the component After being loaded and added to the pathfinder, the position of the link will not be updated. For example that means, if your link start position gets mapped to a position on a moving platform, the initial mapping of the link start to the segment won't change. The mapped position is relative to the NavSurface containing the moving platform. It will follow the movements of the platform, even though the start marker of the link will not.
You can update the links mapping by calling UpdateMapping
Internally, when moving the start and end marker around in scene view while the game is playing, UpdateMapping is called. That means you can move the markers around and the link will update its mapping. If you move them around by any other means however, you have to call UpdateMapping afterwards.
Everything visualization related is purely for you and is not meant to accessed at runtime. Visualizations like bezier or projectile are meant to allow you to figure out a good clearance value.
When a link is marked bidirectional, internally two links get added to the pathfinder. One for each direction. Both links traversable can be set separately with SetStartToGoalLinkTraversable and SetGoalToStartLinkTraversable.
Not being traversable should always be temporary. In the sense of, *"this link is not traversable right now, but will be in the future"*. NavAgents will wait indefinitely for the link to become traversable again. You can adjust AvgWaitTime to increase the cost of such not alway traversable links. The pathfinder will add it to the cost of traversal. The pathfinder does not care if a link is marked as traversable or not. It only cares about the cost of traversal. If you want to disable a link for a longer time, consider disabling the link component. Then it will be unloaded and not considered for any pathfinding.
void PathBerserker2d.NavLink.SetGoalToStartLinkTraversable | ( | bool | traversable | ) |
Set the link instance from goal point to start traversable. This link only exist, if the link is bidirectional.
void PathBerserker2d.NavLink.SetStartToGoalLinkTraversable | ( | bool | traversable | ) |
Set the link instance from start point to goal traversable.
void PathBerserker2d.NavLink.UpdateMapping | ( | ) |
Update the mapping for both link instances. Call after link positions have been changed.