问题描述
我正在尝试box2d.我似乎遇到了一个被人们描述为粘墙的问题
I'm experimenting with box2d.I seem to have a problem people describe as sticky walls
我有一个球和一个球拍
我使用的是我能找到的所有推荐的基本磅秤,即10m世界,1m球
I'm using all the basic recommended scales I could find, 10m world, 1m ball
该球具有以下属性:
shape: circle (.5f radius)
size: 1.0f
density: 1.0f
restitution: 1.0f
friction: 0.0f
用于移动球的球拍为1.5m,它具有以下属性:形状:
The paddle used to move the ball is 1.5m, it has the following properties:shape:
circle (.75f radius)
size: 1.5f
density: 10.0f
restitution: 0.1f
friction: 0.0f
如您所见,所有物体的摩擦力均为0.
As you see the friction is 0 for all objects.
球不断被卡住沿墙滚动或完全卡在90度角上
The ball constantly gets stuck rolling along a wall or completely jammed in the 90 degree corners
我本以为我可以检测到与墙壁的碰撞并触发applyLinearImpulse将球移离墙壁.
I was thinking I could detect a collision with a wall and trigger an applyLinearImpulse to move the ball off the wall.
推荐答案
您需要降低弹性碰撞的最小速度阈值.
You need to reduce the minimum velocity threshold for elastic collisions.
通过减少 b2Settings :: b2_velocityThreshold 接近0.
这篇关于如何防止球粘在Box2D中的墙壁上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!