Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PhysicsEvents

Various events that can be retrieved during and after the simulation has completed. See PhysicsWorld.Simulate and PhysicsWorld.Simulate.
Read time 3 minutesLast updated 14 days ago

Definition

  • Type: Struct
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule
public readonly struct PhysicsEvents

Static Events

Member

Description

PostSimulateEvent callback for a post-simulate event. This is called after the simulation has finished running and is always called on the main-thread. See PhysicsEvents.PostSimulateEventHandler.
PreSimulateEvent callback for a pre-simulate event. This is called prior to the simulation running and is always called on the main-thread. See PhysicsEvents.PreSimulateEventHandler.
WorldDefinitionChangeEvent callback for a world definition change event.
WorldDrawResultsEvent callback for a world draw results event. This is only called if the world is currently rendering as specified by PhysicsWorld.renderingMode or if PhysicsCoreSettings2D.alwaysDrawWorlds is true.

Structs

Struct

Description

PhysicsEvents.BodyUpdateEventAn event produced by a PhysicsBody that indicates the simulation changed the body in one of the following ways:
PhysicsEvents.ContactBeginEventAn event produced by a pair of Shapes, neither of which are a trigger, began touching. The shapes provided may have been destroyed so they should always be validated with PhysicsShape.isValid. See PhysicsWorld.contactBeginEvents.
PhysicsEvents.ContactEndEventAn event produced by a pair of Shapes, neither of which are a trigger, stopped touching. You will get an end event if you do anything that destroys contacts prior to the last world simulation step which include things like setting the body transform, destroying a body etc. The shapes provided may have been destroyed so they should always be validated with PhysicsShape.isValid. See PhysicsWorld.contactEndEvents.
PhysicsEvents.ContactFilterEventAn event produced when a pair of PhysicsShape come into contact. This can be used to decide if a contact between the two shapes should be created or not.
PhysicsEvents.ContactHitEventAn event produced when a pair of PhysicsShape come into contact at relative speed exceeding the PhysicsWorld.contactHitEventThreshold.
PhysicsEvents.JointThresholdEventAn event produced by a Joint which exceeds either its PhysicsJoint.forceThreshold or PhysicsJoint.torqueThreshold.
PhysicsEvents.PreSolveEventAn event produced when a contact between a pair of PhysicsShape is updated, used to provide the ability to decide if the contact should be disabled or not.
PhysicsEvents.TransformChangeEventAn event produced after registering via PhysicsWorld.RegisterTransformChange.
PhysicsEvents.TransformTweenWriteEventAn event produced and sent to the callback target set with PhysicsWorld.transformWriteCallbackTarget which must implement PhysicsCallbacks.ITransformWriteCallback which will have PhysicsCallbacks.ITransformWriteCallback.OnTransformTweenWrite called allowing custom transform writing.
PhysicsEvents.TransformWriteEventAn event produced and sent to the callback target set with PhysicsWorld.transformWriteCallbackTarget which must implement PhysicsCallbacks.ITransformWriteCallback which will have PhysicsCallbacks.ITransformWriteCallback.OnTransformWrite called allowing custom transform writing.
PhysicsEvents.TriggerBeginEventAn event produced when a pair of Shapes, one of which was a trigger, began touching. The shapes provided may have been destroyed so they should always be validated with PhysicsShape.isValid. See PhysicsWorld.triggerBeginEvents.
PhysicsEvents.TriggerEndEventAn event produced when a pair of Shapes, one of which was a trigger, stopped touching. An end event will be produced anything that destroys contacts happens, prior to the last world simulation step, which include things like setting the body transform, destroying a body or shape or changing a contact filter etc. The shapes provided may have been destroyed so they should always be validated with PhysicsShape.isValid. See PhysicsWorld.triggerEndEvents.

Delegates

Delegate

Description

PhysicsEvents.PostSimulateEventHandlerEvent handler for a post-simulate event callback. This is called after the simulation has finished running and is always called on the main-thread. See PhysicsWorld and PhysicsEvents.PostSimulate.
PhysicsEvents.PreSimulateEventHandlerEvent handler for a pre-simulate event callback. This is called prior to the simulation running and is always called on the main-thread. See PhysicsWorld and PhysicsEvents.PreSimulate.
PhysicsEvents.WorldDefinitionChangeEventHandlerEvent handler for a world definition change event callback.
PhysicsEvents.WorldDrawResultsEventHandlerEvent handler for a world draw results event callback. This is only called if the world is currently rendering as specified by PhysicsWorld.renderingMode or if PhysicsCoreSettings2D.alwaysDrawWorlds is true.