Skip to content

ConstraintComponent

ConstraintComponent

constraints property

constraints: list[Constraint]

Constraints this object owns (as Object A)

mirrored_constraints property

mirrored_constraints: list[Constraint]

Constraints another object owns where this object is Object B. Read-only from here — modify them via their owner's ConstraintComponent instead.

owner property

owner: Object

The Object that owns this component

add_child

add_child(obj: Object) -> Object

Add obj as a child of this component's owning Object

add_component

add_component(component_class: Any) -> typing.Any

Attach a new component of the given type to this component's owning Object.

Example
render = self.add_component(RenderComponent)

add_constraint

add_constraint(constraint: Constraint) -> None

Register a constraint (e.g. a DistanceConstraint) with this object and the physics engine.

Example
cc.add_constraint(DistanceConstraint(self.owner, target, 5.0))

add_object

add_object(obj: Object, parent: Object = None) -> Object

Add a newly created Object to the scene, optionally parented to another Object

get_component

get_component(component_class: Any) -> typing.Any

Look up a component on this Object

get_constraint_count

get_constraint_count() -> int

Number of constraints this object owns

get_owner

get_owner() -> Object

The Object that owns this component

has_component

has_component(component_class: Any) -> bool

Check whether this component's owning Object has a component of the given type

remove_component

remove_component(component_class: Any) -> None

Remove a component of the given type from this component's owning Object

remove_object

remove_object(obj: Object) -> None

Remove an object from the scene

Constraint

Base class for physics constraints (DistanceConstraint, SpringConstraint, RevoluteConstraint, WeldConstraint, PrismaticConstraint). Not constructed directly.

attach_point_a property writable

attach_point_a: Vector3

Local-space attach point on Object A. Setting this disables use_center_a.

attach_point_b property writable

attach_point_b: Vector3

Local-space attach point on Object B. Setting this disables use_center_b.

beta property writable

beta: float

Baumgarte position-correction factor (0-1). Higher values correct constraint drift faster but can introduce jitter.

draw_constraint property writable

draw_constraint: bool

Whether to draw this constraint's debug visualization in the editor/game view

name property

name: str

The constraint's type name, e.g. 'DistanceConstraint'

object_a property

object_a: Object

The first Object this constraint is attached to

object_b property

object_b: Object

The second Object this constraint is attached to, or None

use_center_a property writable

use_center_a: bool

Whether Object A's attach point tracks its RenderComponent center automatically. Setting this to True immediately snaps attach_point_a to that center; setting attach_point_a directly turns this back off.

use_center_b property writable

use_center_b: bool

Whether Object B's attach point tracks its RenderComponent center automatically. Setting this to True immediately snaps attach_point_b to that center; setting attach_point_b directly turns this back off.

__repr__

__repr__() -> str

get_attach_world_a

get_attach_world_a() -> Vector3

World-space position of attach_point_a, given Object A's current transform

get_attach_world_b

get_attach_world_b() -> Vector3

World-space position of attach_point_b, given Object B's current transform

set_beta

set_beta(beta: SupportsFloat | SupportsIndex) -> None

Set beta. See the beta property.

set_draw_constraint

set_draw_constraint(draw_constraint: bool) -> None

Set draw_constraint. See the draw_constraint property.

set_object_a

set_object_a(object: Object) -> None

Change the owning object (Object A). Attach point resets to that object's center.

set_object_b

set_object_b(object: Object) -> None

Change the other object (Object B), or None to detach it. Attach point resets to that object's center.

DistanceConstraint

Bases: Constraint

distance property writable

distance: float

Target distance the constraint tries to maintain between its two attach points

extendable property writable

extendable: bool

If True, the two bodies may move further apart than distance (rope-like); the constraint only resists moving closer

retractable property writable

retractable: bool

If True, the two bodies may move closer than distance (rod pushing only); the constraint only resists moving further apart

set_distance

set_distance(distance: SupportsFloat | SupportsIndex) -> None

Set distance. See the distance property.

set_extendable

set_extendable(extendable: bool) -> None

Set extendable. See the extendable property.

set_retractable

set_retractable(retractable: bool) -> None

Set retractable. See the retractable property.

SpringConstraint

Bases: Constraint

damping property writable

damping: float

Damping coefficient. Higher values reduce oscillation around the rest length.

length property writable

length: float

Rest length of the spring

stiffness property writable

stiffness: float

Spring constant. Higher values pull back to the rest length more strongly.

set_damping

set_damping(damping: SupportsFloat | SupportsIndex) -> None

Set damping. See the damping property.

set_length

set_length(length: SupportsFloat | SupportsIndex) -> None

Set length. See the length property.

set_stiffness

set_stiffness(stiffness: SupportsFloat | SupportsIndex) -> None

Set stiffness. See the stiffness property.

RevoluteConstraint

Bases: Constraint

WeldConstraint

Bases: Constraint

angular_offset property writable

angular_offset: float

Fixed rotational offset (radians) maintained between Object A and Object B

set_angular_offset

set_angular_offset(angular_offset: SupportsFloat | SupportsIndex) -> None

Set angular_offset. See the angular_offset property.

PrismaticConstraint

Bases: Constraint

dir property

dir: Vector3

The locked slide direction. Read-only from script — use relock_direction() to update it.

relock_direction

relock_direction() -> None

Recompute the locked slide direction from the objects' current world positions (mirrors the inspector's 'Re-lock direction' button)