文档

Unity Engine

Unity Engine

UnityEngine.Physics2DModule

The Physics2d module implements 2D physics in Unity.
阅读时间9 分钟最后更新于 1 小时前

Definition

  • Type: Module

Classes

Class

Description

AnchoredJoint2DParent class for all joints that have anchor points.
AreaEffector2DApplies forces within an area.
BoxCollider2DCollider for 2D physics representing an axis-aligned rectangle.
BuoyancyEffector2DApplies forces to simulate buoyancy, fluid-flow and fluid damping.
CapsuleCollider2DA capsule-shaped primitive collider.
CircleCollider2DCollider for 2D physics representing an circle.
Collider2DThe parent class for collider types used with 2D gameplay. Provides methods to defines the shape and physical behavior for 2D object interactions, used to detect collisions, and trigger events in 2D game environments.
Collision2DCollision details returned by 2D physics callback functions.
CompositeCollider2DA Collider that can merge other Colliders together.
ConstantForce2DApplies both linear and angular (torque) forces continuously to the rigidbody each physics update.
CustomCollider2DRepresents a Collider2D that is configured by assigning PhysicsShape2D geometry to it via a PhysicsShapeGroup2D.
DistanceJoint2DJoint that keeps two Rigidbody2D objects a fixed distance apart.
EdgeCollider2DCollider for 2D physics representing an arbitrary set of connected edges (lines) defined by its vertices.
Effector2DA base class for all 2D effectors.
FixedJoint2DConnects two Rigidbody2D together at their anchor points using a configurable spring.
FrictionJoint2DApplies both force and torque to reduce both the linear and angular velocities to zero.
HingeJoint2DJoint that allows a Rigidbody2D object to rotate around a point in space or a point on another object.
Joint2DParent class for joints to connect Rigidbody2D objects.
Physics2DProvides utilities and global settings to manage and simulate 2D physics interactions, such as collision detection and raycasting.
PhysicsLowLevelSettings2DPhysics LowLevel Settings Asset. This contains all the global physics options along with the default values for the following definitions:
PhysicsMaterial2DAsset type that defines the surface properties of a Collider2D.
PhysicsSceneExtensions2DScene extensions to access the underlying physics scene.
PhysicsShapeGroup2DRepresents a group of PhysicsShape2D and their geometry.
PhysicsUpdateBehaviour2DA base type for 2D physics components that required a callback during FixedUpdate.
PlatformEffector2DApplies "platform" behaviour such as one-way collisions etc.
PointEffector2DApplies forces to attract/repulse against a point.
PolygonCollider2DCollider for 2D physics representing an arbitrary polygon defined by its vertices.
RelativeJoint2DKeeps two Rigidbody2D at their relative orientations.
Rigidbody2DProvides physics movement and other dynamics, and the ability to attach Collider2D to it.
SliderJoint2DJoint that restricts the motion of a Rigidbody2D object to a single line.
SpringJoint2DJoint that attempts to keep two Rigidbody2D objects a set distance apart by applying a force between them.
SurfaceEffector2DApplies tangent forces along the surfaces of colliders.
TargetJoint2DThe joint attempts to move a Rigidbody2D to a specific target position.
WheelJoint2DThe wheel joint allows the simulation of wheels by providing a constraining suspension motion with an optional motor.

Structs

Struct

Description

