Options
All
  • Public
  • Public/Protected
  • All
Menu

Body describes all the physical properties pos, vel, acc, rotation, angular velocity for the purpose of of physics simulation.

Hierarchy

Implements

Index

Constructors

Properties

__oldTransformCaptured: boolean = false

Indicates whether the old transform has been captured at least once for interpolation

internal
bounciness: number = 0.2

The also known as coefficient of restitution of this actor, represents the amount of energy preserved after collision or the bounciness. If 1, it is 100% bouncy, 0 it completely absorbs.

canSleep: boolean = Physics.bodiesCanSleepByDefault

Can this body sleep, by default bodies do not sleep

collisionType: CollisionType = CollisionType.PreventCollision

Collision type for the rigidbody physics simulation, by default CollisionType.PreventCollision

dependencies: (typeof TransformComponent | typeof MotionComponent)[] = ...

Optionally list any component types this component depends on If the owner entity does not have these components, new components will be added to the entity

Only components with zero-arg constructors are supported as automatic component dependencies

enableFixedUpdateInterpolate: boolean = true

Enable or disabled the fixed update interpolation, by default interpolation is on.

events: EventDispatcher<any> = ...
friction: number = 0.99

The coefficient of friction on this actor

group: CollisionGroup = CollisionGroup.All

The collision group for the body's colliders, by default body colliders collide with everything

id: Id<"body"> = ...
limitDegreeOfFreedom: DegreeOfFreedom[] = []

Degrees of freedom to limit

Note: this only limits responses in the realistic solver, if velocity/angularVelocity is set the actor will still respond

oldAcc: Vector = Vector.Zero

Gets/sets the acceleration of the actor from the last frame. This does not include the global acc Physics.acc.

oldVel: Vector = ...

The velocity of the actor last frame (vx, vy) in pixels/second

optional?: ComponentCtor<Component<string>>[]
owner?: Entity = null

Current owning Entity, if any, of this component. Null if not added to any Entity

sleepMotion: number = ...

Amount of "motion" the body has before sleeping. If below Physics.sleepEpsilon it goes to "sleep"

type: "ex.body" = 'ex.body'

Type of this component, must be a unique type among component types in you game.

useGravity: boolean = true

Should use global gravity Physics.gravity in it's physics simulation, default is true

_ID: number = 0

Accessors

  • The current acceleration vector (ax, ay) of the actor in pixels/second/second. An acceleration pointing down such as (0, 100) may be useful to simulate a gravitational effect.

    Returns Vector

  • The current acceleration vector (ax, ay) of the actor in pixels/second/second. An acceleration pointing down such as (0, 100) may be useful to simulate a gravitational effect.

    Parameters

    Returns void

  • get active(): boolean
  • get angularVelocity(): number
  • set angularVelocity(value: number): void
  • The (x, y) position of the actor this will be in the middle of the actor if the Actor.anchor is set to (0.5, 0.5) which is default. If you want the (x, y) position to be the top left of the actor specify an anchor of (0, 0).

    Returns Vector

  • The (x, y) position of the actor this will be in the middle of the actor if the Actor.anchor is set to (0.5, 0.5) which is default. If you want the (x, y) position to be the top left of the actor specify an anchor of (0, 0).

    Parameters

    Returns void

  • get inertia(): number
  • get inverseInertia(): number
  • get inverseMass(): number
  • get mass(): number
  • set mass(newMass: number): void
  • get oldRotation(): number
  • get rotation(): number
  • set rotation(val: number): void
  • get scaleFactor(): Vector
  • set scaleFactor(scaleFactor: Vector): void
  • get sleeping(): boolean
  • get torque(): number
  • set torque(val: number): void

Methods

  • applyLinearImpulse(impulse: Vector): void
  • captureOldTransform(): void
  • onRemove(previousOwner: Entity): void
  • setSleeping(sleeping: boolean): void
  • updateMotion(): void