A* Pathfinding Project
3.7.3
The A* Pathfinding Project for Unity 3D
|
Handles collision checking for graphs. More...
Handles collision checking for graphs.
Mostly used by grid based graphs
Public Member Functions | |
bool | Check (Vector3 position) |
Returns if the position is obstructed. | |
Vector3 | CheckHeight (Vector3 position) |
Returns the position with the correct height. | |
Vector3 | CheckHeight (Vector3 position, out RaycastHit hit, out bool walkable) |
Returns the position with the correct height. | |
RaycastHit[] | CheckHeightAll (Vector3 position) |
Returns all hits when checking height for position. | |
void | DeserializeSettings (GraphSerializationContext ctx) |
void | Initialize (Matrix4x4 matrix, float scale) |
Sets up several variables using the specified matrix and scale. | |
Vector3 | Raycast (Vector3 origin, out RaycastHit hit, out bool walkable) |
Same as CheckHeight, except that the raycast will always start exactly at origin. | |
void | SerializeSettings (GraphSerializationContext ctx) |
Public Attributes | |
bool | collisionCheck = true |
Toggle collision check. | |
float | collisionOffset |
float | diameter = 1F |
Diameter of capsule or sphere when checking for collision. | |
float | fromHeight = 100 |
The height to check from when checking height. | |
float | height = 2F |
Height of capsule or length of ray when checking for collision. | |
bool | heightCheck = true |
Toggle height check. | |
LayerMask | heightMask = -1 |
Layer mask to use for height check. | |
LayerMask | mask |
Layer mask to use for collision check. | |
const float | RaycastErrorMargin = 0.005F |
Offset to apply after each raycast to make sure we don't hit the same point again in CheckHeightAll. | |
RayDirection | rayDirection = RayDirection.Both |
Direction of the ray when checking for collision. | |
bool | thickRaycast |
Toggles thick raycast. | |
float | thickRaycastDiameter = 1 |
Diameter of the thick raycast in nodes. | |
ColliderType | type = ColliderType.Capsule |
Collision shape to use. | |
bool | unwalkableWhenNoGround = true |
Make nodes unwalkable when no ground was found with the height raycast. | |
Vector3 | up |
Direction to use as UP. | |
bool | use2D |
Use Unity 2D Physics API. | |
Private Attributes | |
float | finalRadius |
diameter * scale * 0.5. | |
float | finalRaycastRadius |
thickRaycastDiameter * scale * 0.5. | |
Vector3 | upheight |
up * height. | |
bool Check | ( | Vector3 | position | ) |
Returns if the position is obstructed.
If collisionCheck is false, this will always return true.
Vector3 CheckHeight | ( | Vector3 | position | ) |
Returns the position with the correct height.
If heightCheck is false, this will return position.
Vector3 CheckHeight | ( | Vector3 | position, |
out RaycastHit | hit, | ||
out bool | walkable | ||
) |
Returns the position with the correct height.
If heightCheck is false, this will return position.
walkable will be set to false if nothing was hit. The ray will check a tiny bit further than to the grids base to avoid floating point errors when the ground is exactly at the base of the grid
RaycastHit [] CheckHeightAll | ( | Vector3 | position | ) |
Returns all hits when checking height for position.
void DeserializeSettings | ( | GraphSerializationContext | ctx | ) |
void Initialize | ( | Matrix4x4 | matrix, |
float | scale | ||
) |
Sets up several variables using the specified matrix and scale.
Vector3 Raycast | ( | Vector3 | origin, |
out RaycastHit | hit, | ||
out bool | walkable | ||
) |
Same as CheckHeight, except that the raycast will always start exactly at origin.
walkable will be set to false if nothing was hit. The ray will check a tiny bit further than to the grids base to avoid floating point errors when the ground is exactly at the base of the grid
void SerializeSettings | ( | GraphSerializationContext | ctx | ) |
bool collisionCheck = true |
Toggle collision check.
float collisionOffset |
float diameter = 1F |
|
private |
|
private |
float fromHeight = 100 |
The height to check from when checking height.
float height = 2F |
Height of capsule or length of ray when checking for collision.
If type is set to Sphere, this does not affect anything
bool heightCheck = true |
Toggle height check.
If false, the grid will be flat
LayerMask heightMask = -1 |
Layer mask to use for height check.
LayerMask mask |
Layer mask to use for collision check.
This should only contain layers of objects defined as obstacles
const float RaycastErrorMargin = 0.005F |
Offset to apply after each raycast to make sure we don't hit the same point again in CheckHeightAll.
RayDirection rayDirection = RayDirection.Both |
Direction of the ray when checking for collision.
If type is not Ray, this does not affect anything
bool thickRaycast |
Toggles thick raycast.
float thickRaycastDiameter = 1 |
Diameter of the thick raycast in nodes.
1 equals nodeSize
ColliderType type = ColliderType.Capsule |
Collision shape to use.
bool unwalkableWhenNoGround = true |
Make nodes unwalkable when no ground was found with the height raycast.
If height raycast is turned off, this doesn't affect anything.
Vector3 up |
Direction to use as UP.
|
private |
bool use2D |
Use Unity 2D Physics API.