Struct WorldEvents
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
The events raised during the most recent step.
public readonly ref struct WorldEventsInherited Members
Examples
world.Step(1.0f / 60.0f);
foreach (var hit in world.Events.ContactHits)
{
PlayImpactSound(hit.Point, volume: hit.ApproachSpeed / 20.0f);
}
foreach (var moved in world.Events.BodyMoves)
{
transforms[moved.Body].Set(moved.Position, moved.Rotation);
}
Remarks
Every collection here is a view over engine memory rather than a copy, so reading them allocates nothing. They stay valid only until the next Box3D.PhysicsWorld.Step(System.Single,System.Int32).
It is safe to create and destroy bodies while walking these, which is the whole reason Box3D buffers events instead of calling back mid-step. Be aware that doing so can invalidate handles carried by events you have not read yet.
Properties
- BodyMoves
-
Gets the bodies the simulation moved.
- ContactBegins
-
Gets the pairs of shapes that started touching.
- ContactEnds
-
Gets the pairs of shapes that stopped touching.
- ContactHits
-
Gets the collisions fast enough to raise a hit event.
- SensorBegins
-
Gets the shapes that entered a sensor.
- SensorEnds
-
Gets the shapes that left a sensor.