Skip to content

Constraints

abstract class CP::Constraint
inherits Reference #

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.

Direct known subclasses

CP::Constraint::DampedRotarySpring CP::Constraint::DampedSpring CP::Constraint::GearJoint CP::Constraint::GrooveJoint CP::Constraint::PinJoint CP::Constraint::PivotJoint CP::Constraint::RatchetJoint CP::Constraint::RotaryLimitJoint CP::Constraint::SimpleMotor CP::Constraint::SlideJoint

Methods#

#bodies : ::Tuple(Body, Body)#

Get the bodies the constraint is attached to.

View source

#body_a : Body#

Get the first body the constraint is attached to.

View source

#body_b : Body#

Get the second body the constraint is attached to.

View source

#collide_bodies=(collide_bodies : Bool)#

View source

#collide_bodies? : Bool#

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

(defaults to false)

View source

#error_bias : Float64#

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.

View source

#error_bias=(error_bias : Number)#

View source

#impulse : Float64#

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.

View source

#max_bias : Float64#

The maximum rate at which joint error is corrected.

(defaults to INFINITY)

View source

#max_bias=(max_bias : Number)#

View source

#max_force : Float64#

The maximum force that this constraint is allowed to use.

(defaults to INFINITY)

View source

#max_force=(max_force : Number)#

View source

#post_solve(space : Space)#

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

View source

#pre_solve(space : Space)#

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

View source

#space : Space | ::Nil#

Get the Space this constraint is added to.

View source