- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
Inherits from Component
Control of an object's position through physics simulation.
通过物理模拟控制一个物体的位置。
Rigidbody components take control over an object's position - it makes the objects fall down under the influence of gravity, and can calculate how objects will respond to collisions.
Rigidbody组件控制物体的位置 - 它使物体在重力影响下下落,并可计算物体将怎样响应碰撞。
When manipulating rigidbody parameters you should work inside the FixedUpdate function. Physics simulation is carried out in discrete timesteps. The FixedUpdate function is called immediately before each step.
当操作刚体参数的时候,你应该在FixedUpdate函数中使用它,物理模拟以离散的时间步执行。FixedUpdate函数在每一步之前被立即调用。
Things to watch out for when using rigid bodies:
使用刚体需要注意的事:
1. If your simulation looks like slow motion and not solid: This is a problem of scale. When your game world is huge everything will appear to be move very slowly. Make sure all your models are in real world sizes. For example a car should be around 4 meters long. A character around 2 meters high. An object falls at the same acceleration no matter big or small, heavy or light. If your game world has a large scale, objects will still fall at the same acceleration. But since everything is larger, objects will appear like they fall slower.
如果你的模拟看起来像慢动作并且不真实: 这是缩放的问题。如果你的游戏世界非常大,所以的东西将显示移动非常慢,确保你所有的模型为真实世界大小。例如,一个汽车应该有4米长,一个角色约2米高。物体以相同的加速度下落,不论大或小,重或轻。如果你的游戏世界有较大的缩放,物体仍以相同的加速度下落,但是因为所有的物体都比较大,物体的下落显得就比较慢。
Variables变量
velocity
The velocity vector of the rigidbody.
刚体的速度向量。
angularVelocity
The angular velocity vector of the rigidbody.
刚体的角速度向量。
drag
The drag of the object.
物体的阻力。
angularDrag
The angular drag of the object.
物体的角阻力。
mass
The mass of the rigidbody.
刚体的质量。
useGravity
Controls whether gravity affects this rigidbody.
控制重力是否影响整个刚体。
isKinematic
Controls whether physics affects the rigidbody.
控制物理是够影响这个刚体。
freezeRotation
Controls whether physics will change the rotation of the object.
控制物理是否改变物体的旋转。
collisionDetectionMode
The Rigidbody's collision detection mode.
刚体的碰撞检测模式。
centerOfMass
The center of mass relative to the transform's origin.
相对于变换原点的重心。
worldCenterOfMass
The center of mass of the rigidbody in world space (Read Only).
在世界坐标空间的刚体的重心。(只读)
inertiaTensorRotation
The rotation of the inertia tensor.
惯性张量的旋转。
inertiaTensor
The diagonal inertia tensor of mass relative to the center of mass.
相对于重心的质量的惯性张量对角线。
detectCollisions
Should collision detection be enabled? (By default always enabled)
碰撞检测应否启用?(默认总是启用的)
useConeFriction
Force cone friction to be used for this rigidbody.
用于该刚体的锥形摩擦力。
position
The position of the rigidbody.
该刚体的位置。
rotation
The rotation of the rigdibody.
该刚体的旋转。
interpolation
Interpolation allows you to smooth out the effect of***nning physics at a fixed frame rate.
插值允许你以固定的帧率平滑物理运行效果。
solverIterationCount
Allows you to override the solver iteration count per rigidbody.
允许你覆盖每个刚体的求解迭代次数。
sleepVelocity
The linear velocity, below which objects start going to sleep. (Default 0.14) range { 0, infinity }
线性速度,低于该值的物体将开始休眠。(默认0.14)范围{0, infinity}
sleepAngularVelocity
The angular velocity, below which objects start going to sleep. (Default 0.14) range { 0, infinity }
角速度,低于该值的物体将开始休眠。(默认0.14)范围{0, infinity}
maxAngularVelocity
The maximimum angular velocity of the rigidbody. (Default 7) range { 0, infinity }
刚体的最大角速度,(默认7)范围{0, infinity}
Functions函数
SetDensity
Sets the mass based on the attached colliders assuming a constant density.
基于附加的碰撞器假设一个固定的密度设置质量。
AddForce
Adds a force to the rigidbody. As a result the rigidbody will start moving.
添加一个力到刚体。作为结果刚体将开始移动。
AddRelativeForce
Adds a force to the rigidbody relative to its coordinate system.
添加一个力到刚体。相对于它的系统坐标。
AddTorque
Adds a torque to the rigidbody.
添加一个力矩到刚体。
AddRelativeTorque
Adds a torque to the rigidbody relative to the rigidbodie's own coordinate system.
添加一个力矩到刚体,相对于刚体自身的坐标系统。
AddForceAtPosition
Applies force at position. As a result this will apply a torque and force on the object.
在position位置应用force力。作为结果这个将在这个物体上应用一个力矩和力。
AddExplosionForce
Applies a force to the rigidbody that simulates explosion effects. The explosion force will fall off linearly with distance to the rigidbody.
应用一个力到刚体来模拟爆炸效果。爆炸力将随着到刚体的距离线形衰减。
ClosestPointOnBounds
The closest point to the bounding box of the attached colliders.
到附加的碰撞器边界框上的最近点。
GetRelativePointVelocity
The velocity relative to the rigidbody at the point relativePoint.
相对于刚体在relativePoint点的速度。
GetPointVelocity
The velocity of the rigidbody at the point worldPoint in global space.
刚体在世界坐标空间中worldPoint点的速度。
MovePosition
Moves the rigidbody to position.
移动刚体到position。
MoveRotation
Rotates the rigidbody to rotation.
旋转刚体到rot。
Sleep
Forces a rigidbody to sleep at least one frame.
强制一个刚体休眠至少一帧。
IsSleeping
Is the rigidbody sleeping?
刚体在休眠么?
WakeUp
Forces a rigidbody to wake up.
强制唤醒一个刚体。
SweepTest
Tests if a rigidbody would collide with anything, if it was moved through the scene.
如果一个刚体碰到任何东西触发测试,如果它是穿过场景。
SweepTestAll
Like Rigidbody.SweepTest, but returns all hits.
像Rigidbody.SweepTest,但是返回所有碰撞点。
Messages Sent发送消息
OnCollisionEnter
OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
当这个collider/rigidbody已经开始接触另一个rigidbody/collider时,OnCollisionEnter被调用。
OnCollisionExit
OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
当这个collider/rigidbody停止接触另一个rigidbody/collider时,OnCollisionExit被调用。
OnCollisionStay
OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
对于每个collider/rigidbody接触另一个rigidbody/collider时,OnCollisionStay每帧被调用一次。
Inherited members继承成员
Inherited Variables继承变量
transform
The Transform attached to this GameObject (null if there is none attached).
Transform附加到GameObject(游戏物体)(如无附加则为空)。
rigidbody
The Rigidbody attached to this GameObject (null if there is none attached).
Rigidbody附加到GameObject(游戏物体)(如无附加则为空)。
camera
The Camera attached to this GameObject (null if there is none attached).
Camera附加到GameObject(游戏物体)(如无附加则为空)。
light
The Light attached to this GameObject (null if there is none attached).
Light附加到GameObject(游戏物体)(如无附加则为空)。
animation
The Animation attached to this GameObject (null if there is none attached).
Animation附加到GameObject(游戏物体)(如无附加则为空)。
constantForce
The ConstantForce attached to this GameObject (null if there is none attached).
ConstantForce附加到GameObject(游戏物体)(如无附加则为空)。
renderer
The Renderer attached to this GameObject (null if there is none attached).
Renderer附加到GameObject(游戏物体)(如无附加则为空)。
audio
The AudioSource attached to this GameObject (null if there is none attached).
AudioSource附加到GameObject(游戏物体)(如无附加则为空)。
guiText
The GUIText attached to this GameObject (null if there is none attached).
GUIText附加到GameObject(游戏物体)(如无附加则为空)。
networkView
The NetworkView attached to this GameObject (Read Only). (null if there is none attached)
NetworkView附加到GameObject(游戏物体)(只读)(如无附加则为空)。
guiTexture
The GUITexture attached to this GameObject (Read Only). (null if there is none attached)
GUITexture附加到GameObject(游戏物体)(只读)(如无附加则为空)。
collider
The Collider attached to this GameObject (null if there is none attached).
Collider附加到GameObject(游戏物体)(如无附加则为空)。
hingeJoint
The HingeJoint attached to this GameObject (null if there is none attached).
HingeJoint附加到GameObject(游戏物体)(如无附加则为空)。
particleEmitter
The ParticleEmitter attached to this GameObject (null if there is none attached).
ParticleEmitter附加到GameObject(游戏物体)(如无附加则为空)。
gameObject
The game object this component is attached to. A component is always attached to a game object.
组件附加的游戏物体。一个组件总是被附加到一个游戏物体。
tag
The tag of this game object.
游戏物体的标签。
name
The name of the object. //物体的名字
hideFlags
Should the object be hidden, saved with the scene or modifiable by the user?
物体是否被隐藏、保存在场景中或被用户修改?
Inherited Functions继承函数
GetComponent
Returns the component of Type type if the game object has one attached, null if it doesn't.
如果游戏物体有一个附加,则返回Type类型的组件,如果没有则为null。
GetComponent.<T>
GetComponent
Returns the component with name type if the game object has one attached, null if it doesn't.
如果游戏物体有一个附加,则返回名字类型组件,如果没有则为null。
GetComponentInChildren
Returns the component of Type type in the GameObject or any of its children using depth first search.
返回Type类型组件,在GameObject或它的任何子物体使用深度优先搜索,仅返回激活的组件。
GetComponentInChildren.<T>
GetComponentsInChildren
Returns all components of Type type in the GameObject or any of its children.
在GameObject或任何它的子物体,返回全部Type类型组件
GetComponentsInChildren.<T>
GetComponents
Returns all components of Type type in the GameObject.
在游戏物体返回全部Type类型组件。
GetComponents.<T>
CompareTag
Is this game object tagged tag?
游戏物体有被标记标签么?
SendMessageUpwards
Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour
在游戏物体每一个MonoBehaviour和每一个behaviour的祖先上调用名为methodName的方法。
SendMessage
Calls the method named methodName on every MonoBehaviour in this game object.
在游戏物体每一个MonoBehaviour上调用名为methodName的方法。
BroadcastMessage
Calls the method named methodName on every MonoBehaviour in this game object or any of its children.
在游戏物体每一个MonoBehaviour和它的全部子物体上调用名为methodName的方法。
GetInstanceID
Returns the instance id of the object.
返回物体的实例ID
ToString
Returns the name of the game object.
返回游戏物体的名称。
Inherited Class Functions继承类函数
operator bool
Does the object exist?
物体是否存在?
Instantiate
Clones the object original and returns the clone.
克隆原始物体,并返回克隆的物体
Instantiate.<T>
Destroy
Removes a gameobject, component or asset.
删除一个游戏物体、组件或资源
DestroyImmediate
Destroys the object obj immediately. It is strongly recommended to use Destroy instead.
立即销毁物体obj,强烈建议使用Destroy代替。
FindObjectsOfType
Returns a list of all active loaded objects of Type type.
返回Type类型的所有激活的加载的物体列表
FindObjectOfType
Returns the first active loaded object of Type type.
返回Type类型第一个激活的加载的物体。
operator ==
Compares if two objects refer to the same
比较如果两个物体相同
operator !=
Compares if two objects refer to a different object
比较如果两个物体不同
DontDestroyOnLoad
Makes the object target not be destroyed automatically when loading a new scene.
加载新场景的时候使目标物体不被自动销毁。
|
|