Skip to main content

CompositeCollider

A collision collider specifies the geometry that can detect when other collision colliders intersect for the purposes of colliding 2 objects in excalibur.

Hierarchy

Index

Constructors

constructor

Properties

publiccomposite

composite: CompositeCollider = null

Composite collider if any this collider is attached to

WARNING do not tamper with this property

publicevents

events: EventEmitter<any> = ...

publicreadonlyid

id: Id<collider> = ...

offset

offset: Vector = Vector.Zero

Pixel offset of the collision collider relative to the collider, by default (0, 0) meaning the collider is positioned on top of the collider.

publicowner

owner: Entity<any>

Accessors

axes

  • Return the axes of this particular collider


    Returns Vector[]

bounds

  • Return the axis-aligned bounding box of the collision collider in world coordinates


    Returns BoundingBox

center

  • The center point of the collision collider, for example if the collider is a circle it would be the center.


    Returns Vector

publiccompositeStrategy

  • get compositeStrategy(): separate | together
  • set compositeStrategy(value: separate | together): void
  • Returns separate | together

  • Treat composite collider's member colliders as either separate colliders for the purposes of onCollisionStart/onCollision or as a single collider together.

    This property can be overridden on individual [[CompositeColliders]].

    For composites without gaps or small groups of colliders, you probably want 'together'

    For composites with deliberate gaps, like a platforming level layout, you probably want 'separate'

    Default is 'together' if unset


    Parameters

    • value: separate | together

    Returns void

localBounds

  • Return the axis-aligned bounding box of the collision collider in local coordinates


    Returns BoundingBox

worldPos

  • Position of the collision collider in world coordinates


    Returns Vector

Methods

addCollider

  • Parameters

    Returns void

clearColliders

  • clearColliders(): void
  • Returns void

clone

  • Returns Collider

collide

contains

  • contains(point: Vector): boolean
  • Return wether the collider contains a point inclusive to it's border


    Parameters

    Returns boolean

publicdebug

getClosestLineBetween

  • Returns the closest line between the surfaces this collider and another


    Parameters

    Returns LineSegment

getColliders

getFurthestPoint

  • Find the furthest point on the convex hull of this particular collider in a certain direction.


    Parameters

    Returns Vector

getInertia

  • getInertia(mass: number): number
  • Parameters

    • mass: number

    Returns number

project

  • Create a projection of this collider along an axis. Think of this as casting a "shadow" along an axis


    Parameters

    Returns Projection

rayCast

  • Return the point on the border of the collision collider that intersects with a ray (if any).


    Parameters

    • ray: Ray
    • optionalmax: number

    Returns RayCastHit

removeCollider

  • removeCollider(collider: Collider): void
  • Parameters

    Returns void

publictouching

  • Returns a boolean indicating whether this body collided with or was in stationary contact with the body of the other [[Collider]]


    Parameters

    Returns boolean

update

  • Updates collider world space geometry


    Parameters

    Returns void