A* Pathfinding Project  3.8.12
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
GraphCollision Class Reference

Handles collision checking for graphs. More...

Detailed Description

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 DeserializeSettingsCompatibility (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.
 

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.
 

Member Function Documentation

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.

Warning
Does not work well with thick raycast, will only return an object a single time
void DeserializeSettingsCompatibility ( GraphSerializationContext  ctx)
void Initialize ( Matrix4x4  matrix,
float  scale 
)

Sets up several variables using the specified matrix and scale.

See Also
GraphCollision.up
GraphCollision.upheight
GraphCollision.finalRadius
GraphCollision.finalRaycastRadius
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

Member Data Documentation

bool collisionCheck = true

Toggle collision check.

float collisionOffset
float diameter = 1F

Diameter of capsule or sphere when checking for collision.

1 equals nodeSize . If type is set to Ray, this does not affect anything

float finalRadius
private

diameter * scale * 0.5.

Where scale usually is nodeSize

See Also
Initialize
float finalRaycastRadius
private

thickRaycastDiameter * scale * 0.5.

Where scale usually is nodeSize

See Also
Initialize
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

Note
This variable is not used currently, it 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.

Pathfinding.ColliderType

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.

See Also
Initialize
Vector3 upheight
private

up * height.

See Also
Initialize
bool use2D

Use Unity 2D Physics API.

See Also
http://docs.unity3d.com/ScriptReference/Physics2D.html

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