1 decade ago by craig132
if (overlapY > overlapX || ( bottom.grounded && top.collides === ig.EntityExtended.COLLIDES.FIXED )) {
// two fixed entities collided
if ( left.collides + right.collides >= COLLISION_DOUBLEFIXED ) {
left.collideWith(right, 1, 0, -overlapX, 0);
right.collideWith(left, -1, 0, overlapX, 0);
}
else {
vel = (left.vel.x - right.vel.x) * 0.5;
left.collideWith(right, 1, 0, -overlapX, -vel, weak);
right.collideWith(left, -1, 0, overlapX, vel, weak);
}
}
// default to higher overlap on x axis, i.e. vertical collision
else {
// two fixed entities collided
if ( top.collides + bottom.collides >= COLLISION_DOUBLEFIXED ) {
top.collideWith(bottom, 0, 1, -overlapY, 0);
bottom.collideWith(top, 0, -1, overlapY, 0);
}
else {
//bug occurs here, -1 case doesn't trigger
vel = (top.vel.y - bottom.vel.y) * 0.5;
top.collideWith(bottom, 0, 1, -overlapY, -vel, weak);
bottom.collideWith(top, 0, -1, overlapY, vel, weak);
}
}
I am using the impact++ plugins to make a birds eye view game.
The horizontal collision with fixed entity is working fine, weak one stops at collision. Vertical collision seems to be broken. Collision with fixed entity below character is fine, but collision with fixed entity above character causes the character to teleport to the side of the fixed entity. Any help is appreciated.
// two fixed entities collided
if ( left.collides + right.collides >= COLLISION_DOUBLEFIXED ) {
left.collideWith(right, 1, 0, -overlapX, 0);
right.collideWith(left, -1, 0, overlapX, 0);
}
else {
vel = (left.vel.x - right.vel.x) * 0.5;
left.collideWith(right, 1, 0, -overlapX, -vel, weak);
right.collideWith(left, -1, 0, overlapX, vel, weak);
}
}
// default to higher overlap on x axis, i.e. vertical collision
else {
// two fixed entities collided
if ( top.collides + bottom.collides >= COLLISION_DOUBLEFIXED ) {
top.collideWith(bottom, 0, 1, -overlapY, 0);
bottom.collideWith(top, 0, -1, overlapY, 0);
}
else {
//bug occurs here, -1 case doesn't trigger
vel = (top.vel.y - bottom.vel.y) * 0.5;
top.collideWith(bottom, 0, 1, -overlapY, -vel, weak);
bottom.collideWith(top, 0, -1, overlapY, vel, weak);
}
}
I am using the impact++ plugins to make a birds eye view game.
The horizontal collision with fixed entity is working fine, weak one stops at collision. Vertical collision seems to be broken. Collision with fixed entity below character is fine, but collision with fixed entity above character causes the character to teleport to the side of the fixed entity. Any help is appreciated.