Referring to the Godot Engine book, importing and playing sound is quite simple in Godot. But there are a few things to take care of:
Background music is a good way to improve the design of your world.
To add background music to your game, verify that res://main.scn contains globals/bg_music.scn as a child of telon.
To launch music, you have 2 main ways.
If you want the music to be played automatically, change the globals/bg_music.tscn by adding a stream path to the stream node. You have to activate the Autoplay property in the Inspector too.
To control the music changes on event, use the set_state
to bg_music command when you want to load a new music and give the file path in local system:
set_state bg_music "res://scenes/intro-game/sounds/asianoriental2.ogg"
Make sure you use only stream formats for bg music, like ogg, mpc or opus. Wav won't work here !
To change a music to another, just reuse the set_state with another resource path.
To stop the music, use set_state bg_music off
.
Keep in mind that the state of the object will be saved to the savegame, so this music setting will be restored when a game is loaded.
Sound effects are made to give a better feedback to action as well as giving the game more realism. Most of the sound effects you’ll need will be played while picking or using an object, or when a dialog happens (voicing). Because there can often be animations while the sound plays, Escoria uses those animations too. If you don’t have any, you will have to set one for each sound.
For example, if we wanted the good_bamboo to play a sound on pick-up, we should do the following.
set_state
command, but we can preferably use anim global_id animation_name
or cut_scene global_id animation_name
. In our case, we would get::pick_up
anim good_bamboo pick_up
Il y a une erreur de communication avec le serveur Booktype. Nous ne savons pas actuellement où est le problème.
Vous devriez rafraîchir la page.