fix: rejected collision movement
This commit is contained in:
parent
aaa78c99c5
commit
6b3136a0b5
|
@ -105,35 +105,30 @@ export default class Collider extends Component {
|
||||||
const otherAabb = other.aabbs[oj];
|
const otherAabb = other.aabbs[oj];
|
||||||
const {Position} = thisEntity;
|
const {Position} = thisEntity;
|
||||||
const {lastX, lastY} = Position;
|
const {lastX, lastY} = Position;
|
||||||
if (!intersects(
|
const {x, y} = Position;
|
||||||
|
if (intersects(
|
||||||
{
|
{
|
||||||
x0: aabb.x0 + Position.lastX,
|
x0: aabb.x0 + lastX,
|
||||||
x1: aabb.x1 + Position.lastX,
|
x1: aabb.x1 + lastX,
|
||||||
y0: aabb.y0 + Position.y,
|
y0: aabb.y0 + y,
|
||||||
y1: aabb.y1 + Position.y,
|
y1: aabb.y1 + y,
|
||||||
},
|
|
||||||
otherAabb,
|
|
||||||
)) {
|
|
||||||
Position.x = lastX;
|
|
||||||
Position.lastX = lastX;
|
|
||||||
}
|
|
||||||
else if (!intersects(
|
|
||||||
{
|
|
||||||
x0: aabb.x0 + Position.x,
|
|
||||||
x1: aabb.x1 + Position.x,
|
|
||||||
y0: aabb.y0 + Position.lastY,
|
|
||||||
y1: aabb.y1 + Position.lastY,
|
|
||||||
},
|
},
|
||||||
otherAabb,
|
otherAabb,
|
||||||
)) {
|
)) {
|
||||||
Position.y = lastY;
|
Position.y = lastY;
|
||||||
Position.lastY = lastY;
|
Position.lastY = lastY;
|
||||||
}
|
}
|
||||||
else {
|
if (intersects(
|
||||||
|
{
|
||||||
|
x0: aabb.x0 + x,
|
||||||
|
x1: aabb.x1 + x,
|
||||||
|
y0: aabb.y0 + lastY,
|
||||||
|
y1: aabb.y1 + lastY,
|
||||||
|
},
|
||||||
|
otherAabb,
|
||||||
|
)) {
|
||||||
Position.x = lastX;
|
Position.x = lastX;
|
||||||
Position.lastX = lastX;
|
Position.lastX = lastX;
|
||||||
Position.y = lastY;
|
|
||||||
Position.lastY = lastY;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user