Improved movement interpolation

This commit is contained in:
2024-02-23 20:13:46 +01:00
parent 7926b7a80e
commit fcee55d9a4
10 changed files with 48 additions and 31 deletions

View File

@ -3,7 +3,7 @@ extends Node
@export var move_speed := 4.5
@export var jump_velocity := 4.5
@export var deceleration := 0.75
@export var deceleration_speed := 20
var body: Character
var direction: Vector3
@ -20,8 +20,8 @@ func _physics_process(delta):
body.velocity.x = direction.x * move_speed
body.velocity.z = direction.z * move_speed
else:
body.velocity.x *= deceleration
body.velocity.z *= deceleration
body.velocity.x = Math.dampf(body.velocity.x, 0, deceleration_speed * delta)
body.velocity.z = Math.dampf(body.velocity.z, 0, deceleration_speed * delta)
if !body.is_on_floor():
body.velocity.y -= gravity * delta