Hi!
So you are facing a common misconception about how addforce works: it basically adds a continuous force until removed. To apply an instantaneous force that then stops you need to switch from addforce to apply_impulse:
extends RigidBody
export var speed := 3.0
func _physics_process(_delta):
var velocity := Vector3.ZERO
if Input.is_action_pressed('up'):
velocity.z -= speed
if Input.is_action_pressed('left'):
velocity.x -= speed
if Input.is_action_pressed('down'):
velocity.z += speed
if Input.is_action_pressed('right'):
velocity.x += speed
apply_impulse(velocity.rotated(Vector3.UP, rotation.y), Vector3.ZERO)
I hope that it helps,