Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

PhysicsCallbacks.IPreContinuousCallback.OnPreContinuous2D

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool OnPreContinuous2D(PreContinuousEvent preContinuousEvent);

Parameters

Parameter Description
preContinuousEvent The event that occurred.

Returns

bool Return false to let the shape continue through, or true to stop it at the predicted impact point.

Description

Called during the continuous collision stage when a fast-moving shape is predicted to hit another shape this step. No contact exists yet, as the shapes are not touching during the contact update, so this is the only place the pair is seen. Returning true stops the shape at the predicted impact point, and a contact then appears on the next step once the shapes are found touching.

This is only called for Awake Dynamic bodies and is never called for triggers.

Extreme care must be taken with this callback.

It occurs during the simulation step and can be called from any thread, so it must be thread-safe. During this time the simulation state is undefined for the broadphase, events and so on. Any attempt to perform a write operation on the world results in a deadlock, as the world itself is write locked. Simple read operations on PhysicsBody, PhysicsShape or PhysicsJoint are safe, such as reading velocity or getting the geometry of a shape, however more complex operations involving the world such as performing a query can result in corruption or crashes. Reading PhysicsUserData from any object is a completely safe read operation, so any required information should be encoded there if possible.