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

A collection of line segments to traverse on. More...

Inheritance diagram for PathBerserker2d.NavSurface:

Public Member Functions

Vector2 LocalToWorld (Vector2 pos)
 
Matrix4x4 LocalToWorldMatrix ()
 
Vector2 WorldToLocal (Vector2 pos)
 
Matrix4x4 WorldToLocalMatrix ()
 
IEnumerator Bake ()
 Updates NavSurface baked data. Baking largely runs in a different thread. This function should be run as a Coroutine. NavSurface will be removed from World first and added back, when baking is completed. Calling this function before the previous bake job completed, will abort the previous job. More...
 

Public Attributes

float MaxClearance => maxClearance
 
float MinClearance => minClearance
 
float CellSize => cellSize
 
LayerMask ColliderMask => includedColliders
 
float TotalLineLength => totalLineLength
 Length of all segments combined More...
 
float MaxSlopeAngle => maxSlopeAngle
 Segments exceeding this angle are removed from the bake output. Should equal the highest slope angle of your NavAgents. More...
 
float SmallestDistanceYouCareAbout => smallestDistanceYouCareAbout
 Parameter for the line simplifier (Ramer-Douglas-Peucker). Higher values reduce overall segment count at the expense of fitting the original collider shape. More...
 
float MinSegmentLength => minSegmentLength
 Segments shorter than this will be removed from the bake output. More...
 

Properties

Rect WorldBounds [get]
 

Detailed Description

A collection of line segments to traverse on.

NavSurfaces are independent collections of segments. At runtime their data gets added to the pathfinder. You can load and unload NavSurfaces at runtime. This allows you to setup Prefabs with navigation data and stream them in at runtime. Loading and unloading is as simple as enabling and disabling a NavSurface script.

Baking

The bake process only consideres colliders that are children of the NavSurface. This also extends to the clearance calculation of segment cells. Baking is currently limited to editor mode only. You can't bake at runtime.

Transformations

All baked postion data is relative to the current NavSurface position. Only to the position though, not to it's rotation or scale. This allows NavSurfaces to be moved at runtime, without requiring a rebake. Segments in calculated paths remain relative to the NavSurface of origin. If you pathfind on a NavSurface and then move it, the path will reflect that transformation.

See also Core concepts: NavAgent.

Member Function Documentation

◆ Bake()

IEnumerator PathBerserker2d.NavSurface.Bake ( )

Updates NavSurface baked data. Baking largely runs in a different thread. This function should be run as a Coroutine. NavSurface will be removed from World first and added back, when baking is completed. Calling this function before the previous bake job completed, will abort the previous job.

Member Data Documentation

◆ MaxSlopeAngle

float PathBerserker2d.NavSurface.MaxSlopeAngle => maxSlopeAngle

Segments exceeding this angle are removed from the bake output. Should equal the highest slope angle of your NavAgents.

◆ MinSegmentLength

float PathBerserker2d.NavSurface.MinSegmentLength => minSegmentLength

Segments shorter than this will be removed from the bake output.

◆ SmallestDistanceYouCareAbout

float PathBerserker2d.NavSurface.SmallestDistanceYouCareAbout => smallestDistanceYouCareAbout

Parameter for the line simplifier (Ramer-Douglas-Peucker). Higher values reduce overall segment count at the expense of fitting the original collider shape.

◆ TotalLineLength

float PathBerserker2d.NavSurface.TotalLineLength => totalLineLength

Length of all segments combined


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