A* Pathfinding Project  4.3.8
The A* Pathfinding Project for Unity 3D
NodeLink2 Class Reference

Connects two nodes via two intermediate point nodes. More...

Detailed Description

Connects two nodes via two intermediate point nodes.

In contrast to the NodeLink component, this link type will not connect the nodes directly instead it will create two point nodes at the start and end position of this link and connect through those nodes.

If the closest node to this object is called A and the closest node to the end transform is called D, then it will create one point node at this object's position (call it B) and one point node at the position of the end transform (call it C), it will then connect A to B, B to C and C to D.

This link type is possible to detect while following since it has these special point nodes in the middle. The link corresponding to one of those intermediate nodes can be retrieved using the GetNodeLink method which can be of great use if you want to, for example, play a link specific animation when reaching the link.

See also
The example scene RecastExample2 contains a few links which you can take a look at to see how they are used.

Public Member Functions

 NodeLink2 ()
 
void Apply (bool forceNewCheck)
 Connects the start and end points using a link or refreshes the existing link. More...
 
virtual void DrawGizmos ()
 
override void OnGraphsPostUpdateBeforeAreaRecalculation ()
 Called after graphs have been updated. More...
 
- Public Member Functions inherited from GraphModifier
virtual void OnGraphsPostUpdate ()
 Called after graphs have been updated using GraphUpdateObjects or navmesh cutting. More...
 
virtual void OnGraphsPreUpdate ()
 Called before graphs are updated using GraphUpdateObjects. More...
 
virtual void OnLatePostScan ()
 Called at the end of the scanning procedure. More...
 
virtual void OnPostCacheLoad ()
 Called after cached graphs have been loaded. More...
 
virtual void OnPostGraphLoad ()
 Called after a graph has been deserialized and loaded. More...
 
virtual void OnPostScan ()
 Called right after all graphs have been scanned. More...
 
virtual void OnPreScan ()
 Called right before graphs are going to be scanned. More...
 

Static Public Member Functions

static NodeLink2 GetNodeLink (GraphNode node)
 
- Static Public Member Functions inherited from GraphModifier
static void FindAllModifiers ()
 
static void TriggerEvent (GraphModifier.EventType type)
 Triggers an event for all active graph modifiers. More...
 

Public Attributes

float costFactor = 1.0f
 The connection will be this times harder/slower to traverse. More...
 
Transform end
 End position of the link. More...
 
bool oneWay = false
 Make a one-way connection. More...
 

Protected Member Functions

override void OnDisable ()
 Removes this modifier from list of active modifiers. More...
 
override void OnEnable ()
 Adds this modifier to list of active modifiers. More...
 
- Protected Member Functions inherited from GraphModifier
override void Awake ()
 
virtual void OnDestroy ()
 
override void Reset ()
 Handle serialization backwards compatibility. More...
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility. More...
 

Static Protected Attributes

static Dictionary< GraphNode, NodeLink2reference = new Dictionary<GraphNode, NodeLink2>()
 
- Static Protected Attributes inherited from GraphModifier
static Dictionary< ulong, GraphModifierusedIDs = new Dictionary<ulong, GraphModifier>()
 Maps persistent IDs to the component that uses it. More...
 

Static Package Functions

static void DeserializeReferences (Pathfinding.Serialization.GraphSerializationContext ctx)
 
static void SerializeReferences (Pathfinding.Serialization.GraphSerializationContext ctx)
 

Properties

PointNode endNode [get, private set]
 
GraphNode EndNode [get]
 
Transform EndTransform [get]
 
PointNode startNode [get, private set]
 
GraphNode StartNode [get]
 
Transform StartTransform [get]
 
- Properties inherited from VersionedMonoBehaviour
int Util.IEntityIndex. EntityIndex [get, set]
 Internal entity index used by #BurstBatchHelper. More...
 
- Properties inherited from IEntityIndex
int EntityIndex [get, set]
 

Private Member Functions

void ContextApplyForce ()
 
void CreateLinkNodes ()
 

Static Private Member Functions

static void RemoveConnections (GraphNode node)
 

Private Attributes

Vector3 clamped1
 
Vector3 clamped2
 
GraphNode connectedNode1
 
GraphNode connectedNode2
 
bool linkCreated = false
 

Static Private Attributes

static readonly Color GizmosColor = new Color(206.0f/255.0f, 136.0f/255.0f, 48.0f/255.0f, 0.5f)
 
static readonly Color GizmosColorSelected = new Color(235.0f/255.0f, 123.0f/255.0f, 32.0f/255.0f, 1.0f)
 

