Rigidbody(刚体) and Collider(碰撞器)

关于刚体Rigidbody,手册上是这么描述的:

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函数在每一步之前被立即调用。

 

 关于碰撞器Collider的描述:

A base class of all colliders.

所有碰撞器的基类。

If you intend to move the collider around a lot it is recommended to also attach a kinematic rigidbody to it.

如果你打算经常移动这个刚体,建议再附加一个运动学刚体给它。

使用碰撞器时,经常会将触发器属性置为true。

 

总之刚体是模拟现实世界中物理运动的组件。碰撞器描述了物体可被碰撞的边界,以及碰撞过程中相互影响效果。它们经常一起使用,从而产生一些效果,比如爆炸,弹飞等。

 

例如两物体相撞需要实现两者爆炸的效果,rigidbody实现它们碰撞的行为(相互运动),当碰撞器中的触发器确认两物体发生交互后,产生爆炸。

没有刚体,就不会产生物理行为(碰撞),没有碰撞器,就不会产生碰撞后的效果(爆炸)。

 

Q:碰撞怎样才能实现

A:双方必须都含有rigidbody和collider。没有刚体无法实现物理运动,而其中一者没有collider时,两者交互时会穿过。

 

通常我们在角色的组件中只写碰撞方法,将触发方法放在角色触碰的游戏对象的组件中。

 

posted @ 2017-08-11 22:34  鱼丸粗面丶  阅读(403)  评论(0编辑  收藏  举报