Linear Interpolation issues (acceleration and deceleration)?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamepro5

This video illustrates the problems.

To try to describe them, basically when I put linear interpolation code for adding acceleration and deceleration to already working code several things break. After months of trying and giving up, I cant do this anymore and will require help. The project’s code can be found open source here.

(It’s a modified version of this)

:bust_in_silhouette: Reply From: Magso

I’m not sure about the code you currently have but if all else fails I’d suggest lerping a velocity Vector3 with global_transform.basis.xform(direction) like this.

var velocity : Vector3

func _process(delta):
    var local_z_movement = Input.get_action_strength("move_forward") - Input.get_action_strength("move_backward")
    var local_x_movement = Input.get_action_strength("move_left") - Input.get_action_strength("move_right")
    var intended_velocity = global_transform.basis.xform(Vector3(local_x_movement, 0, local_z_movement)
    velocity = lerp(velocity, intended_velocity, delta)