mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
3rd person view: keep minimum distance from wall
That fixes seeing through blocks
This commit is contained in:
parent
e4a5cb597b
commit
332423e5ad
@ -59,7 +59,7 @@ class ThirdPersonView(override val camera: Camera) : PersonView {
|
||||
val target = camera.context.connection.camera.target.raycastBlock(position, (-front).toVec3d).first
|
||||
val distance = target?.distance?.let { minOf(it, MAX_DISTANCE) } ?: MAX_DISTANCE
|
||||
|
||||
this.eyePosition = position + (-front * distance)
|
||||
this.eyePosition = if (distance <= 0.0) position else position + (-front * (distance - MIN_MARGIN))
|
||||
}
|
||||
|
||||
override fun onAttach(previous: CameraView?) {
|
||||
@ -71,6 +71,7 @@ class ThirdPersonView(override val camera: Camera) : PersonView {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MIN_MARGIN = 0.05
|
||||
const val MAX_DISTANCE = 3.0
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user