Preloading a Sound When Loading into an Area

From HEWIKI
Jump to: navigation, search

FMOD Studio should be used by all new HeroCloud developers, and those who have not began substantial work on their audio systems. It is a replacement for DirectMusic and FMOD, and supports both individual files (WAV, MP3, XMA), as well as full-fledged projects.

Below are two sets of instructions; one for when the sound is the same regardless of which area is being loaded into, and one for playing a sound that is unique to the area being loaded into. Common to both methods is that you'll need to use prop buckets and a currently undocumented clean engine system. See Prop Buckets for info on using prop buckets.

Playing a sound common to all area loading

1. If you haven't already done so, create a client-side class to be glommed onto the BASECLIENT prototype and a class methods script for it. Make sure to add a field to the class called 'savedSpecID' of type ID to know which spec to create the sound from.

2. Implement the HE_Area_Preload(areaID as ID, instanceID as ID, areaName as String) as Boolean method.

3. In the method, execute the following lines of code:

 CreatePropBucket("SOUND")
 fmodSoundFQN as String = "\your\fully\qualified\name\sound.fev"
 me.savedSpec = AddAssetSpecToPropBucket( "SOUND", fmodSoundFQN)


4. Implement the HE_Area_Load(areaID as ID, instanceID as ID, areaName as String) method in the same script. This is where you remove your splash screen.

5. In the method, play the sound by executing the following code:

  if(IsAssetSpecReady(me.savedSpec))  
    fmodSoundInstance as noderef = CreateInstanceFromPropBucket("SOUND", me.savedSpecID)
    fmodSoundInstance["EventPath"] = "path/to/sound/event/from/fsb/"
    ActivateInstance(fmodSoundInstance)
  .
 

Playing a Sound Specific to a Particular Area's Loading

1. If you haven't already done so, create a server-side class to be glommed onto the ACCOUNT prototype and a class methods script for it.

2. Implement the HE_ClientReady(account as NodeRef) method.

3. In the method, call whatever system you create to get the FQN of the sound you wish to play for the area that the account has logged into.

4. Make a remote call to a client script with that FQN.

5. In the client script's remote function, execute the following lines of code and store the returned specIdToSave ID:

 CreatePropBucket("SOUND")
 fmodSoundFQN as String = "\your\fully\qualified\name\sound.fev"
 specIdToSave = AddAssetSpecToPropBucket( "SOUND", fmodSoundFQN)

6. The client script should then remote call back up to the server.

7. The server script can then execute PlayerLoadFinished( me ) external function. Note that if you've already implemented the HE_ClientReady() method and were calling PlayerLoadFinished() somewhere else in a synchronous fashion, you will need to remove that. If you were already implemented HE_ClientReady() and were calling PlayerLoadFinished() in an asynchronous fashion, you will want to coordinate this step with that.

7. Implement the HE_Area_Load(areaID as ID, instanceID as ID, areaName as String) method in the same script. This is where you remove your splash screen.

8. In the method, play the sound by executing the following code:

  if(IsAssetSpecReady(specIdToSave))  
    fmodSoundInstance as noderef = CreateInstanceFromPropBucket("SOUND", specIdToSave)
    fmodSoundInstance["EventPath"] = "path/to/sound/event/from/fsb/"
    ActivateInstance(fmodSoundInstance)
  .
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox