mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-02 13:00:53 +00:00
reorder collision response so zipping up is prioritised over left if player gets stuck in a block
This commit is contained in:
parent
7eb880f0b7
commit
6a57a8580e
@ -113,6 +113,19 @@ struct Player {
|
||||
}
|
||||
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
|
||||
if let aabb = checkCollision(self._position) {
|
||||
if self._velocity.x < 0 {
|
||||
@ -131,19 +144,6 @@ struct Player {
|
||||
}
|
||||
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
|
||||
if self._onGround {
|
||||
|
Loading…
Reference in New Issue
Block a user