如何在 Box2D 中创建一个以中心旋转的平台体
我正在尝试创造漂浮在太空中的旋转形状。环境中仍然存在重力,但它不应该影响这些平台对象,因为它们是静态的(对吗?)。我如何对其应用恒定的角速度?当我给它赋值时,它似乎不适用,可能是因为它是静态的。
最简单的例子是一个旋转齿轮,一个自动跷跷板(不受外力影响)。我想做的只是一个旋转的矩形,它可能会干扰用户控制的球。
我需要使用接头将其固定到位吗?如何指定不受动态对象影响的细节?
感谢任何对此有答案的人!
I'm trying to create spinning shapes floating in space. There is still gravity in the environment, however it should not affect these platform objects because they are static (right?). How can I apply a constant angularVelocity to it though? It doesn't seem to apply when I assign it a value, probably due because it's static.
The simplest example would be a spinning gear, an automated teeter-totter (not influenced by external forces). All I'm trying to make is a spinning rectangle that could interfere with a ball controlled by the user.
Do I need to use Joints to pin it in place? How can I specify the details of not being influenced by the dynamic objects?
Thanks for anyone who has an answer to this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,找到了一个很棒的资源网站,其中显示了一些常见的示例:
http://blog.thestem.ca/archives/102
需要注意的重要一点是,联合本身几乎没有什么用处(或者甚至只附加一个 b2Body)。
它始终需要两 (2) 个主体与其 .body1 和 .body2 属性关联。因此,为了将对象“固定”到世界/背景,您必须创建一个“虚拟”主体作为两个候选主体之一,而另一个则是您想要的移动对象。 电机速度和扭矩是使其“旋转”的关键,而不是在更新方法中控制角速度或直接操纵主体的角度。
——
希望这可以为其他 Flash 物理学家节省一些时间来解决这个问题:)
Actually, found a great resource site showing an example of a few common ones:
http://blog.thestem.ca/archives/102
An important thing to notice, a joint is pretty much useless by itself (or even with only a single b2Body attached to it).
It always require two (2) bodies to be associated to it's .body1 and .body2 properties. So in order to "pin" an object to the world / background, you have to create a "dummy" body as one of the two body candidates, while the other would be your desired moving object. The motor speed and torque is the key to make it "spin", as opposed to controlling the angularVelocity or directly manipulating the body's angle in an update method.
--
Hopefully that saves other Flash physicists some time to figure this one out :)