mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
physics: abort entity movement if collisions would increase distance
This commit is contained in:
parent
aa20dc3441
commit
7236ad0bc8
@ -243,8 +243,9 @@ abstract class Entity(
|
||||
testDelta.y = STEP_HEIGHT
|
||||
val stepMovementY = collisionsToCheck.computeOffset(aabb + testDelta, -STEP_HEIGHT, Axes.Y)
|
||||
if (stepMovementY < 0 && stepMovementY >= -STEP_HEIGHT) {
|
||||
delta.y = STEP_HEIGHT + stepMovementY
|
||||
aabb.offsetAssign(0f, delta.y, 0f)
|
||||
testDelta.y = STEP_HEIGHT + stepMovementY
|
||||
aabb.offsetAssign(0f, testDelta.y, 0f)
|
||||
delta.y += testDelta.y
|
||||
}
|
||||
}
|
||||
val xPriority = delta.x > delta.z
|
||||
@ -268,6 +269,9 @@ abstract class Entity(
|
||||
velocity.x = 0.0f
|
||||
}
|
||||
}
|
||||
if (delta.length() > deltaPosition.length() + STEP_HEIGHT) {
|
||||
return Vec3() // abort all movement if the collision system would move the entity further than wanted
|
||||
}
|
||||
return delta
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user