摩擦力问题。需要建议:)

发布于 2024-10-10 00:30:49 字数 666 浏览 0 评论 0原文

我在 Box2d 世界中有一个移动播放器,在 box2d 世界中有一个移动平台。

现在,如果平台正在移动,我的玩家跳到平台顶部,我的玩家不会随平台移动。我尝试在玩家和平台上设置摩擦力(摩擦力:1.0f),但现在如果它们发生接触,要么移动,要么停止。如果我的玩家移动,平台就会移向该方向(玩家方向)。

我想......我可以将玩家摩擦力设置为0.5f,将平台设置为1.0f......

我该怎么办???我应该改变密度、恢复中的某些内容吗?还是只有摩擦力

我应该更改哪个值?

请帮忙。

非常感谢:D

PS:我正在使用 Objective C + iphone sdk + cocos2d

编辑:代码

//player
    fixtureDef.density = 1.0f;
        fixtureDef.friction = 0.0f;
        fixtureDef.restitution = 0.0f;
//platform
    fixtureDef.density = .0f;
        fixtureDef.friction = 0.0f;
        fixtureDef.restitution = 0.0f;

I have a moving player in a Box2d world and a moving platform which is in the box2d world too.

Now i my player jumps on the top of the platform my player is not moving with the platform if the platform is moving. I tried to set a friction on the player and on the platform (friction: 1.0f) but now if they have a contact either moves and it stops. if my player moves the platform moves into that direction (the player direction).

I thought ..... i could set the player friction to 0.5f and the platform to 1.0f........

what should i do??? should i change something in the density, restitution?? or only the friction??

In which value(s) should i change it??

Help please.

Thank you very much :D

PS: I'm using Objective C + iphone sdk + cocos2d

Edit: code

//player
    fixtureDef.density = 1.0f;
        fixtureDef.friction = 0.0f;
        fixtureDef.restitution = 0.0f;
//platform
    fixtureDef.density = .0f;
        fixtureDef.friction = 0.0f;
        fixtureDef.restitution = 0.0f;

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

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

发布评论

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

评论(1

烟柳画桥 2024-10-17 00:30:49

也许这与平台的移动方式有关。一旦玩家到达平台顶部,是否施加了足够的力?因为玩家的质量可能太大,平台无法移动……只是建议。

Maybe it's got something to do with the way the platform is being moved. Is enough force being applied once the player is on top of the platform? Because the mass of the player might be to high for the platform to move...just suggesting.

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