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
Fields
_cachedLocalPosePos
Declaration
protected Vector3 _cachedLocalPosePos
Field Value
Vector3
|
_cachedLocalPoseRot
_cachedScale
Declaration
protected Float3 _cachedScale
Field Value
Float3
|
_center
Declaration
protected Vector3 _center
Field Value
Vector3
|
_contactOffset
Declaration
protected float _contactOffset
Field Value
float
|
_isTrigger
Declaration
protected bool _isTrigger
Field Value
bool
|
_shape
Declaration
protected void* _shape
Field Value
void
|
_staticActor
Declaration
protected void* _staticActor
Field Value
void
|
Material
The physical material used to define the collider physical properties.
Declaration
public JsonAssetReference<PhysicalMaterial> Material
Field 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) override
Parameters
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) const
Parameters
RigidBody
rigidBody
The rigid body. |
Returns
bool
|
CanBeTrigger()
Determines whether this collider can be a trigger shape.
Declaration
public virtual bool CanBeTrigger() const
Returns
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 final
Parameters
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 final
Parameters
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()
DrawPhysicsDebug(RenderView& view)
EndPlay()
Called when removing object from the game.
Declaration
protected virtual void EndPlay() override
Overrides
GetAttachedRigidBody()
Gets the attached rigid body.
Declaration
public virtual RigidBody* GetAttachedRigidBody() const override
Returns
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() const
Returns
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() const
Returns
float
|
GetGeometry(CollisionShape& collision)
Gets the collider shape geometry.
Declaration
protected virtual void GetGeometry(CollisionShape& collision) = 0
Parameters
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() const
Returns
bool
|
GetPhysicsShape()
Gets the native physics backend object.
Declaration
public void* GetPhysicsShape() const
Returns
void
|
OnActiveInTreeChanged()
Called when actor active in tree state gets changed.
Declaration
protected virtual void OnActiveInTreeChanged() override
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() override
Overrides
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() override
Overrides
OnLayerChanged()
Called when layer gets changed.
Declaration
protected virtual void OnLayerChanged() override
Overrides
OnParentChanged()
Called when actor parent gets changed.
Declaration
protected virtual void OnParentChanged() override
Overrides
OnPhysicsSceneChanged(PhysicsScene* previous)
Declaration
protected virtual void OnPhysicsSceneChanged(PhysicsScene* previous) override
Parameters
PhysicsScene
previous
|
Overrides
OnStaticFlagsChanged()
Called when actor static flag gets changed.
Declaration
protected virtual void OnStaticFlagsChanged() override
Overrides
OnTransformChanged()
Called when actor transform gets changed.
Declaration
protected virtual void OnTransformChanged() override
Overrides
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 final
Parameters
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 final
Parameters
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 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() = 0
UpdateGeometry()
Updates the shape geometry.
Declaration
protected virtual void UpdateGeometry()
UpdateLayerBits()
Updates the shape actor collisions/queries layer mask bits.
Declaration
protected void UpdateLayerBits()