Version: Unity 6 Preview (6000.0)
LanguageEnglish
  • C#

Collider2D.localToWorldMatrix

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

public Matrix4x4 localToWorldMatrix;

Description

The transformation matrix used to transform the Collider physics shapes to world space.

The Collider2D creates PhysicsShape2D in the space of any attached Rigidbody2D. The transformation matrix returned here transforms these shapes from the Rigidbody2D's local space to world space.

If the Collider2D is not attached to a Rigidbody2D then Matrix4x4.identity is returned because the Collider2D is Static and the subsequently created PhysicsShape2D will already be in world space.

Additional resources: Rigidbody2D.localToWorldMatrix and Matrix4x4.