Class Collider
A base class for all colliders.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Physics/Colliders/Collider.h
Syntax
public class Collider : public PhysicsColliderActor, public IAssetReference, public IPhysicsDebugFields
_cachedLocalPosePos
Declaration
protected Vector3 _cachedLocalPosePosField Value
| Vector3 
 | 
_cachedLocalPoseRot
_cachedScale
Declaration
protected float _cachedScaleField Value
| float 
 | 
_center
Declaration
protected Vector3 _centerField Value
| Vector3 
 | 
_contactOffset
Declaration
protected float _contactOffsetField Value
| float 
 | 
_isTrigger
Declaration
protected bool _isTriggerField Value
| bool 
 | 
_shape
Declaration
protected void* _shapeField Value
| void 
 | 
_staticActor
Declaration
protected void* _staticActorField Value
| void 
 | 
Material
The physical material used to define the collider physical properties.
Declaration
public JsonAssetReference<PhysicalMaterial> MaterialField Value
| JsonAssetReference<PhysicalMaterial> 
 | 
Methods
Attach(RigidBody* rigidBody)
Attaches collider to the specified rigid body.
Declaration
public void Attach(RigidBody* rigidBody)Parameters
| RigidBody
        rigidBody The rigid body. | 
BeginPlay(SceneBeginData* data)
Called when adding object to the game.
Declaration
protected virtual void BeginPlay(SceneBeginData* data) overrideParameters
| SceneBeginData
        data The initialization data (e.g. used to collect joints to link after begin). | 
Overrides
CanAttach(RigidBody* rigidBody)
Determines whether this collider can be attached the specified rigid body.
Declaration
public virtual bool CanAttach(RigidBody* rigidBody) constParameters
| RigidBody
        rigidBody The rigid body. | 
Returns
| bool 
   | 
CanBeTrigger()
Determines whether this collider can be a trigger shape.
Declaration
public virtual bool CanBeTrigger() constReturns
| bool 
   | 
ClosestPoint(const Vector3& point, Vector3& result)
Gets a point on the collider that is closest to a given location. Can be used to find a hit location or position to apply explosion force or any other special effects.
Declaration
public virtual void ClosestPoint(const Vector3& point, Vector3& result) const finalParameters
| Vector3
        point The position to find the closest point to it. | 
| Vector3
        result The result point on the collider that is closest to the specified location. | 
Overrides
ComputePenetration(const Collider* colliderA, const Collider* colliderB, Vector3& direction, float& distance)
Computes minimum translational distance between two geometry objects. Translating the first collider by direction * distance will separate the colliders apart if the function returned true. Otherwise, direction and distance are not defined. The one of the colliders has to be BoxCollider, SphereCollider CapsuleCollider or a convex MeshCollider. The other one can be any type. If objects do not overlap, the function can not compute the distance and returns false.
Declaration
public static bool ComputePenetration(const Collider* colliderA, const Collider* colliderB, Vector3& direction, float& distance)Parameters
| Collider
        colliderA The first collider. | 
| Collider
        colliderB The second collider. | 
| Vector3
        direction The computed direction along which the translation required to separate the colliders apart is minimal. Valid only if function returns true. | 
| float
        distance The penetration distance along direction that is required to separate the colliders apart. Valid only if function returns true. | 
Returns
| bool True if the distance has successfully been computed, i.e. if objects do overlap, otherwise false. | 
ContainsPoint(const Vector3& point)
Checks if a point is inside the collider.
Declaration
public virtual bool ContainsPoint(const Vector3& point) const finalParameters
| Vector3
        point The point to check if is contained by the collider shape (in world-space). | 
Returns
| bool True if collider shape contains a given point, otherwise false. | 
Overrides
CreateShape()
Creates the collider shape.
Declaration
protected virtual void CreateShape()CreateStaticActor()
Creates the static actor.
Declaration
protected void CreateStaticActor()EndPlay()
Called when removing object from the game.
Declaration
protected virtual void EndPlay() overrideOverrides
GetAttachedRigidBody()
Gets the attached rigid body.
Declaration
public virtual RigidBody* GetAttachedRigidBody() const overrideReturns
| RigidBody The rigid body or null. | 
Overrides
GetCenter()
Gets the center of the collider, measured in the object's local space.
Declaration
public Vector3 GetCenter() constReturns
| Vector3 
 | 
GetContactOffset()
Gets the contact offset. Colliders whose distance is less than the sum of their ContactOffset values will generate contacts. The contact offset must be positive. Contact offset allows the collision detection system to predictively enforce the contact constraint even when the objects are slightly separated.
Declaration
public float GetContactOffset() constReturns
| float 
 | 
GetGeometry(CollisionShape& collision)
Gets the collider shape geometry.
Declaration
protected virtual void GetGeometry(CollisionShape& collision) = 0Parameters
| CollisionShape
        collision The output collision shape. | 
GetIsTrigger()
Gets the 'IsTrigger' flag. A trigger doesn't register a collision with an incoming Rigidbody. Instead, it sends OnTriggerEnter and OnTriggerExit message when a rigidbody enters or exits the trigger volume.
Declaration
public bool GetIsTrigger() constReturns
| bool 
 | 
