0 votes

I've tried to read the manual, I think now's the time to ask. Imagine the rhythm game Crypt of the Necrodancer. In short, as I recall it:

There's an upbeat music playing during gameplay. Once you encounter the shopkeeper, they start to sing along the background music. The shopkeeper's singing may become quieter once you go further away from them.

How'd one implement something like this in Godot?

asked Nov 5, 2018 in Engine by Northburns (12 points)

1 Answer

+1 vote

General idea: You need to render all your layers of music that you want to play dynamically as separate tracks. Then you need to store bars (or some unit of musical content - melody that loops) of your music track in array in seconds, so you can determine when second layer can be played to be in sync with backround track. You need to track position of your background music with get_playback_position of AudioStreamPlayer node, and you can play second track if position is equal to to some of values in array of background music. If it is equal then you play your second layer. If second layer is not simple small loop but it's same length and as background music that changes its form (ABA or other) then you need to play second layer at same position with seek function of AudioStreamPlayer node. Each music track should be played in separate audio bus with bus function of AudioStreamPlayer node so yuo can mix them as you wish, and you can monitor distance of some object and make volume of second layer of music dependent of that disnace - volume_db function of AudioStramPlayer node. Hope it helps.

answered Dec 5, 2018 by pospathos (238 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.