Additional Inherited Members

- Public Types inherited from GraphModifier
enum  EventType {
  PostScan = 1 << 0, PreScan = 1 << 1, LatePostScan = 1 << 2, PreUpdate = 1 << 3,
  PostUpdate = 1 << 4, PostCacheLoad = 1 << 5, PostUpdateBeforeAreaRecalculation = 1 << 6, PostGraphLoad = 1 << 7
}
 GraphModifier event type. More...
 
- Static Protected Member Functions inherited from GraphModifier
static List< T > GetModifiersOfType< T > ()
 
- Protected Attributes inherited from GraphModifier
ulong uniqueID
 Unique persistent ID for this component, used for serialization. More...
 

Constructor & Destructor Documentation

◆ NodeLink2()

NodeLink2 ( )

Member Function Documentation

◆ Apply()

void Apply ( bool  forceNewCheck)

Connects the start and end points using a link or refreshes the existing link.

If you have moved the link or otherwise modified it you need to call this method.

Warning
This must only be done when it is safe to update the graph structure. The easiest is to do it inside a work item. See #AstarPath.active.AddWorkItem.

◆ ContextApplyForce()

void ContextApplyForce ( )
private

◆ CreateLinkNodes()

void CreateLinkNodes ( )
private

◆ DeserializeReferences()

static void DeserializeReferences ( Pathfinding.Serialization.GraphSerializationContext  ctx)
staticpackage

◆ DrawGizmos()

virtual void DrawGizmos ( )
virtual

Implements RetainedGizmosWrapper.IDrawGizmos.

Reimplemented in AnimationLink.

◆ GetNodeLink()

static NodeLink2 GetNodeLink ( GraphNode  node)
static

◆ OnDisable()

override void OnDisable ( )
protectedvirtual

Removes this modifier from list of active modifiers.

Reimplemented from GraphModifier.

◆ OnEnable()

override void OnEnable ( )
protectedvirtual

Adds this modifier to list of active modifiers.

Reimplemented from GraphModifier.

◆ OnGraphsPostUpdateBeforeAreaRecalculation()

override void OnGraphsPostUpdateBeforeAreaRecalculation ( )
virtual

Called after graphs have been updated.

This is among other times called after graphs have been scanned, updated using GraphUpdateObjects, navmesh cuts, or GraphUpdateScene components.

Note
Area information (see Pathfinding.HierarchicalGraph) may not be up to date when this event is sent. This means some methods like Pathfinding.PathUtilities.IsPathPossible may return incorrect results. Use OnLatePostScan if you need that info to be up to date.

Use this if you are modifying any graph connections or walkability.

See also
OnGraphsPostUpdate

Reimplemented from GraphModifier.

◆ RemoveConnections()

static void RemoveConnections ( GraphNode  node)
staticprivate

◆ SerializeReferences()

static void SerializeReferences ( Pathfinding.Serialization.GraphSerializationContext  ctx)
staticpackage

Member Data Documentation

◆ clamped1

Vector3 clamped1
private

◆ clamped2

Vector3 clamped2
private

◆ connectedNode1

GraphNode connectedNode1
private

◆ connectedNode2

GraphNode connectedNode2
private

◆ costFactor

float costFactor = 1.0f

The connection will be this times harder/slower to traverse.

Note that values lower than 1 will not always make the pathfinder choose this path instead of another path even though this one should lead to a lower total cost unless you also adjust the Heuristic Scale in A* Inspector -> Settings -> Pathfinding or disable the heuristic altogether.

◆ end

Transform end

End position of the link.

◆ GizmosColor

readonly Color GizmosColor = new Color(206.0f/255.0f, 136.0f/255.0f, 48.0f/255.0f, 0.5f)
staticprivate

◆ GizmosColorSelected

readonly Color GizmosColorSelected = new Color(235.0f/255.0f, 123.0f/255.0f, 32.0f/255.0f, 1.0f)
staticprivate

◆ linkCreated

bool linkCreated = false
private

◆ oneWay

bool oneWay = false

Make a one-way connection.

◆ reference

Dictionary<GraphNode, NodeLink2> reference = new Dictionary<GraphNode, NodeLink2>()
staticprotected

Property Documentation

◆ endNode

PointNode endNode
getprivate set

◆ EndNode

GraphNode EndNode
get

◆ EndTransform

Transform EndTransform
get

◆ startNode

PointNode startNode
getprivate set

◆ StartNode

GraphNode StartNode
get

◆ StartTransform

Transform StartTransform
get

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