mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 13:11:33 +00:00
reorder collision response so zipping up is prioritised over left if player gets stuck in a block
This commit is contained in:
@ -113,6 +113,19 @@ struct Player {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
self._position.y += self._velocity.y * deltaTime
|
||||||
|
if let aabb = checkCollision(self._velocity.y > 0 ? self._position + .down * Self.epsilon : self.position) {
|
||||||
|
if self._velocity.y < 0 {
|
||||||
|
self._position.y = aabb.top + Self.epsilon
|
||||||
|
self._onGround = true
|
||||||
|
} else {
|
||||||
|
self._position.y = aabb.bottom - Self.height - Self.epsilon
|
||||||
|
self._onGround = false
|
||||||
|
}
|
||||||
|
self._velocity.y = 0
|
||||||
|
} else {
|
||||||
|
self._onGround = false
|
||||||
|
}
|
||||||
self._position.x += self._velocity.x * deltaTime
|
self._position.x += self._velocity.x * deltaTime
|
||||||
if let aabb = checkCollision(self._position) {
|
if let aabb = checkCollision(self._position) {
|
||||||
if self._velocity.x < 0 {
|
if self._velocity.x < 0 {
|
||||||
@ -131,19 +144,6 @@ struct Player {
|
|||||||
}
|
}
|
||||||
self._velocity.z = 0
|
self._velocity.z = 0
|
||||||
}
|
}
|
||||||
self._position.y += self._velocity.y * deltaTime
|
|
||||||
if let aabb = checkCollision(self._velocity.y > 0 ? self._position + .down * Self.epsilon : self.position) {
|
|
||||||
if self._velocity.y < 0 {
|
|
||||||
self._position.y = aabb.top + Self.epsilon
|
|
||||||
self._onGround = true
|
|
||||||
} else {
|
|
||||||
self._position.y = aabb.bottom - Self.height - Self.epsilon
|
|
||||||
self._onGround = false
|
|
||||||
}
|
|
||||||
self._velocity.y = 0
|
|
||||||
} else {
|
|
||||||
self._onGround = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ground friction
|
// Ground friction
|
||||||
if self._onGround {
|
if self._onGround {
|
||||||
|
Reference in New Issue
Block a user