用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:rigidbody2d:rigidbody2d

Rigidbody2D 二维刚体

Namespace: UnityEngine / Inherits from: Component

Description 描述

Rigidbody physics component for 2D sprites.

用于2D精灵的刚体物理组件。

The Rigidbody2D class essentially provides the same functionality in 2D that the Rigidbody class provides in 3D. Adding a Rigidbody2D component to a sprite puts in under the control of the physics engine. By itself, this means that the sprite will be affected by gravity and can be controlled from scripts using forces. By adding the appropriate collider component, the sprite will also respond to collisions with other sprites. This behaviour comes entirely from Unity's physics system; very little code is required to get impressive and authentic physical behaviour and allows for “emergent” gameplay that was not explicitly coded into the game.

Rigidbody2D类本质上提供了与3D刚体同样功能。添加Rigidbody2D组件到一个精灵上置于物理引擎的控制下。就其本身而言,这意味着精灵会受到重力的影响并可以从脚本使用力控制。通过添加合适的碰撞器组件,该精灵也会响应与其他精灵碰撞。这种行为完全来自Unity的物理系统;非常少的代码得到令人印象深刻和真实的物理行为,并允许游戏中未明确编码的“突发”的运动。

See Also: Rigidbody class, SpriteRenderer class, Collider2D class, Joint2D class.

Variables 变量

angularDragCoefficient of angular drag.
角阻力系数。
angularVelocityAngular velocity in degrees per second.
每秒度的角速度。
centerOfMassThe center of mass of the rigidBody in local space.
刚体局部空间坐标的质量中心。
collisionDetectionModeThe method used by the physics engine to check if two objects have collided.
这个方法用于检测物理引擎两个对象是否已经碰撞。
constraintsControls which degrees of freedom are allowed for the simulation of this Rigidbody2D.
控制允许该Rigidbody2D模拟的自由度。
dragCoefficient of drag.
阻力系数 。
freezeRotationControls whether physics will change the rotation of the object.
控制该对象的物理是否更改旋转。
gravityScaleThe degree to which this object is affected by gravity.
该对象将受重力影响。
inertiaThe rigidBody rotational inertia.
该刚体旋转的惯性。
interpolationPhysics interpolation used between updates.
用于更新期间的物理插值。
isKinematicShould this rigidbody be taken out of physics control?
这个刚体不采用物理控制么?
massMass of the rigidbody.
该刚体的质量。
positionThe position of the rigidbody.
该刚体的位置。
rotationThe rotation of the rigdibody.
该刚体的旋转角度。
simulatedIndicates whether the rigid body should be simulated or not by the physics system.
标识该刚体是否应该物理模拟或不使用物理系统。
sleepModeThe sleep state that the rigidbody will initially be in.
该休眠状态就是该刚体将初始化状态。
useAutoMassShould the total rigid-body mass be automatically calculated from the Collider2D.density of attached colliders?
该刚体的总质量是否从Collider2D.density自动计算。
velocityLinear velocity of the rigidbody.
该刚体的线性速度。
worldCenterOfMassGets the center of mass of the rigidBody in global space.
在世界坐标空间获取该刚体的质量中心。

Functions 函数

AddForceApply a force to the rigidbody.
应用一个力到刚体。
AddForceAtPositionApply a force at a given position in space.
在给定位置添加力。
AddRelativeForceAdds a force to the rigidbody2D relative to its coordinate system.
添加一个力到二维刚体,相对于它的坐标系统。
AddTorqueApply a torque at the rigidbody's centre of mass.
在该刚体的质心应用一个力矩。
GetPointGet a local space point given the point point in rigidBody global space.
GetPointVelocityThe velocity of the rigidbody at the point Point in global space.
在刚体世界坐标空间给定的点,获得局部坐标空间的点。
GetRelativePointGet a global space point given the point relativePoint in rigidBody local space.
在刚体局部空间给定点relativePoint,获得一个全局空间的点。
GetRelativePointVelocityThe velocity of the rigidbody at the point Point in local space.
在局部空间刚体在point点的速度。
GetRelativeVectorGet a global space vector given the vector relativeVector in rigidBody local space.
在刚体局部坐标空间获得给定向量relativeVector的全局坐标空间向量。
GetVectorGet a local space vector given the vector vector in rigidBody global space.
在刚体全局空间给定的的vector向量的获得局部空间向量。
IsAwakeIs the rigidbody “awake”?
Sleeping是用来优化当一个对象在静止时暂时删除物理模拟。这个函数告诉当前刚体是否苏醒。
IsSleepingIs the rigidbody “sleeping”?
该刚体是否休眠?
IsTouchingCheck whether any of the collider(s) attached to this rigidbody are touching the collider or not.
检测附加到该刚体的任意碰撞器是否与collider接触。
IsTouchingLayersChecks whether any of the collider(s) attached to this rigidbody are touching any colliders on the specified layerMask or not.
检测附加到该刚体的任意碰撞器是否与指定层的碰撞器接触。
MovePositionMoves the rigidbody to position.
移动刚体到position。
MoveRotationRotates the rigidbody to angle.
旋转该刚体到“angle”。
SleepMake the rigidbody “sleep”.
使刚体休眠。
WakeUpDisables the “sleeping” state of a rigidbody.
禁用一个刚体的休眠状态。
script/unityengine/classes/rigidbody2d/rigidbody2d.txt · 最后更改: 2016/08/02 05:30 (外部编辑)