weld
fun weld(a: RigidBody, b: JointEnd, x: Float, y: Float, compliance: Float = 0.0f, breakForce: Float = Float.POSITIVE_INFINITY): Joint(source)
Holds a and b together at the world point (x, y), and at the angle they have now, as softly as compliance, and returns the joint's handle. Pulled harder than breakForce, it breaks: it is removed, and Events.brokenJointAt reports it.
Throws
if an end is gone, b is a, compliance is negative, or breakForce is not more than 0.
Samples
val world = PhysicsWorld()
world.rigidBody(Shape.box(200f, 10f), x = 0f, y = 100f, kind = BodyKind.STATIC)
val left = world.rigidBody(Shape.box(20f, 20f), x = -10f, y = 0f)
val right = world.rigidBody(Shape.box(20f, 20f), x = 10f, y = 0f)
// The two crates are one from now on, unless pulled harder than breakForce.
world.joints.weld(left, right, x = 0f, y = 0f, breakForce = 1e9f)
repeat(60) { world.step(1.seconds / 60) }
val gap = world.rigidBodies.xOf(right) - world.rigidBodies.xOf(left)
assertTrue(gap in 19.9f..20.1f)Content copied to clipboard