Why one object can play sound while other not?

olokolo96olokolo96 Posts: 6Member

Hi, im making platformer game where you pick up things. I wanted to add sound effect for picking up coin but it doesnt seem to work, so ive tryied it on another object and it works. When picking up coin i can hear some quiet noise.

Best Answer

  • olokolo96olokolo96 Posts: 6
    Accepted Answer

    I've realized what is cause of this. The sound just wasn have time to play bevore the parent node was deleted.

Answers

  • olokolo96olokolo96 Posts: 6Member

    i use play() function, playing and autoplay is turned off

  • SIsilicon28SIsilicon28 Posts: 647Moderator

    Are you using an AudioStreamPlayer3D by any chance?

  • olokolo96olokolo96 Posts: 6Member

    No, im using AudioStreamPlayer2d. Thats confusing because on other objects it works properly. code for pick up funcion of coin :
    func pick_up():
    $Sprite.self_modulate.a -= .075
    if $Sprite.self_modulate.a <= 0:
    queue_free()
    $weed.play()
    position.y -= 1

  • olokolo96olokolo96 Posts: 6Member

    @olokolo96 said:
    No, im using AudioStreamPlayer2d. Thats confusing because on other objects it works properly. code for pick up funcion of coin :
    func pick_up():
    $Sprite.self_modulate.a -= .075
    if $Sprite.self_modulate.a <= 0:
    queue_free()
    $weed.play()
    position.y -= 1

    weed is my sound node xD

  • olokolo96olokolo96 Posts: 6Member
    Accepted Answer

    I've realized what is cause of this. The sound just wasn have time to play bevore the parent node was deleted.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file