Version: 2020.3

Physics2D

class in UnityEngine

切换到手册

描述

用于 2D 物理的全局设置和 Helper 方法。

静态变量

AllLayers包括所有层的层遮罩常量。
alwaysShowCollidersEnable to always show the Collider Gizmos even when they are not selected.
angularSleepToleranceA Rigidbody cannot sleep if its angular velocity is above this tolerance threshold.
autoSyncTransformsSet whether to automatically sync changes to the Transform component with the physics engine.
baumgarteScale控制解析重叠速度的缩放因子。
baumgarteTOIScale控制解析 TOI 重叠速度的缩放因子。
callbacksOnDisable用于控制 Collider2D 处于禁用状态时是否应调用相应的 OnCollisionExit2D 或 OnTriggerExit2D 回调。
colliderAABBColorSet 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.
defaultPhysicsSceneUnity 启动时自动创建的 PhysicsScene2D。
DefaultRaycastLayers层遮罩常量,包括默认情况下参与射线投射的所有层。
gravity重力产生的加速度。
IgnoreRaycastLayer忽略射线投射的默认层的层遮罩常量。
jobOptions一组选项,用于控制在使用作业系统进行多线程物理模拟时物理系统的工作方式。
linearSleepTolerance如果刚体的线性速率高于该公差,将无法进入睡眠状态。
maxAngularCorrection解算约束时使用的最大角位置校正。这有助于防止过冲。
maxLinearCorrection解算约束时使用的最大线性位置校正。这有助于防止过冲。
maxRotationSpeed每次物理更新时,刚体的最大角速度。增大该值可能会导致数值问题。
maxTranslationSpeed每次物理更新时,刚体的最大线性速度。增大该值可能会导致数值问题。
positionIterations考虑对象位置时,物理解算器的迭代次数。
queriesHitTriggers射线投射是否检测配置为触发器的碰撞体?
queriesStartInCollidersSet the raycasts or linecasts that start inside Colliders to detect or not detect those Colliders.
reuseCollisionCallbacks确定垃圾回收器是否应仅对所有冲突回调重用一个 Collision2D 类型的实例。
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?
simulationModeControls when Unity executes the 2D physics simulation.
timeToSleep刚体进入睡眠状态前必须保持静止的时间(以秒为单位)。
velocityIterations考虑对象速度时,物理解算器的迭代次数。
velocityThreshold将相对线性速度低于该阈值的任何碰撞都视为非弹性碰撞。

静态函数

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. Note: This method will be deprecated in a future build and it is recommended to use BoxCast instead.
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. Note: This method will be deprecated in a future build and it is recommended to use CapsuleCast instead.
CircleCastCasts a circle against Colliders in the Scene, returning the first Collider to contact with it.
CircleCastAll向场景中的碰撞体投射圆形,返回与圆形接触的所有碰撞体。
CircleCastNonAllocCasts a circle into the Scene, returning Colliders that contact with it into the provided results array. Note: This method will be deprecated in a future build and it is recommended to use CircleCast instead.
ClosestPointReturns a point on the perimeter of the Collider that is closest to the specified position.
DistanceCalculates the minimum distance between two Colliders.
GetContactsRetrieves all Colliders in contact with the Collider.
GetIgnoreCollision检查碰撞检测系统是否忽略 collider1 与 collider2 之间的所有碰撞/触发器。
GetIgnoreLayerCollision检查是否忽略指定层之间的碰撞。
GetLayerCollisionMask获取碰撞层遮罩,指示指定层可以与哪些层发生碰撞。
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. Note: This method will be deprecated in a future build and it is recommended to use GetRayIntersection instead.
IgnoreCollision使碰撞检测系统忽略 collider1 与 collider2 之间的所有碰撞/触发器。
IgnoreLayerCollision选择检测还是忽略指定层对之间的碰撞。
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. Note: This method will be deprecated in a future build and it is recommended to use Linecast instead.
OverlapArea检查碰撞体是否位于一个矩形区域内。
OverlapAreaAllGet a list of all Colliders that fall within a rectangular area.
OverlapAreaNonAllocGet a list of all Colliders that fall within a specified area. Note: This method will be deprecated in a future build and it is recommended to use OverlapArea instead.
OverlapBox检查碰撞体是否在一个盒形区域内。
OverlapBoxAllGet a list of all Colliders that fall within a box area.
OverlapBoxNonAllocGet a list of all Colliders that fall within a box area. Note: This method will be deprecated in a future build and it is recommended to use OverlapBox instead.
OverlapCapsule检查碰撞体是否位于一个胶囊体区域内。
OverlapCapsuleAllGet a list of all Colliders that fall within a capsule area.
OverlapCapsuleNonAllocGet a list of all Colliders that fall within a capsule area. Note: This method will be deprecated in a future build and it is recommended to use OverlapCapsule instead.
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. Note: This method will be deprecated in a future build and it is recommended to use OverlapCircle instead.
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. Note: This method will be deprecated in a future build and it is recommended to use OverlapPoint instead.
Raycast向场景中的碰撞体投射射线。
RaycastAllCasts a ray against Colliders in the Scene, returning all Colliders that contact with it.
RaycastNonAllocCasts a ray into the Scene. Note: This method will be deprecated in a future build and it is recommended to use Raycast instead.
SetLayerCollisionMask设置碰撞层遮罩,指示指定层可以与哪些层发生碰撞。
Simulate在场景中进行物理模拟。
SyncTransforms同步。