This worked to me:
extends KinematicBody2D
const UP = Vector2(0, -1)
const GRAVITY = 35
const SPEED = 700
const JUMP_HEIGHT = -1200
var motion = Vector2()
var motion_previous = Vector2()
var hit_the_ground = false
func _physics_process(delta):
motion_previous = motion
motion = move_and_slide(motion, UP, false)
"""
-- New Code from this Point --
If the player is in the air, make scale of sprite
based on the y motion value using range_lerp
The fast the y motion,
the larger the y stretch,
the larger the x squash
"""
if not is_on_floor():
hit_the_ground = false
$Sprite.scale.y = range_lerp(abs(motion.y), 0, abs(JUMP_HEIGHT), 0.75, 1.75)
$Sprite.scale.x = range_lerp(abs(motion.y), 0, abs(JUMP_HEIGHT), 1.25, 0.75)
"""
If there's a floor collision,
set squashed scale values based on
previous motion
"""
if not hit_the_ground and is_on_floor():
hit_the_ground = true
$Sprite.scale.x = range_lerp(abs(motion_previous.y), 0, abs(1700), 1.2, 2.0)
$Sprite.scale.y = range_lerp(abs(motion_previous.y), 0, abs(1700), 0.8, 0.5)
$Sprite.scale.x = lerp($Sprite.scale.x, 1, 1 - pow(0.01, delta))
$Sprite.scale.y = lerp($Sprite.scale.y, 1, 1 - pow(0.01, delta))

Don't ask me why the character it's a door. XD