Version: 2023.2

Physics2D

class in UnityEngine

切换到手册

描述

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

静态变量

AllLayers包括所有层的层遮罩常量。
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 重叠速度的缩放因子。
bounceThresholdAny collisions with a relative linear velocity below this threshold will be treated as inelastic so no bounce will occur.
callbacksOnDisable用于控制 Collider2D 处于禁用状态时是否应调用相应的 OnCollisionExit2D 或 OnTriggerExit2D 回调。
defaultContactOffsetThe default contact offset of the newly created Colliders.
defaultPhysicsSceneUnity 启动时自动创建的 PhysicsScene2D。
DefaultRaycastLayers层遮罩常量,包括默认情况下参与射线投射的所有层。
gravity重力产生的加速度。
IgnoreRaycastLayer忽略射线投射的默认层的层遮罩常量。
jobOptions一组选项,用于控制在使用作业系统进行多线程物理模拟时物理系统的工作方式。
linearSleepTolerance如果刚体的线性速率高于该公差,将无法进入睡眠状态。
maxAngularCorrection解算约束时使用的最大角位置校正。这有助于防止过冲。
maxLinearCorrection解算约束时使用的最大线性位置校正。这有助于防止过冲。
MaxPolygonShapeVerticesThe maximum number of vertices allowed per primitive polygon shape type (PhysicsShapeType2D.Polygon). (Read Only)
maxRotationSpeed每次物理更新时,刚体的最大角速度。增大该值可能会导致数值问题。
maxSubStepCountThe maximum number of simulation sub-steps allowed per-frame when simulation sub-stepping is enabled.
maxTranslationSpeed每次物理更新时,刚体的最大线性速度。增大该值可能会导致数值问题。
minSubStepFPSThe minimum FPS allowed for a simulation step before sub-stepping will be used.
positionIterations考虑对象位置时,物理解算器的迭代次数。
queriesHitTriggers射线投射是否检测配置为触发器的碰撞体?
queriesStartInCollidersSet the raycasts or linecasts that start inside Colliders to detect or not detect those Colliders.
reuseCollisionCallbacks确定垃圾回收器是否应仅对所有冲突回调重用一个 Collision2D 类型的实例。
simulationLayersThe Rigidbody2D and Collider2D layers to simulate.
simulationModeControls when Unity executes the 2D physics simulation.
timeToSleep刚体进入睡眠状态前必须保持静止的时间(以秒为单位)。
useSubStepContactsWhether to calculate contacts for all simulation sub-steps or only the first sub-step.
useSubSteppingWhether to use simulation sub-stepping during a simulation step.
velocityIterations考虑对象速度时,物理解算器的迭代次数。

静态函数

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.
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.
CircleCastCasts a circle against Colliders in the Scene, returning the first Collider to contact with it.
CircleCastAll向场景中的碰撞体投射圆形,返回与圆形接触的所有碰撞体。
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 2D Colliders in the Scene.
GetRayIntersectionAllCast a 3D ray against the 2D Colliders in the Scene.
GetRayIntersectionNonAllocCast a 3D ray against the 2D Colliders in the Scene.
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.
OverlapArea检查碰撞体是否位于一个矩形区域内。
OverlapAreaAllGet a list of all Colliders that fall within a rectangular area.
OverlapBox检查碰撞体是否在一个盒形区域内。
OverlapBoxAllGet a list of all Colliders that fall within a box area.
OverlapCapsule检查碰撞体是否位于一个胶囊体区域内。
OverlapCapsuleAllGet 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.
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.
Raycast向场景中的碰撞体投射射线。
RaycastAllCasts a ray against Colliders in the Scene, returning all Colliders that contact with it.
SetLayerCollisionMask设置碰撞层遮罩,指示指定层可以与哪些层发生碰撞。
SimulateSimulate physics in the default physics scene.
SyncTransforms同步。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961