GrappleTest/Player/BasicCharacter/SoundScript.gd

27 lines
585 B
GDScript3
Raw Normal View History

2024-03-17 21:56:16 -05:00
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()