Unity3d自学记录 Rigidbody的WakeUp方法

看一个小游戏的源码时的时候,看到有这么一句代码:

GetComponent<Rigidbody>().WakeUp ();

愣了一下,去官网查了一下API,它的意思唤醒一个沉睡的Rigidbody,难道刚体也能睡觉?对呀,因为这是为了优化。

那,原话是这么说的:When a Rigidbody is moving slower than a defined minimum linear or rotational speed, the physics engine assumes it has come to a halt. When this happens, the GameObject does not move again until it receives a collision or force, and so it is set to “sleeping” mode. This optimisation means that no processor time is spent updating the Rigidbody until the next time it is “awoken” (that is, set in motion again).

大白话翻译:当一个刚体比定义的最小线性速度或者旋转速度小时,物理引擎就会假定刚体暂时不使用,直到接受了一个碰撞或者外力,否则就进入了睡眠状态,会节约性能。

那,如果睡眠了,会发生什么?bug!!!

且看下一段原话(准确的描述了bug如何产生):For most purposes, the sleeping and waking of a Rigidbody component happens transparently. However, a GameObject might

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值