Package | flare.collisions |
Class | public class SphereCollision |
Inheritance | SphereCollision ![]() |
Wraps 3d objects, such as characters, spheres or boxes, in a virtual sphere and uses this sphere to detect the other objects around it. With this class we can detect collisions against walls, floors, ceilings, specific areas, etc. At the same time, we can generate or not a response for them.
The slider method detects collisions and provides a sliding response according to the (normal) inclination of the collision.
The fixed method detects collisions and generates a static response, locating the colliding object exactly at the collision point.
The intersect method detects when the colliding object intersects another 3d mesh but does not generate any response.
Download example - 07 - sphere collision
Property | Defined By | ||
---|---|---|---|
collided : Boolean [read-only]
Returns whether collision occurred or not in the last check. | SphereCollision | ||
collisionCount : int [read-only]
Returns the number of objects that will be checked. | SphereCollision | ||
collisionTime : int [read-only]
Returns the time taken to perform the last check in milliseconds. | SphereCollision | ||
data : Vector.<CollisionInfo>
CollisionInfo-type vector with collision results. | SphereCollision | ||
offset : Vector3D
Sets or returns the displacement of the colliding sphere center. | SphereCollision | ||
radius : Number
Sets ir returns the collision radius that will be used to detect collisions. | SphereCollision | ||
source : Pivot3D [read-only]
Returns the source used to test the collisions. | SphereCollision |
Method | Defined By | ||
---|---|---|---|
SphereCollision(source:Pivot3D, radius:Number = 1, offset:Vector3D = null)
Creates a new SphereCollision object. | SphereCollision | ||
addCollisionWith(pivot:Pivot3D, includeChildren:Boolean = true):void
Adds objects that will be used to test collisions. | SphereCollision | ||
fixed():Boolean
The fixed method detects collisions and generates a static response, locating the colliding object exactly at the collision point. | SphereCollision | ||
intersect():Boolean
The intersect method detects when the colliding object intersects another 3d mesh but will not generate any response. | SphereCollision | ||
removeCollisionWith(pivot:Pivot3D, includeChildren:Boolean = true):void
Removes a Pivot3D to stop its checking process. | SphereCollision | ||
reset():void
The SphereCollision class calculates collisions based on object trajectory and previous position. | SphereCollision | ||
slider(precision:int = 2):Boolean
The slider method detects collisions and provides a sliding response depending on the collision inclination (normal). | SphereCollision |
collided | property |
collided:Boolean
[read-only] Returns whether collision occurred or not in the last check.
public function get collided():Boolean
collisionCount | property |
collisionCount:int
[read-only] Returns the number of objects that will be checked.
public function get collisionCount():int
collisionTime | property |
collisionTime:int
[read-only] Returns the time taken to perform the last check in milliseconds.
public function get collisionTime():int
data | property |
public var data:Vector.<CollisionInfo>
CollisionInfo-type vector with collision results.
offset | property |
offset:Vector3D
Sets or returns the displacement of the colliding sphere center.
public function get offset():Vector3D
public function set offset(value:Vector3D):void
radius | property |
radius:Number
Sets ir returns the collision radius that will be used to detect collisions.
public function get radius():Number
public function set radius(value:Number):void
source | property |
source:Pivot3D
[read-only] Returns the source used to test the collisions.
public function get source():Pivot3D
SphereCollision | () | Constructor |
public function SphereCollision(source:Pivot3D, radius:Number = 1, offset:Vector3D = null)
Creates a new SphereCollision object.
Parameterssource:Pivot3D — Pivot that will serve as colliding object. It could be a character, a camera, etc.
| |
radius:Number (default = 1 ) — Collision radius that will be used to detect collisions.
| |
offset:Vector3D (default = null ) — By default, the virtual sphere center will be placed at the origin of the Pivot3D that is used as
source, i.e. at the (0,0,0) point. The offset parameter allows the user to move the sphere center to a more convenient position
manually if necessary. The offset parameter must be represented in the object’s local space; therefore,
if the 'source' object is rotated, the offset will also be rotated.
|
addCollisionWith | () | method |
public function addCollisionWith(pivot:Pivot3D, includeChildren:Boolean = true):void
Adds objects that will be used to test collisions.
Parameters
pivot:Pivot3D — Pivot3D object to be checked for collisions.
| |
includeChildren:Boolean (default = true ) — defines whether Pivot3D children are to be included.
|
fixed | () | method |
public function fixed():Boolean
The fixed method detects collisions and generates a static response, locating the colliding object exactly at the collision point. When this method is used, the object will stop at the first collision it encounters and will remain in that position without sliding, which is typical of the slider method.
ReturnsBoolean — true if collision occurred.
|
intersect | () | method |
public function intersect():Boolean
The intersect method detects when the colliding object intersects another 3d mesh but will not generate any response. It can be used to detect collisions with invisible zones, for example.
ReturnsBoolean — true si hubo colisión.
|
removeCollisionWith | () | method |
public function removeCollisionWith(pivot:Pivot3D, includeChildren:Boolean = true):void
Removes a Pivot3D 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.
|
reset | () | method |
public function reset():void
The SphereCollision class calculates collisions based on object trajectory and previous position. In some cases, when the source object is to be removed and forced to a given position, collisions should be reset. The reset method must be used after repositioning the object.
slider | () | method |
public function slider(precision:int = 2):Boolean
The slider method detects collisions and provides a sliding response depending on the collision inclination (normal).
Parameters
precision:int (default = 2 )
|
Boolean — true if collision occured.
|