Setting up the Banks path location
Before attempting to load any banks, make sure to have set the correct Banks path location in the FMOD settings located in the Project Settings (the Advanced Settings toggle needs to be activated for the FMOD settings to show up):
Loading Banks at Engine startup
To automatically load Banks when starting up your game, add your desired Banks to the Banks to Load at Startup setting in the Project Settings displayed above. The Banks will be automatically loaded this way. This might be useful for directly loading your Master Bank.
Loading Banks with the StudioBankLoader Node
The integration ships with a custom node called StudioBankLoader that will allow you to select a defined number of Banks and load or Unload them on Enter Tree, Ready or Exit Tree:
You need to enter the number of banks you want to load and list of Bank properties will appear in the inspector. You can select the desired banks by clicking on Select Bank...
button.
Loading Banks with GDScript
The simplest way to load a Bank with GDScript is to export a BankAsset
member variable and call load_bank_file
on the StudioSystem
object:
extends Node3D
@export var bank_asset: BankAsset
var bank: Bank
func _enter_tree() -> void:
bank = FMODStudioModule.get_studio_system().load_bank_file(bank_asset.file_path, FMODStudioModule.FMOD_STUDIO_LOAD_BANK_NORMAL, false)
You will need to select the Bank in the inspector for this to work.
Alternatively, you can directly pass a path to desired bank to load_bank_file
:
extends Node3D
var bank_path: String = "res://banks/Desktop/music.bank"
var bank: Bank
func _enter_tree() -> void:
bank = FMODStudioModule.get_studio_system().load_bank_file(bank_path, FMODStudioModule.FMOD_STUDIO_LOAD_BANK_NORMAL, false)
Unloading the bank involves calling unload on the Bank instance:
extends Node3D
var bank: Bank
func _enter_tree() -> void:
bank = FMODStudioModule.get_studio_system().get_bank("bank:/TestBank")
bank.unload()
You should know how to load banks now. Try it out and check if you get any warning and errors. You can try to play back FMOD Events in Godot next.
Loading Banks from outside the project at runtime
On Windows you can load banks that are stored outside the project. For example you could ship your banks alongside the game .exe and call OS.get_executable_path().get_base_dir() to get the game’s directory. It is still recommended that you export them in your project, especially if you yu plan to support multiple platforms.