[SOLVED] Play jumping sound on Button Click 'R'

As far as I can see your script is not saved. Can you check this please?

// update function
if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
    this.entity.sound.play('Sound');
}
1 Like

wait if it plays everytime you hit the spacebar that would be weird, it should play everytime the jumping mechanic/script is played

that is the jumping

not to sure what you mean by saving the script but is this correct
Screenshot 2022-04-05 7.33.08 PM

If you change script you need to save it. You can do this with CTRL+S. A script that is not saved has a orange script name on the left side of the code editor.

Please update your code with the correct slot name ‘Song’ instead of ‘Sound’ (my bad).

ohhh ok thank you ill try it

Not the script name, only the slot name:

// update function
if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
    this.entity.sound.play('Song');
}

it worked thank you very much

I would suggest to start the sound after line 125 of the player script. Then you can remove the extra script. Make sure the sound component is on the same entity as the script.

ok thank you

1 Like

did you get it working?

Yes

1 Like

noice i’m making the sfx menu so you can turn off if you dont want it
also do you think you can make multiple different sounds you can toggle on or off, or even just changing the original because i actually kinda dont like the sound it’s not a good sound for this game in my opinion so i either want it permanantly changed to an option to change it