在Box2D中,如何设置对象的sleepTime?
我正在从事一个教育物理项目,我选择 Box2D 作为“构建自己的火箭”之类的物理游戏的主要引擎。
Box2D 看起来非常直观,文档看起来也不错,恕我直言,但我找不到如何设置给定主体的睡眠时间。是否可以?
我已经尝试过懒惰的方法:
var newB = new b2BodyDef();
newB.m_sleepTime = 12000;
不幸的是,newB
在进入休息位置后几乎立即开始睡眠。
I'm working on a educational physics project and I've chosen Box2D as my main engine for a "Build your own rocket" like physics game.
Box2D looks very intuitive and the documentation seems pretty good IMMO, but I couldn't find how to set the sleeping time of a given body. Is it possible?
I've already tried the lazy approach:
var newB = new b2BodyDef();
newB.m_sleepTime = 12000;
Unfortunately, the newB
still starts to sleep almost instantaneously after it gets into a rest position.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在单个主体上设置SleepingAllowed(bool),或者在创建它时将整个世界设置为不睡眠。除非你的模拟中有大量的身体,否则我只会使用其中之一并让身体始终保持清醒。如果您知道何时需要唤醒各个实体,您还可以对它们设置 SetAwake(bool)。
You can SetSleepingAllowed(bool) on an individual body, or set the entire world to not sleep when you create it. Unless you have a huge number of bodies in your simulation, I would just use one of these and keep the body awake all the time. You can also SetAwake(bool) on individual bodies if you know when you'll need them to be awake.