Music Playing but Sound Effects wont

Been following the tutorial and have the background music playing just fine. for some reason though it wont play the sfx(jump) at all. I’ve tried doing it directly from the player node as well as through the AudioPlayer as per tutorial. As far as I can tell I’m doing it correctly, but no matter what I try, I get get it to play the jump noise.

Can you post your relevant code? Not much we can do otherwise.

extends Node2D

var hurt = preload("res://assets/audio/hurt.wav")
var jump = preload("res://assets/audio/jump.wav")

func play_sfx(sfx_name: String):
	
	var stream = null
	if sfx_name == "hurt":
		stream = hurt
	elif sfx_name == "jump":
		stream = jump
	else:
		print("Invalid SFX Name")
		return
	var asp = AudioStreamPlayer.new()
	asp.stream = stream
	asp.stream = "SFX"
	
	add_child(asp)
	
	asp.play()
func jump(force):
	AudioPlayer.play_sfx("jump")
	velocity.y = -force

fixed the second “asp.stream” to be “asp.name” jump sounds will play now.

1 Like

Good job! You spotted it just before I did XD

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms