Skip to main content

Editor.Components.Physics.BodyComponent

Class

Rigid body physics component for dynamic objects.

Index

Example

const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
const scene = model.project.scene;

const obj = scene.createSceneObject('PhysicsBody');
const body = obj.addComponent('BodyComponent') as Editor.Components.Physics.BodyComponent;

body.dynamic = true;
body.damping = 0.5;
body.angularDamping = 0.1;
console.log(`BodyComponent: dynamic=${body.dynamic}, damping=${body.damping}, angularDamping=${body.angularDamping}`);

Extends

Properties

angularDamping

angularDamping: number

Rotational resistance value.


bodySetting

bodySetting: BodySetting

Body configuration mode.


bodySettingValue

bodySettingValue: number

Numeric value for the selected body setting.


damping

damping: number

Linear movement resistance value.


debugDrawEnabled

debugDrawEnabled: boolean

Enable visual debugging of the collider shape.

Inherited from

ColliderComponent.debugDrawEnabled


dynamic

dynamic: boolean

Whether the body is affected by physics forces.


enabled

enabled: boolean

Whether the component is active.

Inherited from

ColliderComponent.enabled


excludeFromParentCompounding

excludeFromParentCompounding: boolean

If enabled, this collider is never merged into an ancestor's compound shape and is simulated as its own top-level collider. It can still compound its own children.

Inherited from

ColliderComponent.excludeFromParentCompounding


filter

filter: Filter

Collision filtering rules for this collider.

Inherited from

ColliderComponent.filter


fitVisual

fitVisual: boolean

Automatically match collider shape to visual bounds.

Inherited from

ColliderComponent.fitVisual


forceCompound

forceCompound: boolean

Force collision shape to use compound geometry.

Inherited from

ColliderComponent.forceCompound


hasPrefabChanges

readonly hasPrefabChanges: boolean

Whether this entity differs from its counterpart in the prefab or was added to the prefab instance. Always false outside prefab instances.

Inherited from

ColliderComponent.hasPrefabChanges


id

readonly id: Uuid

The unique id of the entity.

Inherited from

ColliderComponent.id


intangible

intangible: boolean

Disable collision response while maintaining overlap detection.

Inherited from

ColliderComponent.intangible


isPrefabInstanceRoot

readonly isPrefabInstanceRoot: boolean

Whether this entity is the root of a prefab instance.

Inherited from

ColliderComponent.isPrefabInstanceRoot


matter

matter: Matter

Physics material properties for this collider.

Inherited from

ColliderComponent.matter


meta

readonly meta: Meta

Metadata associated with this entity, providing access to its unique identifier and other descriptive properties.

Inherited from

ColliderComponent.meta


name

name: string

Name of the component.

Inherited from

ColliderComponent.name


overlapFilter

overlapFilter: Filter

Filtering rules for overlap queries on this collider.

Inherited from

ColliderComponent.overlapFilter


rotateSmoothFactor

rotateSmoothFactor: number

Damping factor for rotational motion.

Inherited from

ColliderComponent.rotateSmoothFactor


sceneObject

readonly sceneObject: SceneObject

Scene object this component is attached to.

Inherited from

ColliderComponent.sceneObject


shape

shape: Shape

Collision shape definition.

Inherited from

ColliderComponent.shape


smooth

smooth: boolean

Enable motion smoothing between physics updates.

Inherited from

ColliderComponent.smooth


translateSmoothFactor

translateSmoothFactor: number

Damping factor for translational motion.

Inherited from

ColliderComponent.translateSmoothFactor


type

readonly type: string

The entity's type.

Inherited from

ColliderComponent.type


worldSettings

worldSettings: WorldSettingsAsset

Physics simulation settings for this collider's world.

Inherited from

ColliderComponent.worldSettings

Methods

getDirectlyReferencedEntities()

getDirectlyReferencedEntities(): Entity[]

A list of entities which this entity has a reference to.

Returns

Entity[]

Inherited from

ColliderComponent.getDirectlyReferencedEntities


getMeta()

static getMeta(): Meta

Returns metadata about this type.

Returns

Meta

Overrides

ColliderComponent.getMeta


getOwnedEntities()

getOwnedEntities(): Entity[]

A list of entities which has a reference to this entity.

Returns

Entity[]

Inherited from

ColliderComponent.getOwnedEntities


getPrefabInstanceRoot()

getPrefabInstanceRoot(): Prefabable

Returns the nearest prefab instance root that contains this entity, starting with the entity itself, or null if it is not part of a prefab instance.

Returns

Prefabable

Inherited from

ColliderComponent.getPrefabInstanceRoot


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

ColliderComponent.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ColliderComponent.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ColliderComponent.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ColliderComponent.isSame