Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PhysicsShapeDefinition

A PhysicsShape definition used to specify important initial properties.
Read time 3 minutesLast updated 9 days ago

Definition

  • Type: Struct
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule
public struct PhysicsShapeDefinition

Fields

Value

Description

contactFilterThe contact filter used to control which contacts this shape can participate in.
moverDataThe mover data used for the shape mover.
surfaceMaterialThe surface material for the shape comprising of many properties such as friction, bounciness, rolling resistance etc.

Constructors

Constructor

Description

PhysicsShapeDefinition()Create a default PhysicsShape definition.
PhysicsShapeDefinition(System.Boolean)Create a default PhysicsShape definition.

Properties

Property

Description

contactEventsControls whether this shape produces contact events which can be retrieved after the simulation has completed. This only applies to kinematic and dynamic bodies. A contact event is produced if either shapes involved have their contactEvents enabled. Changing this at run-time may lead to lost begin/end events.
contactFilterCallbacksControls whether this shape produces contact filter callbacks. A contact filter callback allows direct control over whether a contact will be created between a pair of shapes. This applies to both triggers and non-triggers but only with to Dynamic bodies These are relatively expensive so disabling them can provide a significant performance benefit. A contact filter callback will call the _callbackTarget for both shapes involved if they implement PhysicsCallbacks.IContactFilterCallback.
densityThe density, usually in kg/m^2, defaults to 1. This is not part of the surface material because this is for the interior of the shape, which may have other considerations, such as being hollow.
hitEventsControls whether this shape produces hit events which can be retrieved after the simulation has completed. This only applies to kinematic and dynamic bodies. This is ignored for triggers.
isTriggerEnable/Disable being a trigger shape. A trigger shape generates overlap events but never generates a collision response. Triggers do not collide with other triggers and do not have continuous collision, instead, use a ray or shape cast for those scenarios. Triggers still contribute to the body mass if they have non-zero density. The default is false.
preSolveCallbacksControls whether this shape produces pre-solve callbacks. This only applies to Dynamic bodies and is ignored for triggers. These are relatively expensive so disabling them can provide a significant performance benefit. A pre-solve callback will call the _callbackTarget for both shapes involved if they implement PhysicsCallbacks.IPreSolveCallback.
startMassUpdateShould the body update its mass properties when this shape is created. Disabling this improves performance when multiple shapes are being added to the same body. The mass of a body can then be explicitly updated by calling PhysicsBody.ApplyMassFromShapes
startStaticContactsNormally shapes on Static bodies don't create contacts when they are added to the world. This overrides that behavior and causes contact creation. This significantly slows down Static body creation which can be important when there are many Static shapes. This is implicitly always true for Triggers, Dynamic bodies and Kinematic bodies.
triggerEventsControls whether this shape produces trigger events which can be retrieved after the simulation has completed. A trigger event is only produced if both shapes involved have their triggerEvents enabled. This applies to triggers and non-triggers alike.
worldDrawingControls whether this shape is automatically drawn when the world is drawn.

Static Properties

Property

Description

defaultDefinitionGet a default PhysicsShape definition.