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
WeldConstraint ¶
Bases: Constraint
PrismaticConstraint ¶
Bases: Constraint