extends Node2D

@onready var player = get_parent()

var jump = preload("res://Player/BasicCharacter/Sounds/Jump/jump.tscn")

var lastJump = null

func _on_character_jumped():
	var sound = jump.instantiate()
	add_child(sound)
	if is_instance_valid(lastJump):
		sound.pitch_scale += 0.5
		lastJump.queue_free()
	lastJump = sound

var lastAir = true

func _physics_process(delta):
	if player.is_on_floor() and lastAir:
		lastAir = false
		$Landing.play()
	elif not player.is_on_floor():
		lastAir = true
	if Input.is_action_just_pressed("down") and player.is_on_floor():
		$Squish.play()