GetPhysicsShape()
Gets the native physics backend object.
Declaration
public void* GetPhysicsShape() constReturns
| void 
 | 
OnActiveInTreeChanged()
Called when actor active in tree state gets changed.
Declaration
protected virtual void OnActiveInTreeChanged() overrideOverrides
OnAssetChanged(Asset* asset, void* caller)
Declaration
protected virtual void OnAssetChanged(Asset* asset, void* caller) overrideParameters
| Asset
        asset 
 | 
| void
        caller 
 | 
Overrides
OnAssetLoaded(Asset* asset, void* caller)
Declaration
protected virtual void OnAssetLoaded(Asset* asset, void* caller) overrideParameters
| Asset
        asset 
 | 
| void
        caller 
 | 
Overrides
OnAssetUnloaded(Asset* asset, void* caller)
Declaration
protected virtual void OnAssetUnloaded(Asset* asset, void* caller) overrideParameters
| Asset
        asset 
 | 
| void
        caller 
 | 
Overrides
OnDisable()
Called when actor gets removed from game systems. Occurs on EndPlay event or when actor gets inactivated in hierarchy. Use this event to unregister object from other game system (eg. audio).
Declaration
protected virtual void OnDisable() overrideOverrides
OnEnable()
Called when actor gets added to game systems. Occurs on BeginPlay event or when actor gets activated in hierarchy. Use this event to register object to other game system (eg. audio).
Declaration
protected virtual void OnEnable() overrideOverrides
OnLayerChanged()
Called when layer gets changed.
Declaration
protected virtual void OnLayerChanged() overrideOverrides
OnParentChanged()
Called when actor parent gets changed.
Declaration
protected virtual void OnParentChanged() overrideOverrides
OnPhysicsSceneChanged(PhysicsScene* previous)
Declaration
protected virtual void OnPhysicsSceneChanged(PhysicsScene* previous) overrideParameters
| PhysicsScene
        previous 
 | 
Overrides
OnStaticFlagsChanged()
Called when actor static flag gets changed.
Declaration
protected virtual void OnStaticFlagsChanged() overrideOverrides
OnTransformChanged()
Called when actor transform gets changed.
Declaration
protected virtual void OnTransformChanged() overrideOverrides
RayCast(const Vector3& origin, const Vector3& direction, float& resultHitDistance, float maxDistance=MAX_float)
Performs a raycast against this collider shape.
Declaration
public virtual bool RayCast(const Vector3& origin, const Vector3& direction, float& resultHitDistance, float maxDistance=MAX_float) const finalParameters
| Vector3
        origin The origin of the ray. | 
| Vector3
        direction The normalized direction of the ray. | 
| float
        resultHitDistance The raycast result hit position distance from the ray origin. Valid only if raycast hits anything. | 
| float
        maxDistance The maximum distance the ray should check for collisions. | 
Returns
| bool True if ray hits an object, otherwise false. | 
Overrides
RayCast(const Vector3& origin, const Vector3& direction, RayCastHit& hitInfo, float maxDistance=MAX_float)
Performs a raycast against this collider, returns results in a RaycastHit structure.
Declaration
public virtual bool RayCast(const Vector3& origin, const Vector3& direction, RayCastHit& hitInfo, float maxDistance=MAX_float) const finalParameters
| Vector3
        origin The origin of the ray. | 
| Vector3
        direction The normalized direction of the ray. | 
| RayCastHit
        hitInfo The result hit information. Valid only when method returns true. | 
| float
        maxDistance The maximum distance the ray should check for collisions. | 
Returns
| bool True if ray hits an object, otherwise false. | 
Overrides
RemoveStaticActor()
Removes the static actor.
Declaration
protected void RemoveStaticActor()SetCenter(const Vector3& value)
Sets the center of the collider, measured in the object's local space.
Declaration
public virtual void SetCenter(const Vector3& value)Parameters
| Vector3
        value 
 | 
SetContactOffset(float value)
Sets the contact offset. Colliders whose distance is less than the sum of their ContactOffset values will generate contacts. The contact offset must be positive. Contact offset allows the collision detection system to predictively enforce the contact constraint even when the objects are slightly separated.
Declaration
public void SetContactOffset(float value)Parameters
| float
        value 
 | 
SetIsTrigger(bool value)
Sets the IsTrigger flag. A trigger doesn't register a collision with an incoming Rigidbody. Instead, it sends OnTriggerEnter and OnTriggerExit message when a rigidbody enters or exits the trigger volume. 
Declaration
public void SetIsTrigger(bool value)Parameters
| bool
        value 
 | 
UpdateBounds()
Updates the bounding box of the shape.
Declaration
protected virtual void UpdateBounds() = 0UpdateGeometry()
Updates the shape geometry.
Declaration
protected virtual void UpdateGeometry()UpdateLayerBits()
Updates the shape actor collisions/queries layer mask bits.
Declaration
protected void UpdateLayerBits()