Try to resolve ghost collision
This commit is contained in:
parent
d9c4b0aee2
commit
4474026fd4
@ -188,8 +188,8 @@ fun main() {
|
|||||||
Starbound.pollCallbacks()
|
Starbound.pollCallbacks()
|
||||||
|
|
||||||
//ent.think(client.frameRenderTime)
|
//ent.think(client.frameRenderTime)
|
||||||
//client.camera.pos.x = ent.position.x.toFloat()
|
client.camera.pos.x = ent.position.x.toFloat()
|
||||||
//client.camera.pos.y = ent.position.y.toFloat()
|
client.camera.pos.y = ent.position.y.toFloat()
|
||||||
|
|
||||||
//println(client.camera.velocity.toDoubleVector() * client.frameRenderTime * 0.1)
|
//println(client.camera.velocity.toDoubleVector() * client.frameRenderTime * 0.1)
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import ru.dbotthepony.kstarbound.world.World
|
|||||||
import ru.dbotthepony.kvector.util2d.AABB
|
import ru.dbotthepony.kvector.util2d.AABB
|
||||||
import ru.dbotthepony.kvector.vector.Color
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||||
|
import ru.dbotthepony.kvector.vector.ndouble.times
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
|
||||||
enum class Move {
|
enum class Move {
|
||||||
@ -144,6 +145,11 @@ abstract class WalkableMovementController<T : IWalkableEntity>(entity: T) : Move
|
|||||||
|
|
||||||
if (body.linearVelocity.x > -topSpeed) {
|
if (body.linearVelocity.x > -topSpeed) {
|
||||||
body.linearVelocity += Vector2d(x = -moveSpeed * delta)
|
body.linearVelocity += Vector2d(x = -moveSpeed * delta)
|
||||||
|
|
||||||
|
// Ghost collision prevention
|
||||||
|
if (body.linearVelocity.x.absoluteValue < 1) {
|
||||||
|
body.linearVelocity += -delta * world.gravity * 2.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +160,11 @@ abstract class WalkableMovementController<T : IWalkableEntity>(entity: T) : Move
|
|||||||
|
|
||||||
if (body.linearVelocity.x < topSpeed) {
|
if (body.linearVelocity.x < topSpeed) {
|
||||||
body.linearVelocity += Vector2d(x = moveSpeed * delta)
|
body.linearVelocity += Vector2d(x = moveSpeed * delta)
|
||||||
|
|
||||||
|
// Ghost collision prevention
|
||||||
|
if (body.linearVelocity.x.absoluteValue < 1) {
|
||||||
|
body.linearVelocity += -delta * world.gravity * 2.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user