PathBerserker2d  1.0
Platformer pathfinding solution
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Properties | List of all members
PathBerserker2d.NavLink Class Reference

A link from one segment to another. More...

Inheritance diagram for PathBerserker2d.NavLink:
PathBerserker2d.BaseNavLink

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...
 

Public Attributes

bool IsAddedToWorld => linkStartToGoal?.IsAdded ?? false
 

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]
 

Additional Inherited Members

Detailed Description

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.

Mapping

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.

Visualization

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.

Traversable

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.

Member Function Documentation

◆ SetGoalToStartLinkTraversable()

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.

◆ SetStartToGoalLinkTraversable()

void PathBerserker2d.NavLink.SetStartToGoalLinkTraversable ( bool  traversable)

Set the link instance from start point to goal traversable.

◆ UpdateMapping()

void PathBerserker2d.NavLink.UpdateMapping ( )

Update the mapping for both link instances. Call after link positions have been changed.


The documentation for this class was generated from the following file: