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

angle property

angle: float

Current joint angle in radians, relative to the pose when tracking began, unwrapped (can exceed ±pi). Only tracked while a motor or limits are enabled; stays 0 until the first solver step after enabling either.

limits_enabled property writable

limits_enabled: bool

Whether the joint angle is restricted to [lower_limit, upper_limit]

lower_limit property writable

lower_limit: float

Lower joint angle limit in radians, relative to the starting pose. Raising it above upper_limit pushes upper_limit up with it.

max_motor_speed property writable

max_motor_speed: float

Maximum angular speed (radians per second) the position motor will drive at. Clamped to >= 0.

max_motor_torque property writable

max_motor_torque: float

Maximum torque the motor may apply (either mode). Clamped to >= 0.

motor_mode property writable

motor_mode: MotorMode

Current MotorMode (Off, Velocity, or Position)

motor_speed property writable

motor_speed: float

Target relative angular velocity in radians per second. Only used when motor_mode is MotorMode.Velocity.

servo_gain property writable

servo_gain: float

Position-motor gain in 1/s: desired speed = gain * angle error, capped by max_motor_speed. Clamped to >= 0.

target_angle property writable

target_angle: float

Target joint angle in radians, relative to the pose the joint had when its angle tracking started (see angle). Only used when motor_mode is MotorMode.Position.

upper_limit property writable

upper_limit: float

Upper joint angle limit in radians, relative to the starting pose. Lowering it below lower_limit pulls lower_limit down with it.

disable_limits

disable_limits() -> None

Disable the joint angle limits

disable_motor

disable_motor() -> None

Turn the motor off (sets motor_mode to MotorMode.Off)

set_limits

set_limits(lower: SupportsFloat | SupportsIndex, upper: SupportsFloat | SupportsIndex) -> None

Enable limits and set both bounds (radians) in one call.

Example
door_hinge.set_limits(0.0, 1.57)

set_limits_enabled

set_limits_enabled(limits_enabled: bool) -> None

Set limits_enabled. See the limits_enabled property.

set_lower_limit

set_lower_limit(lower_limit: SupportsFloat | SupportsIndex) -> None

Set lower_limit. See the lower_limit property.

set_max_motor_speed

set_max_motor_speed(max_motor_speed: SupportsFloat | SupportsIndex) -> None

Set max_motor_speed. See the max_motor_speed property.

set_max_motor_torque

set_max_motor_torque(max_motor_torque: SupportsFloat | SupportsIndex) -> None

Set max_motor_torque. See the max_motor_torque property.

set_motor_mode

set_motor_mode(mode: MotorMode) -> None

Set motor_mode. See the motor_mode property.

set_motor_speed

set_motor_speed(motor_speed: SupportsFloat | SupportsIndex) -> None

Set motor_speed. See the motor_speed property.

set_position_motor

set_position_motor(target_angle: SupportsFloat | SupportsIndex, gain: SupportsFloat | SupportsIndex, max_speed: SupportsFloat | SupportsIndex, max_torque: SupportsFloat | SupportsIndex) -> None

Enable the motor in position (servo) mode in one call.

Example
arm_joint.set_position_motor(1.57, 10.0, 5.0, 50.0)

set_servo_gain

set_servo_gain(servo_gain: SupportsFloat | SupportsIndex) -> None

Set servo_gain. See the servo_gain property.

set_target_angle

set_target_angle(target_angle: SupportsFloat | SupportsIndex) -> None

Set target_angle. See the target_angle property.

set_upper_limit

set_upper_limit(upper_limit: SupportsFloat | SupportsIndex) -> None

Set upper_limit. See the upper_limit property.

set_velocity_motor

set_velocity_motor(speed: SupportsFloat | SupportsIndex, max_torque: SupportsFloat | SupportsIndex) -> None

Enable the motor in velocity mode in one call.

Example
wheel_joint.set_velocity_motor(6.28, 100.0)  # one rev/sec

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)