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

Local Avoidance (beta) [obsolete]. More...

Detailed Description

Local Avoidance (beta) [obsolete].

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.

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.
 
void Update ()
 

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
 
float speed = 2F
 

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

Member Enumeration Documentation

Enumerator:
Inside 
Outside 
Enter 
Exit 
Enumerator:
Sampled 
Geometric 

Member Function Documentation

bool CheckSample ( Vector3  sample,
List< VO vos 
)
Vector3 ClampMovement ( Vector3  direction)
Vector3 GetVelocity ( )
void LateUpdate ( )
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

void Update ( )

Member Data Documentation

LocalAvoidance [] agents
protected
float circlePoint = 0.5F
float circleScale = 0.5F
CharacterController controller
protected
float delta = 1.0F

How many seconds to plan for.

1.0 usually works best

bool drawGizmos = false
float maxSpeedScale = 1.5F

Based on the desired velocity, how much larger magnitude should the output be allowed to have.

const int maxVOCounter = 50
private
Vector3 preVelocity
private
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.

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

Vector3 [] samples
float sampleScale = 1F
float speed = 2F
Vector3 velocity
private

Velocity during last frame.

List<VO> vos = new List<VO> ()
private

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