Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

PhysicsCallbacks.IPreSolveCallback.OnPreSolve2D

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 OnPreSolve2D(LowLevelPhysics2D.PhysicsEvents.PreSolveEvent preSolveEvent);

Parameters

Parameter Description
preSolveEvent The event that occurred.

Returns

bool Return false if you want to disable the contact this simulation step. Returning true allows the contact.

Description

Called when a contact between a pair of shapes is updated. This allows a contact to be disabled before it goes to the solver. A typical use-case would be to implement a one-way behaviour. This is only called if the PhysicsWorld has PhysicsWorld.preSolveCallbacks set to true. An event is only produced if one of the PhysicsShape have PhysicsShape.preSolveCallbacks set to true. This is only called for Awake Dynamic bodies. This is not called for triggers.

This callback occurs during the simulation and must be thread-safe as it can be called from any thread therefore extreme care must be taken. Do not perform any write-operations during this callback for any PhysicsWorld, PhysicsBody, PhysicsShape or PhysicsJoint. A write operation would include setting any property or creating objects. Any attempt to perform a write operation may result in a crash, deadlock or hard to detect corruption. In most cases, performing a read operation is safe and should be limited to simple state read operations such as reading velocities etc.