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

Local Avoidance (beta). More...

+ Inheritance diagram for LocalAvoidance:
+ Collaboration diagram for LocalAvoidance:

Classes

class  HalfPlane
 
struct  IntersectionPair
 
class  VO
 
struct  VOIntersection
 
struct  VOLine
 

Public Types

enum  IntersectionState { Inside, Outside, Enter, Exit }
 
enum  ResolutionType { Sampled, Geometric }
 

Public Member Functions

bool CheckSample (Vector3 sample, List< VO > vos)
 
Vector3 ClampMovement (Vector3 direction)
 
Vector3 GetVelocity ()
 
void LateUpdate ()
 
void SimpleMove (Vector3 desiredMovement)
 Simple move.
 

Public Attributes

float circlePoint = 0.5F
 
float circleScale = 0.5F
 
float delta = 1.0F
 How many seconds to plan for.
 
bool drawGizmos = false
 
float maxSpeedScale = 1.5F
 Based on the desired velocity, how much larger magnitude should the output be allowed to have.
 
const float Rad2Deg = (float)(360.0/(Math.PI*2))
 
float radius = 0.5F
 
float responability = 0.5F
 Blending between taking this vecocity or other units velocity into account.
 
ResolutionType resType = ResolutionType.Geometric
 Type of solver for local avoidance.
 
Vector3[] samples
 
float sampleScale = 1F
 

Protected Attributes

LocalAvoidance[] agents
 
CharacterController controller
 

Private Member Functions

void Start ()
 Initialization.
 

Private Attributes

const int maxVOCounter = 50
 
Vector3 preVelocity
 
Vector3 velocity
 Velocity during last frame.
 
List< VOvos = new List<VO> ()
 

Detailed Description

Local Avoidance (beta).

This component can be used as a CharacterController with the call SimpleMove.
Using this on multiple units will improve how they behave in groups and avoid collisions.
Known limitations and issues

  • Many units all trying to go through the same point will take quite some time to sort out
  • Many units trying to go to the same point will sometimes result in overlapping.
  • Only works in 2D (i.e on in XZ space), multiple floors are not handled properly yet.
  • Only works with agents which were present from the beginning of the game (otherwise you need to update the LocalAvoidance::agents array, see LocalAvoidance::Start)
  • Units do not avoid walls at the moment, support for avoiding at least navmesh edges will be implemented in later versions


See demo of the script here: http://www.youtube.com/watch?v=WUOymX-NpN4
Keep in mind that this is a beta, some features might not work properly and the script is really messy.

Based on ClearPath, RVO, VO and a number of other techniques. This is roughly the same technique which Unity's local avoidance uses.

Deprecated:
This class has been replaced by the much more mature RVO local avoidance. It may be removed in future versions

Member Function Documentation

void SimpleMove ( Vector3  desiredMovement)

Simple move.

Similar to CharacterController.SimpleMove, but this will try to avoid other units

void Start ( )
private

Initialization.

Caches CharacterController component and finds other agents

Member Data Documentation

float delta = 1.0F

How many seconds to plan for.

1.0 usually works best

float responability = 0.5F

Blending between taking this vecocity or other units velocity into account.

0.5 usually works best

ResolutionType resType = ResolutionType.Geometric

Type of solver for local avoidance.

The Geometric one is the one most developed and works best usually.
The sampled one also works quite good, but not in all cases


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