setSolidCollision
Sets whether body is kept out of the solids, the SolidGrid and its moving solids. It is SolidCollision.COLLIDE by default; a SolidCollision.PASS body falls through the level. A body set back to SolidCollision.COLLIDE while a little way into a solid is pushed out; one sunk most of the way in stays there. A change wakes it; setting the value it already has does nothing.
Samples
val world = PhysicsWorld()
// A floor of 16-unit tiles along row 9, its top at y = 144.
val grid = SolidGrid(columns = 20, rows = 10, tileSize = 16f)
for (column in 0 until 20) grid.fill(column, 9)
world.solids = grid
val ghost = world.rigidBody(Shape.box(20f, 20f), x = 160f, y = 100f)
world.rigidBodies.setSolidCollision(ghost, SolidCollision.PASS)
assertPrints(world.rigidBodies.solidCollisionOf(ghost), "PASS")
repeat(60) { world.step(1.seconds / 60) }
// It fell through the floor.
assertTrue(world.rigidBodies.yOf(ghost) > 160f)Content copied to clipboard