A* Pathfinding Project
4.1.8
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. More... | |
Vector3 | CheckHeight (Vector3 position) |
Returns the position with the correct height. More... | |
Vector3 | CheckHeight (Vector3 position, out RaycastHit hit, out bool walkable) |
Returns the position with the correct height. More... | |
RaycastHit [] | CheckHeightAll (Vector3 position) |
Returns all hits when checking height for position. More... | |
void | DeserializeSettingsCompatibility (GraphSerializationContext ctx) |
void | Initialize (GraphTransform transform, float scale) |
Sets up several variables using the specified matrix and scale. More... | |
Vector3 | Raycast (Vector3 origin, out RaycastHit hit, out bool walkable) |
Same as CheckHeight, except that the raycast will always start exactly at origin. More... | |
Public Attributes | |
bool | collisionCheck = true |
Toggle collision check. More... | |
float | collisionOffset |
Height above the ground that collision checks should be done. More... | |
float | diameter = 1F |
Diameter of capsule or sphere when checking for collision. More... | |
float | fromHeight = 100 |
The height to check from when checking height ('ray length' in the inspector). More... | |
float | height = 2F |
Height of capsule or length of ray when checking for collision. More... | |
bool | heightCheck = true |
Toggle height check. More... | |
LayerMask | heightMask = -1 |
Layers to be included in the height check. More... | |
LayerMask | mask |
Layers to be treated as obstacles. More... | |
const float | RaycastErrorMargin = 0.005F |
Offset to apply after each raycast to make sure we don't hit the same point again in CheckHeightAll. More... | |
RayDirection | rayDirection = RayDirection.Both |
Direction of the ray when checking for collision. More... | |
bool | thickRaycast |
Toggles thick raycast. More... | |
float | thickRaycastDiameter = 1 |
Diameter of the thick raycast in nodes. More... | |
ColliderType | type = ColliderType.Capsule |
Collision shape to use. More... | |
bool | unwalkableWhenNoGround = true |
Make nodes unwalkable when no ground was found with the height raycast. More... | |
Vector3 | up |
Direction to use as UP. More... | |
bool | use2D |
Use Unity 2D Physics API. More... | |
Private Attributes | |
float | finalRadius |
diameter * scale * 0.5. More... | |
float | finalRaycastRadius |
thickRaycastDiameter * scale * 0.5. More... | |
Vector3 | upheight |
up * height. More... | |
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 DeserializeSettingsCompatibility | ( | GraphSerializationContext | ctx | ) |
void Initialize | ( | GraphTransform | transform, |
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
bool collisionCheck = true |
Toggle collision check.
float collisionOffset |
Height above the ground that collision checks should be done.
For example, if the ground was found at y=0, collisionOffset = 2 type = Capsule and height = 3 then the physics system will be queried to see if there are any colliders in a capsule for which the bottom sphere that is made up of is centered at y=2 and the top sphere has its center at y=2+3=5.
If type = Sphere then the sphere's center would be at y=2 in this case.
float diameter = 1F |
Diameter of capsule or sphere when checking for collision.
When checking for collisions the system will check if any colliders overlap a specific shape at the node's position. The shape is determined by the type field.
A diameter of 1 means that the shape has a diameter equal to the node's width, or in other words it is equal to nodeSize .
If type is set to Ray, this does not affect anything.
|
private |
|
private |
float fromHeight = 100 |
The height to check from when checking height ('ray length' in the inspector).
As the image below visualizes, different ray lengths can make the ray hit different things. The distance is measured up from the graph plane.
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 |
Layers to be included in the height check.
LayerMask mask |
Layers to be treated 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.