From c80e456d3efb1126a49518c1346d38a8bd891c86 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Sat, 7 Sep 2024 00:09:51 +1000 Subject: [PATCH] fix player ground detection --- Sources/Voxelotl/Player.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Voxelotl/Player.swift b/Sources/Voxelotl/Player.swift index 14852c5..7dde219 100644 --- a/Sources/Voxelotl/Player.swift +++ b/Sources/Voxelotl/Player.swift @@ -77,15 +77,15 @@ struct Player { func checkCollisionRaycast(_ world: World, _ position: SIMD3, top: Bool) -> Optional { let dir: SIMD3 = !top ? .down : .up var org = !top ? self._position + .up * Self.height : self._position - let max: Float = Self.height + Self.epsilon + let max: Float = Self.height + Self.epsilon * 4 org.x -= Self.radius - org.y -= Self.radius + org.z -= Self.radius if let hit1 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit1 } org.x += Self.radius + Self.radius if let hit2 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit2 } org.x -= Self.radius + Self.radius - org.y += Self.radius + Self.radius + org.z += Self.radius + Self.radius if let hit3 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit3 } org.x += Self.radius + Self.radius if let hit4 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit4 }