setLimits

fun setLimits(joint: Joint, lower: Float, upper: Float)(source)

Keeps hinge joint's angle (how far its second end has turned against its first since it was made, in radians), or slider joint's position (how far its second end has slid along the axis, in units), from lower to upper.

Throws

if joint is not a hinge or a slider, or lower is above upper.

Samples

val world = PhysicsWorld()
val door = world.rigidBody(Shape.box(40f, 4f), x = 20f, y = 0f)
val hinge = world.joints.hinge(door, JointEnd.WORLD, x = 0f, y = 0f)
// It may turn at most a quarter turn down.
world.joints.setLimits(hinge, lower = 0f, upper = (PI / 4).toFloat())
repeat(120) { world.step(1.seconds / 60) }
assertTrue(world.joints.angleOf(hinge) <= (PI / 4).toFloat() + 0.02f)