What analytics can you get from planck.js PostSolve?

The PostSolve event in planck.js provides crucial physics simulation data immediately after collision impulses are calculated and applied. By tapping into this event, developers can gather precise analytics on collision forces, friction impulses, and contact points between rigid bodies. This data is essential for implementing gameplay mechanics like dynamic damage systems, sound triggering based on impact severity, and game state analytics.

Understanding the PostSolve Event

In planck.js (a 2D JavaScript physics engine based on Box2D), the physics step goes through several phases. The PostSolve event fires after the solver has finished determining how to resolve a collision. Unlike the PreSolve event, which lets you disable contacts before they happen, PostSolve is strictly for reading the exact physical outcomes of an interaction.

Key Data and Analytics Available

When you subscribe to the PostSolve event, the engine passes a Contact object and a ContactImpulse object to your listener. From these, you can extract several key metrics:

Common Use Cases for PostSolve Data