Physics2D

class in UnityEngine

Switch to Manual

Description

Global settings and helpers for 2D physics.

Static Variables

AllLayersМаска слоя, которая включает в себя все слои.
alwaysShowCollidersShould the collider gizmos always be shown even when they are not selected?
angularSleepToleranceA rigid-body cannot sleep if its angular velocity is above this tolerance.
autoSimulationSets whether the physics should be simulated automatically or not.
autoSyncTransformsWhether or not to automatically sync transform changes with the physics system whenever a Transform component changes.
baumgarteScaleThe scale factor that controls how fast overlaps are resolved.
baumgarteTOIScaleThe scale factor that controls how fast TOI overlaps are resolved.
callbacksOnDisableUse this to control whether or not the appropriate OnCollisionExit2D or OnTriggerExit2D callbacks should be called when a Collider2D is disabled.
colliderAABBColorSets the color used by the gizmos to show all Collider axis-aligned bounding boxes (AABBs).
colliderAsleepColorThe color used by the gizmos to show all asleep colliders (collider is asleep when the body is asleep).
colliderAwakeColorThe color used by the gizmos to show all awake colliders (collider is awake when the body is awake).
colliderContactColorThe color used by the gizmos to show all collider contacts.
contactArrowScaleThe scale of the contact arrow used by the collider gizmos.
defaultContactOffsetThe default contact offset of the newly created colliders.
defaultPhysicsSceneThe PhysicsScene2D automatically created when Unity starts.
DefaultRaycastLayersLayer mask constant that includes all layers participating in raycasts by default.
gravityAcceleration due to gravity.
IgnoreRaycastLayerLayer mask constant for the default layer that ignores raycasts.
jobOptionsA set of options that control how physics operates when using the job system to multithread the physics simulation.
linearSleepToleranceA rigid-body cannot sleep if its linear velocity is above this tolerance.
maxAngularCorrectionThe maximum angular position correction used when solving constraints. This helps to prevent overshoot.
maxLinearCorrectionThe maximum linear position correction used when solving constraints. This helps to prevent overshoot.
maxRotationSpeedThe maximum angular speed of a rigid-body per physics update. Increasing this can cause numerical problems.
maxTranslationSpeedThe maximum linear speed of a rigid-body per physics update. Increasing this can cause numerical problems.
positionIterationsThe number of iterations of the physics solver when considering objects' positions.
queriesHitTriggersDo raycasts detect Colliders configured as triggers?
queriesStartInCollidersSets the raycasts or linecasts that start inside Colliders to detect or not detect those Colliders.
showColliderAABBShould the collider gizmos show the AABBs for each collider?
showColliderContactsShould the collider gizmos show current contacts for each collider?
showColliderSleepShould the collider gizmos show the sleep-state for each collider?
timeToSleepThe time in seconds that a rigid-body must be still before it will go to sleep.
velocityIterationsThe number of iterations of the physics solver when considering objects' velocities.
velocityThresholdAny collisions with a relative linear velocity below this threshold will be treated as inelastic.

Static Functions

BoxCastCasts a box against colliders in the Scene, returning the first collider to contact with it.
BoxCastAllCasts a box against colliders in the Scene, returning all colliders that contact with it.
BoxCastNonAllocCasts a box into the Scene, returning colliders that contact with it into the provided results array.
CapsuleCastCasts a capsule against colliders in the Scene, returning the first collider to contact with it.
CapsuleCastAllCasts a capsule against colliders in the Scene, returning all colliders that contact with it.
CapsuleCastNonAllocCasts a capsule into the Scene, returning colliders that contact with it into the provided results array.
CircleCastCasts a circle against colliders in the Scene, returning the first collider to contact with it.
CircleCastAllCasts a circle against colliders in the Scene, returning all colliders that contact with it.
CircleCastNonAllocCasts a circle into the Scene, returning colliders that contact with it into the provided results array.
DistanceCalculates the minimum distance between two colliders.
GetContactsRetrieves all colliders in contact with the collider.
GetIgnoreCollisionChecks whether the collision detection system will ignore all collisions/triggers between collider1 and collider2 or not.
GetIgnoreLayerCollisionChecks whether collisions between the specified layers be ignored or not.
GetLayerCollisionMaskGet the collision layer mask that indicates which layer(s) the specified layer can collide with.
GetRayIntersectionCast a 3D ray against the colliders in the Scene returning the first collider along the ray.
GetRayIntersectionAllCast a 3D ray against the colliders in the Scene returning all the colliders along the ray.
GetRayIntersectionNonAllocCast a 3D ray against the colliders in the Scene returning the colliders along the ray.
IgnoreCollisionMakes the collision detection system ignore all collisions/triggers between collider1 and collider2.
IgnoreLayerCollisionChoose whether to detect or ignore collisions between a specified pair of layers.
IsTouchingChecks whether the passed colliders are in contact or not.
IsTouchingLayersChecks whether the collider is touching any colliders on the specified layerMask or not.
LinecastCasts a line segment against colliders in the Scene.
LinecastAllCasts a line against colliders in the Scene.
LinecastNonAllocCasts a line against colliders in the Scene.
OverlapAreaChecks if a collider falls within a rectangular area.
OverlapAreaAllGet a list of all colliders that fall within a rectangular area.
OverlapAreaNonAllocGet a list of all colliders that fall within a specified area.
OverlapBoxChecks if a collider falls within a box area.
OverlapBoxAllGet a list of all colliders that fall within a box area.
OverlapBoxNonAllocGet a list of all colliders that fall within a box area.
OverlapCapsuleChecks if a collider falls within a capsule area.
OverlapCapsuleAllGet a list of all colliders that fall within a capsule area.
OverlapCapsuleNonAllocGet a list of all colliders that fall within a capsule area.
OverlapCircleChecks if a collider falls within a circular area.
OverlapCircleAllGet a list of all colliders that fall within a circular area.
OverlapCircleNonAllocGet a list of all colliders that fall within a circular area.
OverlapColliderGets a list of all Colliders that overlap the given collider.
OverlapPointChecks if a collider overlaps a point in space.
OverlapPointAllGet a list of all colliders that overlap a point in space.
OverlapPointNonAllocGet a list of all colliders that overlap a point in space.
RaycastCasts a ray against colliders in the Scene.
RaycastAllCasts a ray against colliders in the Scene, returning all colliders that contact with it.
RaycastNonAllocCasts a ray into the Scene.
SetLayerCollisionMaskSet the collision layer mask that indicates which layer(s) the specified layer can collide with.
SimulateSimulate physics in the Scene.
SyncTransformsSynchronizes.