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 4 minutesLast updated 14 days ago

Definition

public readonly struct PhysicsEvents : IEquatable<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 _renderingMode or if _alwaysDrawWorlds is true.
WorldTransformPlaneChangeEvent callback for a world transform-plane change event. This only fires when the mapping between 2D physics space and 3D world space actually changes. A world using PhysicsWorld.TransformPlane.Custom also fires this when _transformPlaneCustom changes, reporting PhysicsWorld.TransformPlane.Custom as both the old and the new plane.

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 _isValid. See _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 _isValid. See _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 _contactHitEventThreshold.
PhysicsEvents.JointThresholdEventAn event produced by a Joint which exceeds either its _forceThreshold or _torqueThreshold.
PhysicsEvents.PreContactEventAn event produced when a contact between a pair of shapes is updated, giving the opportunity to modify the contact manifold before it is solved. The event is passed to the callback by reference so the manifold can be changed, and calling Cancel cancels the contact.
PhysicsEvents.PreContinuousEventAn event produced during the continuous collision stage when a fast-moving shape is predicted to hit another shape this step. The callback decides whether the shape is stopped at the predicted impact point or allowed to continue.
PhysicsEvents.TransformChangeEventAn event produced after registering via PhysicsWorld.RegisterTransformChange.
PhysicsEvents.TransformTweenWriteEventAn event produced and sent to the callback target set with _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 _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 _isValid. See _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 _isValid. See _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 _renderingMode or if _alwaysDrawWorlds is true.
PhysicsEvents.WorldTransformPlaneChangeEventHandlerEvent handler for a world transform-plane change event callback.