Search Results for

    Show / Hide Table of Contents

    Class Collider

    A base class for all colliders.

    Inheritance
    Object
    ScriptingObject
    SceneObject
    Actor
    PhysicsColliderActor
    Collider
    Inherited Members
    Actor::_box
    Actor::_drawCategory
    Actor::_drawNoCulling
    ScriptingObject::_gcHandle
    ScriptingObject::_id
    Actor::_isActive
    Actor::_isActiveInHierarchy
    Actor::_isEnabled
    Actor::_isHierarchyDirty
    Actor::_isPrefabRoot
    Actor::_layer
    Actor::_localTransform
    Actor::_name
    SceneObject::_parent
    Actor::_physicsScene
    SceneObject::_prefabID
    SceneObject::_prefabObjectID
    Actor::_scene
    Actor::_sphere
    Actor::_staticFlags
    Actor::_transform
    ScriptingObject::_type
    Actor::AddMovement(const Vector3& translation)
    Actor::AddMovement(const Vector3& translation, const Quaternion& rotation)
    Actor::AddScript()
    Actor::AddStaticFlags(StaticFlags flags)
    Actor::AddTag(const Tag& tag)
    Actor::AddTagRecursive(const Tag& tag)
    Collider
    Actor::BreakPrefabLink()
    ScriptingObject::CanCast(const ScriptingTypeHandle& from, const ScriptingTypeHandle& to)
    ScriptingObject::CanCast(const MClass* from, const MClass* to)
    ScriptingObject::Cast(ScriptingObject* obj)
    ScriptingObject::ChangeID(const Guid& newId)
    Actor::ChangeScriptOrder(Script* script, int32 newIndex)
    Actor::Children
    Actor::Clone()
    PhysicsColliderActor::CollisionEnter
    PhysicsColliderActor::CollisionExit
    ScriptingObject::CreateManaged()
    ScriptingObject::CreateManagedInternal()
    ScriptingObject::Deleted
    Object::DeleteObject(float timeToLive = 0.0f, bool useGameTime=false)
    Object::DeleteObjectNow()
    Actor::DEPRECATED("Use HasTag instead") const String& GetTag()
    Actor::DEPRECATED("Use AddTag instead") void SetTag(const StringView& value)
    Actor::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
    ISerializable::DeserializeIfExists(DeserializeStream& stream, const char* memberName, ISerializeModifier* modifier)
    Collider
    Actor::DestroyChildren(float timeLeft = 0.0f)
    ScriptingObject::DestroyManaged()
    Actor::Draw(RenderContext& renderContext)
    Actor::Draw(RenderContextBatch& renderContextBatch)
    Actor::FindActor(const StringView& name)
    Actor::FindActor(const MClass* type, bool activeOnly=false)
    Actor::FindActor(const MClass* type, const StringView& name)
    Actor::FindActor(const MClass* type, const Tag& tag, bool activeOnly=false)
    Actor::FindActor()
    Actor::FindActor(const Tag& tag)
    Actor::FindScript(const MClass* type)
    Actor::FindScript()
    Object::Flags
    Actor::FromBytes(const Span<byte>& data, Array<Actor* >& output, ISerializeModifier* modifier)
    Actor::FromBytes(const Span<byte>& data)
    Actor::FromBytes(const Span<byte>& data, const Dictionary<Guid, Guid, HeapAllocation>& idsMapping)
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    Actor::FromJson(const StringAnsiView& json)
    Actor::GetBox()
    Actor::GetBoxWithChildren()
    Actor::GetChild(int32 index)
    Actor::GetChild(const StringView& name)
    Actor::GetChild(const MClass* type)
    Actor::GetChild()
    Actor::GetChildren(const MClass* type)
    Actor::GetChildren()
    Actor::GetChildrenCount()
    ScriptingObject::GetClass()
    Actor::GetDirection()
    Actor::GetEditorBox()
    Actor::GetEditorBoxChildren()
    ScriptingObject::GetID()
    Actor::GetIsActive()
    Actor::GetLayer()
    Actor::GetLayerMask()
    Actor::GetLayerName()
    Actor::GetLocalOrientation()
    Actor::GetLocalPosition()
    Actor::GetLocalScale()
    Actor::GetLocalToWorldMatrix(Matrix& localToWorld)
    Actor::GetLocalToWorldMatrix(Double4x4& localToWorld)
    Actor::GetLocalTransform()
    ScriptingObject::GetManagedInstance()
    Actor::GetName()
    SceneObject::GetNamePath(Char separatorChar='/')
    Actor::GetOrAddChild()
    ScriptingObject::GetOrCreateManagedInstance()
    Actor::GetOrderInParent()
    Actor::GetOrientation()
    SceneObject::GetParent()
    Actor::GetPerInstanceRandom()
    Actor::GetPhysicsScene()
    Actor::GetPosition()
    SceneObject::GetPrefabID()
    SceneObject::GetPrefabObjectID()
    Actor::GetPrefabRoot()
    Actor::GetRotation()
    Actor::GetScale()
    Actor::GetScene()
    Actor::GetSceneObjectId()
    Actor::GetSceneRendering()
    Actor::GetScript(int32 index)
    Actor::GetScript(const MClass* type)
    Actor::GetScript()
    Actor::GetScriptByID(const Guid& id)
    Actor::GetScripts(const MClass* type)
    Actor::GetScripts()
    Actor::GetScriptsCount()
    Actor::GetSphere()
    Actor::GetStaticFlags()
    Actor::GetTransform()
    ScriptingObject::GetType()
    ScriptingObject::GetTypeHandle()
    Actor::GetWorldToLocalMatrix(Matrix& worldToLocal)
    Actor::GetWorldToLocalMatrix(Double4x4& worldToLocal)
    Actor::HasActorInChildren(Actor* a)
    Actor::HasActorInHierarchy(Actor* a)
    Actor::HasContentLoaded()
    ScriptingObject::HasManagedInstance()
    SceneObject::HasParent()
    SceneObject::HasPrefabLink()
    Actor::HasScene()
    Actor::HasStaticFlag(StaticFlags flag)
    Actor::HasTag()
    Actor::HasTag(const Tag& tag)
    Actor::HasTag(const StringView& tag)
    Actor::HideFlags
    Actor::Initialize()
    Actor::InitializeHierarchy()
    Actor::Intersects(const Ray& ray, Real& distance, Vector3& normal)
    Actor::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)
    ScriptingObject::Is(const ScriptingTypeHandle& type)
    ScriptingObject::Is(const MClass* type)
    ScriptingObject::Is()
    Actor::IsActiveInHierarchy()
    SceneObject::IsDuringPlay()
    Actor::IsPrefabRoot()
    ScriptingObject::IsRegistered()
    Actor::IsStatic()
    Actor::IsTransformStatic()
    Actor::LinkPrefab(const Guid& prefabId, const Guid& prefabObjectId)
    Actor::LookAt(const Vector3& worldPos)
    Actor::LookAt(const Vector3& worldPos, const Vector3& worldUp)
    Actor::LookingAt(const Vector3& worldPos)
    Actor::LookingAt(const Vector3& worldPos, const Vector3& worldUp)
    ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandle)
    ScriptingObject::NewObject()
    Actor::OnActiveChanged()
    Actor::OnBeginPlay()
    PhysicsColliderActor::OnCollisionEnter(const Collision& c)
    PhysicsColliderActor::OnCollisionExit(const Collision& c)
    Actor::OnDebugDraw()
    Actor::OnDebugDrawSelected()
    Actor::OnDeleteObject()
    Actor::OnEndPlay()
    ScriptingObject::OnManagedInstanceDeleted()
    Actor::OnOrderInParentChanged()
    ScriptingObject::OnScriptingDispose()
    PhysicsColliderActor::OnTriggerEnter(PhysicsColliderActor* c)
    PhysicsColliderActor::OnTriggerExit(PhysicsColliderActor* c)
    ScriptingObject::RegisterObject()
    Actor::RemoveStaticFlags(StaticFlags flags)
    Actor::RemoveTag(const Tag& tag)
    Actor::ResetLocalTransform()
    SceneObject::SceneObject(const SpawnParams& params)
    ScriptingObject::ScriptingObject(const SpawnParams& params)
    Actor::Scripts
    Actor::Serialize(SerializeStream& stream, const void* otherObj)
    Collider
    Collider
    Actor::SetDirection(const Float3& value)
    Actor::SetIsActive(bool value)
    Actor::SetLayer(int32 layerIndex)
    Actor::SetLayerName(const StringView& value)
    Actor::SetLayerNameRecursive(const StringView& value)
    Actor::SetLayerRecursive(int32 layerIndex)
    Actor::SetLocalOrientation(const Quaternion& value)
    Actor::SetLocalPosition(const Vector3& value)
    Actor::SetLocalScale(const Float3& value)
    Actor::SetLocalTransform(const Transform& value)
    ScriptingObject::SetManagedInstance(MObject* instance)
    Actor::SetName(String&& value)
    Actor::SetName(const StringView& value)
    Actor::SetOrderInParent(int32 index)
    Actor::SetOrientation(const Quaternion& value)
    Actor::SetParent(Actor* value, bool worldPositionsStays, bool canBreakPrefabLink)
    Actor::SetParent(Actor* value, bool canBreakPrefabLink=true)
    SceneObject::SetParent(Actor* value)
    Actor::SetPhysicsScene(PhysicsScene* scene)
    Actor::SetPosition(const Vector3& value)
    Actor::SetRotation(const Matrix& value)
    Actor::SetScale(const Float3& value)
    Actor::SetStaticFlag(StaticFlags flag, bool value)
    Actor::SetStaticFlags(StaticFlags value)
    Actor::SetTransform(const Transform& value)
    Collider
    Actor::Tags
    Actor::ToBytes(const Array<Actor* >& actors, MemoryWriteStream& output)
    Actor::ToBytes(const Array<Actor* >& actors)
    ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::ToInterface(ScriptingObject* obj)
    Actor::ToJson()
    ScriptingObject::ToManaged(const ScriptingObject* obj)
    ScriptingObject::ToNative(MObject* obj)
    Actor::ToString()
    Actor::TreeExecute(Function<bool(Actor* , Params ...)>& action, Params ... args)
    Actor::TreeExecuteChildren(Function<bool(Actor* , Params ...)>& action, Params ... args)
    PhysicsColliderActor::TriggerEnter
    PhysicsColliderActor::TriggerExit
    Actor::TryGetSerializedObjectsIds(const Span<byte>& data)
    ScriptingObject::UnregisterObject()
    Actor::UnregisterObjectHierarchy()
    ISerializable::~ISerializable()
    Object::~Object()
    SceneObject::~SceneObject()
    ScriptingObject::~ScriptingObject()
    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

    Declaration
    protected Quaternion _cachedLocalPoseRot
    Field Value
    Quaternion

    _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
    Actor::BeginPlay(SceneBeginData* data)

    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

    true if this collider can be attached the specified rigid body; otherwise, false.

    CanBeTrigger()

    Determines whether this collider can be a trigger shape.

    Declaration
    public virtual bool CanBeTrigger() const
    Returns
    bool

    true if this collider can be trigger; otherwise, false.

    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
    PhysicsColliderActor::ClosestPoint(const Vector3& point, Vector3& result)

    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
    PhysicsColliderActor::ContainsPoint(const Vector3& point)

    CreateShape()

    Creates the collider shape.

    Declaration
    protected virtual void CreateShape()

    CreateStaticActor()

    Creates the static actor.

    Declaration
    protected void CreateStaticActor()

    DrawPhysicsDebug(RenderView& view)

    Declaration
    public virtual void DrawPhysicsDebug(RenderView& view)
    Parameters
    RenderView view

    EndPlay()

    Called when removing object from the game.

    Declaration
    protected virtual void EndPlay() override
    Overrides
    Actor::EndPlay()

    GetAttachedRigidBody()

    Gets the attached rigid body.

    Declaration
    public virtual RigidBody* GetAttachedRigidBody() const override
    Returns
    RigidBody

    The rigid body or null.

    Overrides
    PhysicsColliderActor::GetAttachedRigidBody()

    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
    Actor::OnActiveInTreeChanged()

    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
    Actor::OnDisable()

    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
    Actor::OnEnable()

    OnLayerChanged()

    Called when layer gets changed.

    Declaration
    protected virtual void OnLayerChanged() override
    Overrides
    Actor::OnLayerChanged()

    OnParentChanged()

    Called when actor parent gets changed.

    Declaration
    protected virtual void OnParentChanged() override
    Overrides
    Actor::OnParentChanged()

    OnPhysicsSceneChanged(PhysicsScene* previous)

    Declaration
    protected virtual void OnPhysicsSceneChanged(PhysicsScene* previous) override
    Parameters
    PhysicsScene previous

    Overrides
    Actor::OnPhysicsSceneChanged(PhysicsScene* previous)

    OnStaticFlagsChanged()

    Called when actor static flag gets changed.

    Declaration
    protected virtual void OnStaticFlagsChanged() override
    Overrides
    Actor::OnStaticFlagsChanged()

    OnTransformChanged()

    Called when actor transform gets changed.

    Declaration
    protected virtual void OnTransformChanged() override
    Overrides
    Actor::OnTransformChanged()

    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
    PhysicsColliderActor::RayCast(const Vector3& origin, const Vector3& direction, float& resultHitDistance, float maxDistance=MAX_float)

    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
    PhysicsColliderActor::RayCast(const Vector3& origin, const Vector3& direction, RayCastHit& hitInfo, float maxDistance=MAX_float)

    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()

    See Also

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat