Sound and visual effects
The structure and gameplay of the game is complete. In this section, you’ll add some additional effects to the game to improve the game experience.
Sound and music
In the res://assets/sounds
folder are several audio effects for the game. To play a sound, it needs to be loaded by an AudioStreamPlayer
node. Add two of these nodes to the Player
scene, naming them LaserSound
and EngineSound
. Drag the respective sound files into each node’s Stream property in the Inspector. To play the sound when shooting, add this line to shoot()
in player.gd
:
$LaserSound.play()
Play the game and try shooting. If you find the sound too loud, you can adjust the Volume dB property. Try a value of -10
to start.
The engine sounds works a little differently. It needs to play when the thrust is on, but if you just try to call play()
on the sound in the get_input()
function when the player presses the key, it will restart the sound every frame. This doesn...