Class Collider
A base class for all colliders.
Inheritance
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public abstract class Collider : PhysicsColliderActor, ISerializable
Constructors
Collider()
Properties
Center
Gets or sets the center of the collider, measured in the object's local space.
Declaration
[EditorOrder(10)]
[EditorDisplay("Collider", null)]
[Unmanaged]
public Vector3 Center { get; set; }
Property Value
Vector3
|
ContactOffset
Gets or 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
[EditorOrder(1)]
[Limit(0F, 100F, 1F)]
[EditorDisplay("Collider", null)]
[Unmanaged]
public float ContactOffset { get; set; }
Property Value
System.Single
|
IsTrigger
Gets or 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
[EditorOrder(0)]
[EditorDisplay("Collider", null)]
[Unmanaged]
public bool IsTrigger { get; set; }
Property Value
System.Boolean
|
Material
The physical material used to define the collider physical properties.
Declaration
[EditorOrder(2)]
[AssetReference]
[EditorDisplay("Collider", null)]
[Unmanaged]
public JsonAsset Material { get; set; }
Property Value
JsonAsset
|
Methods
ClosestPoint(Vector3, out Vector3)
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
[Unmanaged]
public void ClosestPoint(Vector3 point, out Vector3 result)
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. |
ComputePenetration(Collider, Collider, out Vector3, out Single)
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
[Unmanaged]
public static bool ComputePenetration(Collider colliderA, Collider colliderB, out Vector3 direction, out 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. |
System.Single
distance
The penetration distance along direction that is required to separate the colliders apart. Valid only if function returns true. |
Returns
System.Boolean
True if the distance has successfully been computed, i.e. if objects do overlap, otherwise false. |
ContainsPoint(Vector3)
Checks if a point is inside the collider.
Declaration
[Unmanaged]
public bool ContainsPoint(Vector3 point)
Parameters
Vector3
point
The point to check if is contained by the collider shape (in world-space). |
Returns
System.Boolean
True if collider shape contains a given point, otherwise false. |
RayCast(Vector3, Vector3, out RayCastHit, Single)
Performs a raycast against this collider, returns results in a RaycastHit structure.
Declaration
[Unmanaged]
public bool RayCast(Vector3 origin, Vector3 direction, out RayCastHit hitInfo, float maxDistance = 3.40282347E+38F)
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. |
System.Single
maxDistance
The maximum distance the ray should check for collisions. |
Returns
System.Boolean
True if ray hits an object, otherwise false. |
RayCast(Vector3, Vector3, out Single, Single)
Performs a raycast against this collider shape.
Declaration
[Unmanaged]
public bool RayCast(Vector3 origin, Vector3 direction, out float resultHitDistance, float maxDistance = 3.40282347E+38F)
Parameters
Vector3
origin
The origin of the ray. |
Vector3
direction
The normalized direction of the ray. |
System.Single
resultHitDistance
The raycast result hit position distance from the ray origin. Valid only if raycast hits anything. |
System.Single
maxDistance
The maximum distance the ray should check for collisions. |
Returns
System.Boolean
True if ray hits an object, otherwise false. |