CapsuleGeometryThe geometry of a closed capsule which can be viewed as two semi-circles connected by a rectangle. See PhysicsBody.CreateShape.
ChainGeometryThe geometry of a chain of ChainSegment.
ChainSegmentGeometryThe geometry of a chain line segment with one-sided collision which only collides on the "right" side. Several of these are generated for a chain, connected as ghost1 -> point1 -> point2 -> ghost2.
CircleGeometryThe geometry of a closed circle. See PhysicsBody.CreateShape.
ColliderDistance2DRepresents the separation or overlap of two Collider2D.
ContactFilter2DA set of parameters for filtering contact results. Define the angle by referring to their position in world space, where 0 degrees is parallel to the positive x-axis, 90 degrees is parallel to the positive y-axis, 180 degrees is parallel to the negative x-axis, and 270 degrees is parallel to the negative y-axis.
ContactPoint2DDetails about a specific point of contact involved in a 2D physics collision.
JointAngleLimits2DAngular limits on the rotation of a Rigidbody2D object around a HingeJoint2D.
JointMotor2DParameters for the optional motor force applied to a Joint2D.
JointSuspension2DJoint suspension is used to define how suspension works on a WheelJoint2D.
JointTranslationLimits2DMotion limits of a Rigidbody2D object along a SliderJoint2D.
PhysicsAABBRepresents a 2D axis-aligned bounding-box.
PhysicsBodyA body is contained within a world and has 3 degrees-of-freedom, two for position and one for rotation. A body can have forces, torques and impulses applied to it. A body has three distinct types:
PhysicsBodyDefinitionA PhysicsBody definition used to specify important initial properties.
PhysicsCallbacksCallback targets for object events.
PhysicsChainA dedicated shape that produces a chain of shapes connected together to produce a continuous surface. Chain shapes provide a smooth, continuous surface that will not produce "ghost" collisions. A PhysicsChain is automatically destroyed when the body it is in is destroyed. A PhysicsChain cannot exist unattached from a body.
PhysicsChainDefinitionA PhysicsChain definition used to specify the chain of vertices that will produce multiple ChainSegmentGeometry shape types. Additionally, non-geometric properties can be specified here.
PhysicsComposerProvides the ability to compose geometry using specific operations on layers in a specific order.
PhysicsConstantsConstants used throughout the 2D physics system.
PhysicsDestructorProvides the ability to destruct (fragment and Slice) geometry.
PhysicsDistanceJointConnects an anchor point on body A with an anchor point on body B via a line segment of a specified distance.
PhysicsDistanceJointDefinitionA joint definition used to specify properties when creating a PhysicsDistanceJoint.
PhysicsEventsVarious events that can be retrieved during and after the simulation has completed. See PhysicsWorld.Simulate and PhysicsWorld.Simulate.
PhysicsFixedJointA joint to constrain a pair of bodies together rigidly. This constraint provides springs to mimic soft-body simulation. The approximate solver cannot always hold many bodies together completely rigidly.
PhysicsFixedJointDefinitionA joint definition used to specify properties when creating a PhysicsFixedJoint.
PhysicsHingeJointA joint where an anchor point on body B is fixed to an anchor point on body A. This joint allows relative rotation.
PhysicsHingeJointDefinitionA joint definition used to specify properties when creating a PhysicsHingeJoint.
PhysicsIgnoreJointA joint used to ignore collision between two specific bodies. As a side effect of being a joint, it also keeps the two bodies in the same simulation island meaning they'll wake/sleep at the same time and be solved together on the same thread.
PhysicsIgnoreJointDefinitionA joint definition used to specify properties when creating a PhysicsIgnoreJoint.
PhysicsJobOptions2DA set of options that control how physics operates when using the job system to multithread the physics simulation.
PhysicsJointA joint is used to constrain bodies to the world or to each other in various ways. A joint is automatically destroyed when either body it is attached to is destroyed. A joint cannot exist unattached from a body.
PhysicsLayersThis provides a common method to retrieving layer information. If a PhysicsLowLevelSettings2D asset is assigned then the full layers (PhysicsLowLevelSettings2D.physicsLayerNames) will be used if PhysicsLowLevelSettings2D.useFullLayers is also active. If no PhysicsLowLevelSettings2D asset is assigned then the global layers (See LayerMask) will be used.
PhysicsMaskA 64-bit mask, effectively 64 flags. The default enumerator will iterate all the bits that are set (1).
PhysicsMathA set of mathematical operations that are useful for physics. These operations do not form a fully comprehensive mathematics library, they simply provide operations that are usually required when interacting with physics.
PhysicsPlaneRepresents a 2D plane.
PhysicsQueryVarious physics queries.
PhysicsRelativeJointA joint constraint used to control the relative movement two bodies while still being responsive to collisions. A spring controls the position and rotation and velocity control allows for simulated friction such as seen in top-down games. A typical usage is to control the movement of a dynamic body with respect to the ground.
PhysicsRelativeJointDefinitionA joint definition used to specify properties when creating a PhysicsRelativeJoint.
PhysicsRotateRepresents a 2D rotation.
PhysicsScene2DRepresents a single instance of a 2D physics Scene.
PhysicsShapeA shape is attached to a body and defines an area to which two distinct types of behaviour are handled:
PhysicsShape2DRepresents an efficient low-level physics shape used by the physics engine.
PhysicsShapeDefinitionA PhysicsShape definition used to specify important initial properties.
PhysicsSliderJointA joint that requires defining a line of motion defined by the local anchor A. Body B may slide along the axis defined by the local anchor A. Body B cannot rotate relative to body A. The joint translation is zero when the local anchor origins coincide in world space. The joint uses local anchors so that the initial configuration can violate the constraint slightly.
PhysicsSliderJointDefinitionA joint definition used to specify properties when creating a PhysicsSliderJoint.
PhysicsTransformRepresents a 2D transformation combining a translation and a PhysicsRotate.
PhysicsUserDataCustom user data. The physics system doesn't use this data, it is entirely for custom use.
PhysicsWheelJointA joint that requires defining a line of motion using an axis and an anchor point. The joint translation is zero when the local anchors coincide in world space. The joint uses local anchors so that the initial configuration can violate the constraint slightly.
PhysicsWheelJointDefinitionA joint definition used to specify properties when creating a PhysicsWheelJoint.
PhysicsWorldA world is a container for all other physics objects such as PhysicsBody, PhysicsShape, PhysicsJoint etc. A world can be simulated in isolation from all other worlds. The maximum number of worlds that can be created at one time is defined by PhysicsConstants.MaxWorlds. A world is completely isolated from all other worlds.
PhysicsWorldDefinitionA PhysicsWorld definition used to specify important initial properties.
PolygonGeometryThe geometry of a closed convex polygon.
RaycastHit2DReturns information about 2D Colliders detected by a 2D physics query in the scene.
SegmentGeometryThe geometry of a line segment. See PhysicsBody.CreateShape.

Enums

Enum

Description

CapsuleDirection2DThe direction that the capsule sides can extend.
ColliderErrorState2DIndicates what (if any) error was encountered when creating a 2D Collider.
CollisionDetectionMode2DControls how collisions are detected when a Rigidbody2D moves.
EffectorForceMode2DThe mode used to apply Effector2D forces.
EffectorSelection2DSelects the source and/or target to be used by an Effector2D.
ForceMode2DOption for how to apply a force using Rigidbody2D.AddForce.
JointBreakAction2DOptions for selecting which action to take when a Joint2D breaks.
JointLimitState2DRepresents the state of a joint limit.
PhysicsMaterialCombine2DDescribes how PhysicsMaterial2D friction and bounciness are combined when two Collider2D come into contact.
PhysicsShapeType2DOptions for indicate which primitive shape type is used to interpret geometry contained within a PhysicsShape2D object.
RigidbodyConstraints2DUse these flags to constrain motion of a Rigidbody2D.
RigidbodyInterpolation2DInterpolation mode for Rigidbody2D objects.
RigidbodySleepMode2DSettings for a Rigidbody2D's initial sleep state.
RigidbodyType2DThe physical behaviour type of the Rigidbody2D.
SimulationMode2DA selection of modes that control when Unity executes the 2D physics simulation.