mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 05:10:57 +00:00
fix player ground detection
This commit is contained in:
parent
2a11080eba
commit
c80e456d3e
@ -77,15 +77,15 @@ struct Player {
|
|||||||
func checkCollisionRaycast(_ world: World, _ position: SIMD3<Float>, top: Bool) -> Optional<RaycastHit> {
|
func checkCollisionRaycast(_ world: World, _ position: SIMD3<Float>, top: Bool) -> Optional<RaycastHit> {
|
||||||
let dir: SIMD3<Float> = !top ? .down : .up
|
let dir: SIMD3<Float> = !top ? .down : .up
|
||||||
var org = !top ? self._position + .up * Self.height : self._position
|
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.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 }
|
if let hit1 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit1 }
|
||||||
org.x += Self.radius + Self.radius
|
org.x += Self.radius + Self.radius
|
||||||
if let hit2 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit2 }
|
if let hit2 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit2 }
|
||||||
org.x -= Self.radius + Self.radius
|
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 }
|
if let hit3 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit3 }
|
||||||
org.x += Self.radius + Self.radius
|
org.x += Self.radius + Self.radius
|
||||||
if let hit4 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit4 }
|
if let hit4 = raycast(world: world, origin: org, direction: dir, maxDistance: max) { return hit4 }
|
||||||
|
Loading…
Reference in New Issue
Block a user