chain

fun PhysicsWorld.chain(fromX: Float, fromY: Float, toX: Float, toY: Float, segments: Int, mass: Float = 2.0f, compliance: Float = 0.0f, bendCompliance: Float = 1.0E-5f, pinned: PinnedEnds = PinnedEnds.START, tearAt: Float = 0.0f, radius: Float = 2.0f, bodyCollision: BodyCollision = BodyCollision.PASS, material: Material = Material.DEFAULT): Strand(source)

Adds a chain from (fromX, fromY) to (toX, toY), cut into segments links, and returns it: like rope, but its links are rigid rods that push as well as pull, its particles are heavier and round, and it bends a little, so a chain hangs in a smoother curve and does not bunch up.

Throws

Samples

val world = PhysicsWorld()
val chain = world.chain(fromX = 0f, fromY = 0f, toX = 0f, toY = 60f, segments = 6)
assertPrints(chain.bends.size, "5")