Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


drawDepth

The depth this body is drawn at, in world space, along the axis perpendicular to the world's transform plane.
Read time 1 minuteLast updated 20 hours ago

Definition

  • Type: Property
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule
public float drawDepth { get; set; }

Remarks

Bodies are drawn in two dimensions, so the depth is what places a body in front of or behind other things in the scene. The depth axis is Z for PhysicsWorld.TransformPlane.XY, Y for PhysicsWorld.TransformPlane.XZ and X for PhysicsWorld.TransformPlane.ZY. The depth is only used when the body has no PhysicsBody.transformObject. A body with a transform object is always drawn at the depth of that transform. Everything drawn for the body, such as its shapes and its transform axis, uses this depth. A joint is drawn at the depth of its first body, PhysicsJoint.bodyA. A value that is not finite is rejected and leaves the depth unchanged. The depth only changes how the body is drawn and never affects the simulation. See PhysicsBodyDefinition.drawDepth. To set the depth for custom drawing that is not tied to a body, use PhysicsWorld.drawDepth.