Packageflare.collisions
Classpublic class RayCollision
InheritanceRayCollision Inheritance Object

The RayCollision class provides tools to detect collisions along an infinite 3D virtual line.

The RayCollision class has a wide variety of applications. It could be used to find out which object is below a given character or to align an object in an area by shooting a ray in a downward direction or even to calculate where this object will impact a bullet moving in a specific direction, etc. Information about the environment can be taken by shooting virtual rays in any direction from a given position.



Public Properties
 PropertyDefined By
  collided : Boolean
[read-only] Returns whether collision occurred or not in the last check.
RayCollision
  collisionCount : int
[read-only] Returns the number of objects to be checked.
RayCollision
  collisionTime : int
[read-only] Returns the time taken to perform the last check in milliseconds.
RayCollision
  data : Vector.<CollisionInfo>
CollisionInfo-type vector with collision results.
RayCollision
Public Methods
 MethodDefined By
  
Creates a new RayCollision object.
RayCollision
  
addCollisionWith(pivot:Pivot3D, includeChildren:Boolean = true):void
Adds objects that will be used to check for collisions.
RayCollision
  
dispose():void
RayCollision
  
removeCollisionWith(pivot:Pivot3D, includeChildren:Boolean = true):void
Removes a Pivot3D in order to stop its checking process.
RayCollision
  
test(from:Vector3D, direction:Vector3D, getAllPolysUnderPoint:Boolean = false, ignoreInvisible:Boolean = true, ignoreBackFace:Boolean = true):Boolean
Performs the collision check.
RayCollision
Property Detail
collidedproperty
collided:Boolean  [read-only]

Returns whether collision occurred or not in the last check.


Implementation
    public function get collided():Boolean
collisionCountproperty 
collisionCount:int  [read-only]

Returns the number of objects to be checked.


Implementation
    public function get collisionCount():int
collisionTimeproperty 
collisionTime:int  [read-only]

Returns the time taken to perform the last check in milliseconds.


Implementation
    public function get collisionTime():int
dataproperty 
public var data:Vector.<CollisionInfo>

CollisionInfo-type vector with collision results.

Constructor Detail
RayCollision()Constructor
public function RayCollision()

Creates a new RayCollision object.

Method Detail
addCollisionWith()method
public function addCollisionWith(pivot:Pivot3D, includeChildren:Boolean = true):void

Adds objects that will be used to check for collisions.

Parameters

pivot:Pivot3D — Pivot3D object to be checked for collisions
 
includeChildren:Boolean (default = true) — defines whether Pivot3D children are to be included.

dispose()method 
public function dispose():void

removeCollisionWith()method 
public function removeCollisionWith(pivot:Pivot3D, includeChildren:Boolean = true):void

Removes a Pivot3D in order to stop its checking process.

Parameters

pivot:Pivot3D — Pivot3D object to be removed.
 
includeChildren:Boolean (default = true) — defines whether Pivot3D children are to be removed.

test()method 
public function test(from:Vector3D, direction:Vector3D, getAllPolysUnderPoint:Boolean = false, ignoreInvisible:Boolean = true, ignoreBackFace:Boolean = true):Boolean

Performs the collision check. Both the from parameter and the direction parameter must be in the global scene space. The direction parameter is a Vector3D that represents the direction the ray is pointing to, eg. ( 0, -1, 0 ) would be downward, ( 0, 0, 1 ) would be forward, etc.

Parameters

from:Vector3D — Point of origin of the ray.
 
direction:Vector3D — Direction the ray points to.
 
getAllPolysUnderPoint:Boolean (default = false) — Defines whether all the collisions or only the first collision is to be taken.
 
ignoreInvisible:Boolean (default = true)
 
ignoreBackFace:Boolean (default = true)

Returns
Booleantrue if collision occurred.

See also