如何检测堆栈对象掉落

发布于 2024-08-10 03:32:42 字数 118 浏览 0 评论 0原文

在我的游戏中,对象正在掉落,我必须抓住该对象并创建一个堆栈。我正在使用花栗鼠物理引擎来做到这一点。我能够创建堆栈,但我不明白如何检测堆栈是否像“Tower Bloxx”游戏一样掉落。

如果有人知道请帮帮我。

In my game, Objects are falling down and I have to catch that object and have to create a stack. I am doing this by using chipmunk physics engine. I am able to create stack but I don't understand how to detect that stack is falling like "Tower Bloxx" game.

If any one knows it please help me out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黯然#的苍凉 2024-08-17 03:32:42

您需要计算每个物体上的力和扭矩。

重力作用于物体的质心。如果这个物体悬垂在另一个物体上,那么可能会产生扭矩,使物体滚落。

如果您已经了解了物理原理,使其更加真实,那么您可以通过监视每个对象的速度方向来检测堆栈是否稳定。如果它正在改变符号,并且幅度越来越小,那么它就会趋于稳定。 (如果它为零,则已经稳定。)

You need to calculate the forces and torques on each object.

Gravity acts on the center of mass of an object. If this object overhangs another object, then there could be a torque that could roll the object off.

If you've got the physics down so that it's realistic, then you can detect whether the stack is stable or not by monitoring the direction of the velocity for each object. If it's changing sign, and the magnitude is getting smaller, then it's stabilizing. (If it's zero, it is stable already.)

策马西风 2024-08-17 03:32:42

我不熟悉花栗鼠引擎的结构,但是它有某种碰撞事件吗?如果是这样,您可以使用该事件来检测除基础块之外的任何块何时击中地面物体并结束游戏。

I'm not familiar with the structure of the chipmunk engine, but does it have some sort of collision event? If so, you could use that event to detect when any block but the base one hits the ground object and end the game then.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文