ConstraintComponent¶
ConstraintComponent ¶
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.
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
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
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
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.
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_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.
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_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.
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
PrismaticConstraint ¶
Bases: Constraint