Events
What happened in the last PhysicsWorld.step.
Touches. contactsBegun and contactsEnded list the things that started and stopped touching: rigid bodies, soft bodies and the solids, in any pair. Loose particles get none, as sand would flood them: they have the readouts below. A touch begins in the step two things first push on each other, or come within TOUCH_SLOP, and ends in the first step they don't, so each comes once, however many substeps and points it has. Two bodies asleep against each other stay touching, and a body that's removed ends its touches in the next step.
Sensors. sensorsEntered and sensorsExited list what came into and went out of a sensor (see RigidBodies.setResponse): rigid bodies, soft bodies and loose particles. The sensor is always Touch.a.
Joints. brokenJointCount and brokenJointAt list the joints that broke.
Particles on floors. Which particles stood on a floor, and the Solid.tags of those floors. It keeps this step and the one before apart, because "can I jump?" asks about before you left the ground. A floor is any solid that pushed the particle up: a surface flatter than 60 degrees. Walls and ceilings push too, but aren't floors and report no tags.
toString gives how many touches of each kind the last step reported, for example Events(contactsBegun=2, contactsEnded=0, sensorsEntered=1, sensorsExited=0, brokenJoints=0).
Samples
val world = PhysicsWorld()
val ground = world.rigidBody(Shape.box(200f, 10f), x = 0f, y = 30f, kind = BodyKind.STATIC)
val ball = world.rigidBody(Shape.circle(5f), x = 0f, y = 0f)
var landed = false
repeat(60) {
world.step(1.seconds / 60)
if (world.events.contactsBegun.has(TouchSide.of(ball), TouchSide.of(ground))) landed = true
}
assertPrints(landed, "true")Properties
Number of joints that broke in the last step.
Things that started touching in the last step.
Things that stopped touching in the last step.
Things that came into a sensor in the last step: the sensor is each one's Touch.a.
Things that left a sensor, or were removed while in it, in the last step.
Functions
Returns the joint at index of those that broke in the last step. It has been removed, so its slot may be handed out again.
Returns the unit normal of particle's last contact, across, pointing away from what it touched: (0, -1) on a flat floor. It means something only while isTouching.
Returns the unit normal of particle's last contact, down: see contactNormalXOf.
Returns the tags of every floor particle stood on during the last step, together; SolidTags.NONE for none.
Returns true if particle was pushed out of anything during the last step: a solid, a body or another particle, floor or not.
Returns the particle particle last touched, or the first particle of the edge it touched, or null when it last touched a solid or a rigid body.
Returns true if particle stood on a floor during the step before the last, for coyote time.