class

CP::Constraint

Inherits Reference / Object

A constraint is something that describes how two bodies interact with each other (how they constrain each other). Constraints can be simple joints that allow bodies to pivot around each other like the bones in your body, or they can be more abstract like the gear joint or motors.

Instance methods

bodies

Get the bodies the constraint is attached to.

Source
body_a

Get the first body the constraint is attached to.

Source
body_b

Get the second body the constraint is attached to.

Source
collide_bodies=(collide_bodies : Bool)
Source
collide_bodies?

Are the two bodies connected by the constraint allowed to collide or not?

(defaults to false)

Source
error_bias

Rate at which joint error is corrected.

Defaults to (1.0 - 0.1) ** 60.0 meaning that it will correct 10% of the error every 1/60th of a second.

Source
error_bias=(error_bias : Number)
Source
impulse

Get the most recent impulse applied by this constraint.

To convert this to a force, divide by the timestep passed to Space#step. You can use this to implement breakable joints to check if the force they attempted to apply exceeded a certain threshold.

Source
max_bias

The maximum rate at which joint error is corrected.

(defaults to INFINITY)

Source
max_bias=(max_bias : Number)
Source
max_force

The maximum force that this constraint is allowed to use.

(defaults to INFINITY)

Source
max_force=(max_force : Number)
Source
post_solve(space : Space)

The post-solve method that is called before the solver runs (can be overridden in a subclass).

Source
pre_solve(space : Space)

The pre-solve method that is called before the solver runs (can be overridden in a subclass).

Source
space

Get the Space this constraint is added to.

Source

Nested types