A* Pathfinding Project
4.0.1
The A* Pathfinding Project for Unity 3D
|
Adds new geometry to a recast graph. More...
Adds new geometry to a recast graph.
This component will add new geometry to a recast graph similar to how a NavmeshCut component removes it.
There are quite a few limitations to this component though. This navmesh geometry will not be connected to the rest of the navmesh in the same tile unless very exactly positioned so that the triangles line up exactly. It will be connected to neighbouring tiles if positioned so that it lines up with the tile border.
This component has a few very specific use-cases. For example if you have a tiled recast graph this component could be used to add bridges in that world. You would create a NavmeshCut object cutting out a hole for the bridge. then add a NavmeshAdd object which fills that space. Make sure NavmeshCut.CutsAddedGeom is disabled on the NavmeshCut, otherwise it will cut away the NavmeshAdd object. Then you can add links between the added geometry and the rest of the world, preferably using NodeLink3.
Public Types | |
enum | MeshType { Rectangle, CustomMesh } |
Public Member Functions | |
void | ForceUpdate () |
Forces this navmesh add to update the navmesh. | |
Rect | GetBounds (Pathfinding.Util.GraphTransform inverseTransform) |
Bounds in XZ space after transforming using the *inverse* transform of the inverseTransform parameter. | |
void | GetMesh (ref Int3[] vbuffer, out int[] tbuffer, Pathfinding.Util.GraphTransform inverseTransform=null) |
void | NotifyUpdated () |
Internal method to notify the NavmeshAdd that it has just been used to update the navmesh. | |
void | RebuildMesh () |
bool | RequiresUpdate () |
Returns true if this object has moved so much that it requires an update. | |
Public Attributes | |
Vector3 | center |
Mesh | mesh |
Custom mesh to use. | |
float | meshScale = 1 |
Vector2 | rectangleSize = new Vector2(1, 1) |
Size of the rectangle. | |
MeshType | type |
float | updateDistance = 0.4f |
Distance between positions to require an update of the navmesh. | |
float | updateRotationDistance = 10 |
How many degrees rotation that is required for an update to the navmesh. | |
bool | useRotationAndScale |
Includes rotation and scale in calculations. | |
Static Public Attributes | |
static readonly Color | GizmoColor = new Color(94.0f/255, 239.0f/255, 37.0f/255) |
Protected Member Functions | |
override void | Awake () |
Protected Member Functions inherited from VersionedMonoBehaviour | |
virtual int | OnUpgradeSerializedData (int version) |
Handle serialization backwards compatibility. | |
Protected Attributes | |
Transform | tr |
cached transform component | |
Properties | |
Vector3 | Center [get] |
Events | |
static System.Action< NavmeshAdd > | OnDisableCallback |
Called every time a NavmeshAdd component is disabled. | |
static System.Action< NavmeshAdd > | OnEnableCallback |
Called every time a NavmeshAdd component is enabled. | |
Private Member Functions | |
void | OnDisable () |
void | OnEnable () |
Private Attributes | |
Vector3 | lastPosition |
Quaternion | lastRotation |
int[] | tris |
Cached triangles. | |
Vector3[] | verts |
Cached vertices. | |
enum MeshType |
|
protectedvirtual |
Reimplemented from VersionedMonoBehaviour.
void ForceUpdate | ( | ) |
Forces this navmesh add to update the navmesh.
Rect GetBounds | ( | Pathfinding.Util.GraphTransform | inverseTransform | ) |
Bounds in XZ space after transforming using the *inverse* transform of the inverseTransform parameter.
The transformation will typically transform the vertices to graph space and this is used to figure out which tiles the add intersects.
void GetMesh | ( | ref Int3[] | vbuffer, |
out int[] | tbuffer, | ||
Pathfinding.Util.GraphTransform | inverseTransform = null |
||
) |
void NotifyUpdated | ( | ) |
Internal method to notify the NavmeshAdd that it has just been used to update the navmesh.
|
private |
|
private |
void RebuildMesh | ( | ) |
bool RequiresUpdate | ( | ) |
Returns true if this object has moved so much that it requires an update.
When an update to the navmesh has been done, call NotifyUpdated to be able to get relavant output from this method again.
Vector3 center |
|
static |
|
private |
|
private |
Mesh mesh |
Custom mesh to use.
The contour(s) of the mesh will be extracted. If you get the "max perturbations" error when cutting with this, check the normals on the mesh. They should all point in the same direction. Try flipping them if that does not help.
float meshScale = 1 |
Vector2 rectangleSize = new Vector2(1, 1) |
Size of the rectangle.
|
protected |
cached transform component
|
private |
Cached triangles.
MeshType type |
float updateDistance = 0.4f |
Distance between positions to require an update of the navmesh.
A smaller distance gives better accuracy, but requires more updates when moving the object over time, so it is often slower.
float updateRotationDistance = 10 |
How many degrees rotation that is required for an update to the navmesh.
Should be between 0 and 180.
bool useRotationAndScale |
Includes rotation and scale in calculations.
This is slower since a lot more matrix multiplications are needed but gives more flexibility.
|
private |
Cached vertices.
|
get |
|
static |
Called every time a NavmeshAdd component is disabled.
|
static |
Called every time a NavmeshAdd component is enabled.