setLayers
Puts particle on layers and has it collide with what is on a layer of mask and holds a layer of particle's in its own mask; see PhysicsLayers. The layers say nothing about the solids: see setSolidCollision. For a soft body's particles, set the whole body's with SoftBodies.setLayers.
Samples
val world = PhysicsWorld()
val player = CollisionLayers.of(0)
val enemy = CollisionLayers.of(1)
val grain = world.particles.add(x = 0f, y = 0f, radius = 2f, bodyCollision = BodyCollision.COLLIDE)
// On the enemy layer, colliding with the player only.
world.particles.setLayers(grain, layers = enemy, mask = player)
assertPrints(world.particles.layersOf(grain) == enemy, "true")
assertPrints(world.particles.maskOf(grain) == player, "true")Content copied to clipboard