BodyComp
:The body component.
group
Component Types
vel
: Vec2Object current velocity.
since
v3001.0
damping
: numberHow much velocity decays (velocity *= 1 / (1 + damping * dt) every frame).
since
v3001.0
isStatic
: booleanIf object is static, it won't move, all non static objects won't move past it, and all calls to addForce(), applyImpulse(), or jump() on this body will do absolutely nothing.
jumpForce
: numberInitial speed in pixels per second for jump().
gravityScale
: numberGravity multiplier.
mass
: numberMass of the body, decides how much a non-static body should move when resolves with another non-static body. (default 1).
since
v3000.0
stickToPlatform
?: booleanIf object should move with moving platform (default true).
since
v3000.0
curPlatform
(): GameObj | nullCurrent platform landing on.
isGrounded
(): booleanIf currently landing on a platform.
since
v2000.1
isFalling
(): booleanIf currently falling.
since
v2000.1
isJumping
(): booleanIf currently rising.
since
v3000.0
applyImpulse
(impulse: Vec2): voidApplies an impulse
param
impulse- The impulse vector, applied directly
addForce
(force: Vec2): voidApplies a force
param
force- The force vector, applied after scaled by the inverse mass
jump
(force?: number): voidUpward thrust.
onPhysicsResolve
(action: (col: Collision) => void): KEventControllerRegister an event that runs when a collision is resolved.
since
v3000.0
onBeforePhysicsResolve
(action: (col: Collision) => void): KEventControllerRegister an event that runs before a collision would be resolved.
since
v3000.0
onGround
(action: () => void): KEventControllerRegister an event that runs when the object is grounded.
since
v2000.1
onFall
(action: () => void): KEventControllerRegister an event that runs when the object starts falling.
since
v2000.1
onFallOff
(action: () => void): KEventControllerRegister an event that runs when the object falls off platform.
since
v3000.0
onHeadbutt
(action: () => void): KEventControllerRegister an event that runs when the object bumps into something on the head.
since
v2000.1
onLand
(action: (obj: GameObj) => void): KEventControllerRegister an event that runs when an object lands on this object.
since
v3001.0
onHeadbutted
(action: (obj: GameObj) => void): KEventControllerRegister an event that runs when the object is bumped by another object head.