menu_bookDocumentation
IScenePhysicsEvents: Pre and Post Physics Step Hooks
IScenePhysicsEvents lets Components or GameObjectSystems wrap logic around the physics step. Implement it when you have systems that work closely with physics and need to run code immediately before or after the physics simulation.
Interface Definition
CSHARP
public interface IScenePhysicsEvents : ISceneEvent<IScenePhysicsEvents>
{
void PrePhysicsStep() { }
void PostPhysicsStep() { }
}Usage
Implement on any Component:
CSHARP
public sealed class PhysicsDebugger : Component, IScenePhysicsEvents
{
void IScenePhysicsEvents.PrePhysicsStep()
{
// Called right after FixedUpdate, before physics simulation runs
// Good for: applying forces, setting velocities, preparing constraints
}
void IScenePhysicsEvents.PostPhysicsStep()
{
// Called after physics simulation completes
// Good for: reading final positions, checking contacts, applying corrections
}
}Timing
- PrePhysicsStep runs right after OnFixedUpdate, before the physics engine steps
- PostPhysicsStep runs after the physics engine has completed its step
Was this helpful?