저는이 기사에서 읽은 기사의 자습서를 사용하여이 충돌 감지 시스템을 작성해 왔으며 실제로는 100 % 제대로 작동하도록 할 수 없습니다. 다음은 선발에 대한 코드입니다 :2D 충돌 감지 해상도
BoundingBox aBox;
aBox.Convert(a);
BoundingBox bBox;
bBox.Convert(b);
Vector2 aMin = aBox.GetTopLeft();
Vector2 aMax = aBox.GetBotRight();
Vector2 bMin = bBox.GetTopLeft();
Vector2 bMax = bBox.GetBotRight();
Vector2 minDistance;
float left = (bMin.x - aMax.x);
float right = (bMax.x - aMin.x);
float top = (bMin.y - aMax.y);
float bottom = (bMax.y - aMin.y);
// Check for intersection internally
if (left > 0 || right < 0) return;
if (top > 0 || bottom < 0) return;
// Find the minDistance
if (abs(left) < right)
minDistance.x = left;
else
minDistance.x = right;
if (abs(top) < bottom)
minDistance.y = top;
else
minDistance.y = bottom;
// Null axis with biggest value
if (abs(minDistance.x) < abs(minDistance.y))
minDistance.y = 0;
else
minDistance.x = 0;
문제 지금 그는, 캐릭터가 잘 걷고 블록의 상단과 블록의 바닥을 포옹이지만, 그는 두 블록을 걸어 가지고 일단이다 그 (것)들 사이에서 찔러 얻는다. 우연히도, 아래로 걷는 것은 완벽하게 잘 작동합니다. 누군가이 문제에 대한 해결책을 가지고 있는지 궁금해 할 때, 그것은 대단히 감사하게 될 것입니다! 여기
더 문제를 표시하는 GIF입니다 :
: D 타원 – dgrat