BodyComponent
Hierarchy
- Component
- BodyComponent
Implements
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
optionaloptions: BodyComponentOptions
Returns BodyComponent
Properties
publicbounciness
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.
publiccanSleep
Can this body sleep, by default bodies do not sleep
publiccollisionType
Collision type for the rigidbody physics simulation, by default [[CollisionType.PreventCollision]]
publicdependencies
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
publicenableFixedUpdateInterpolate
Enable or disabled the fixed update interpolation, by default interpolation is on.
publicevents
publicfriction
The coefficient of friction on this actor
publicgroup
The collision group for the body's colliders, by default body colliders collide with everything
publicreadonlyid
publiclimitDegreeOfFreedom
Degrees of freedom to limit
Note: this only limits responses in the realistic solver, if velocity/angularVelocity is set the actor will still respond
publicmotion
publicoldAcc
Gets/sets the acceleration of the actor from the last frame. This does not include the global acc [[Physics.acc]].
publicoldTransform
publicoldVel
The velocity of the actor last frame (vx, vy) in pixels/second
optionalowner
Current owning [[Entity]], if any, of this component. Null if not added to any [[Entity]]
publicsleepMotion
Amount of "motion" the body has before sleeping. If below [[Physics.sleepEpsilon]] it goes to "sleep"
publictransform
publicuseGravity
Should use global gravity [[Physics.gravity]] in it's physics simulation, default is true
publicwakeThreshold
publicstatic_ID
Accessors
publicacc
publicactive
Returns if the owner is active
Returns boolean
publicangularVelocity
Get the angular velocity in radians/second
Returns number
Set the angular velocity in radians/second
Parameters
value: number
Returns void
publiccenter
Returns Vector
publicglobalPos
publicinertia
Get the moment of inertia from the [[ColliderComponent]]
Returns number
publicinverseInertia
Get the inverse moment of inertial from the [[ColliderComponent]]. If [[CollisionType.Fixed]] this is 0, meaning "infinite" mass
Returns number
publicinverseMass
The inverse mass (1/mass) of the body. If [[CollisionType.Fixed]] this is 0, meaning "infinite" mass
Returns number
publicmass
Returns number
Parameters
newMass: number
Returns void
publicmatrix
Returns AffineMatrix
publicoldGlobalPos
The global position of the actor last frame (x, y) in pixels
Returns Vector
publicoldPos
The position of the actor last frame (x, y) in pixels
Returns Vector
publicoldRotation
Gets/sets the rotation of the body from the last frame.
Returns number
publicoldScale
The scale of the actor last frame
Returns Vector
publicpos
publicrotation
The rotation of the body in radians
Returns number
Parameters
val: number
Returns void
publicscale
publicscaleFactor
publicsleeping
Whether this body is sleeping or not
Returns boolean
publictorque
The current torque applied to the actor
Returns number
Parameters
val: number
Returns void
publicvel
Methods
publicapplyAngularImpulse
publicapplyImpulse
publicapplyLinearImpulse
Apply only linear impulse to the body
Parameters
impulse: Vector
Returns void
publiccaptureOldTransform
Sets the old versions of pos, vel, acc, and scale.
Returns void
publicclone
Clones any properties on this component, if that property value has a
clone()
method it will be calledReturns BodyComponent
onAdd
Optional callback called when a component is added to an entity
Parameters
owner: Entity<any>
Returns void
optionalonRemove
Optional callback called when a component is removed from an entity
Parameters
previousOwner: Entity<any>
Returns void
publicsetSleeping
Set the sleep state of the body
Parameters
sleeping: boolean
Returns void
publicupdateMotion
Update body's [[BodyComponent.sleepMotion]] for the purpose of sleeping
Returns void
publicupdatePhysicsConfig
Called by excalibur to update physics config defaults if they change
Parameters
config: Required<{ canSleepByDefault?: boolean; defaultMass?: number; sleepBias?: number; sleepEpsilon?: number; wakeThreshold?: number }>
Returns void
publicstaticupdateDefaultPhysicsConfig
Called by excalibur to update defaults
Parameters
config: Required<{ canSleepByDefault?: boolean; defaultMass?: number; sleepBias?: number; sleepEpsilon?: number; wakeThreshold?: number }>
Returns void
Body describes all the physical properties pos, vel, acc, rotation, angular velocity for the purpose of of physics simulation.