0
我有以下问题:我想使用子弹物理来移动字符。到目前为止,我有一个跳跃的严重问题:如果我落在地面上,身体(角色)沉入地面几秒钟。他跌倒的时间越长,他就越沉。我使用20的重力,一个圆柱形和一个睡眠阈值为0,0的地平面。有没有什么办法解决这一问题?Bulletphysics body through floor
我有以下问题:我想使用子弹物理来移动字符。到目前为止,我有一个跳跃的严重问题:如果我落在地面上,身体(角色)沉入地面几秒钟。他跌倒的时间越长,他就越沉。我使用20的重力,一个圆柱形和一个睡眠阈值为0,0的地平面。有没有什么办法解决这一问题?Bulletphysics body through floor
听起来好像你的物体在每个模拟步骤中移动得太快。这样做的结果可能会导致两个物体过度穿透。在提供字符控制器代码的情况下,有一个recoverFromPenetration被调用来将引起冲突的对象向后移动(向后定义为从穿透多边形的法线计算),直到它不再穿透为止。
void btKinematicCharacterController::preStep ( btCollisionWorld* collisionWorld)
{
int numPenetrationLoops = 0;
m_touchingContact = false;
while (recoverFromPenetration (collisionWorld))
{
numPenetrationLoops++;
m_touchingContact = true;
if (numPenetrationLoops > 4)
{
//printf("character could not recover from penetration = %d\n", numPenetrationLoops);
break;
}
}
m_currentPosition = m_ghostObject->getWorldTransform().getOrigin();
m_targetPosition = m_currentPosition;
// printf("m_targetPosition=%f,%f,%f\n",m_targetPosition[0],m_targetPosition[1],m_targetPosition[2]);
}
它试图做这4次,如果它不能解决渗透恢复代码失败,并终止与对象仍然穿透彼此。这个控制器代码并不是要成为生产代码,而是进一步定制和开发的起点和框架。它的目的非常好,但是你发现它有一些限制。