摩擦力问题。需要建议:)
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这与平台的移动方式有关。一旦玩家到达平台顶部,是否施加了足够的力?因为玩家的质量可能太大,平台无法移动……只是建议。
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.