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

Handles collision checking for graphs. More...

+ Inheritance diagram for GraphCollision:
+ Collaboration diagram for GraphCollision:

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 (AstarSerializer serializer)
 Called to deserialize the object.
 
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.
 
void SerializeSettings (AstarSerializer serializer)
 Called to serialize the object. Called to serialize the object.
 
- Public Member Functions inherited from ISerializableObject
void DeSerializeSettings (AstarSerializer serializer)
 Called to deserialize the object.
 
void SerializeSettings (AstarSerializer serializer)
 Called to serialize the object.
 

Public Attributes

bool collisionCheck = true
 Toggle collision check.
 
float collisionOffset = 0
 
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 = false
 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.
 

Private Attributes

float finalRadius
 diameter * scale * 0.5.
 
float finalRaycastRadius
 thickRaycastDiameter * scale * 0.5.
 
Vector3 upheight
 up * height.
 

Detailed Description

Handles collision checking for graphs.

Mostly used by grid based graphs

Member Function Documentation

bool Check ( Vector3  position)

Returns if the position is obstructed.

If collisionCheck is false, this will always return true.

+ Here is the caller graph for this function:

Vector3 CheckHeight ( Vector3  position)

Returns the position with the correct height.

If heightCheck is false, this will return position.

+ Here is the caller graph for this function:

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

+ Here is the call graph for this function:

RaycastHit [] CheckHeightAll ( Vector3  position)

Returns all hits when checking height for position.

Note
Does not work well with thick raycast, will only return an object a single time

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void DeSerializeSettings ( AstarSerializer  serializer)

Called to deserialize the object.

All variables and data which are to be loaded should be loaded using Pathfinding::AstarSerializer::GetValue

//Loads the integer variable myVariable from the serialized data
myVariable = (int)serializer.GetValue ("myVariable",typeof(int));


A default value can also be passed, in case the variable isn't contained in the data that will be returned instead

//Loads the integer variable myVariable with the default value of 512
myVariable = (int)serializer.GetValue ("myVariable",typeof(int),512);

+ Here is the call graph for this function:

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

+ Here is the caller graph for this function:

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SerializeSettings ( AstarSerializer  serializer)

Called to serialize the object. Called to serialize the object.

All variables and data which are to be saved should be passed to the serialized using Pathfinding::AstarSerializer::AddValue

serializer.AddValue ("myVariable",myVariable);
Called to serialize the object.

+ Here is the call graph for this function:

Member Data Documentation

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 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

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
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

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