gdquest-demos / godot-make-pro-2d-games

A-RPG demo made with Godot, MIT-licensed, from our Godot course
MIT License
995 stars 108 forks source link

Add SFX Libraries #59

Closed henriiquecampos closed 6 years ago

henriiquecampos commented 6 years ago

Hey there, since I am implementing some public domain assets, from kenney I thought that some of them may be helpful.

So let me give a bit of context for this.

AudioStreamRandomPitch

Since we can't set random pitch on importing settings, I decided that it would be good to have AudioStreamRandomPitch resources for each sound effect, so they are the default resource used in the AudioStreamPlayer nodes, the source *.ogg can be found in the */source folder.

SoundEffectLibrary

This is a collection of AudioStreamPlayer nodes that behaves like a library. The idea is that you can put as many AudioStreamPlayers as needed and play them using the Library as interface. A good example would be to have a SoundEffectLibrary for the footsteps. If you want to play a specific one you can call SoundEffectLibrary.play(name_of_the_effect) where name_of_the_effect is the name of the node. But if you want to play a random effect you can just call SoundEffectLibrary.play() and it will randomly pick a child and play it. An example hierarchy:

- PlayerNode
    - FootStepsSFX
        - FootStep1
        - FootStep2
        - FootStep3
        - FootStep4

AudioLibraryFactory

This is an EditorScript that takes a SoundEffectLibrary.source_directory and automatically creates the needed AudioSampleRandomPitches and AudioStreamPlayers as child of the SoundEffectLibrary, that :warning: MUST BE THE ROOT NODE when running this script.

Well, lemme know if anything at all must be changed or removed. I hope this helps! :heart:

NathanLovato commented 6 years ago

Wow okay that's not what I expected. I don't want random assets packaged with the game: only relevant sounds. Can you send me a zip file instead? I'll add you as a contributor manually on the commit when I add the sounds the game needs.

henriiquecampos commented 6 years ago

Sure. Here, the zip with the samples (.ogg) and the AudioLibraryFactory.gd with the SoundEffectLibrary.gd if you find them useful.

sound_effects.zip