About Store Forum Documentation Contact
Donations:
140$/mo



Post Reply 
[SOLVED] Dynamic Ambient Music
Author Message
Dwight Offline
Silver Supporter

Post: #1
[SOLVED] Dynamic Ambient Music
Hi all,

I am looking for some input (or even classes if you want to share) with regards to ambient music in the game world.

My game world is a single world where I would like to have different ambient music depending on the environment type. I was thinking of creating empty game objects and scale them up to be around the area and check if the player is within the bounding box of that object and play a certain playlist.

However... My game world consists of islands and most of the world is actually just water. What would be an easy method of playing "wave" sounds when the player is above water? The ocean plane is set at -0.2 (I was thinking of checking the Y coordinate and if it's below 0, play the sea music... but the player might be on a ship... so I ran into that problem). Or perhaps retrieve the Y coordinatate of the area at the player's location as the heightmap areas where there's ocean is always below -0.2?

Has anyone implemented such an audio/music manager before for a single large open world?

Would greatly appreciate any thoughts or ideas!
  • Playing music underwater [SamNainocard's solution is perfect for this)
  • Playing music in certain bounded area inside a world area [Tottel's tool works like a charm!]
  • Playing music whilst character is on sea (at any height) [Esenthel: add custom data per area]
(This post was last modified: 11-13-2020 08:31 PM by Dwight.)
11-05-2020 02:44 PM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

Post: #2
RE: Dynamic Ambient Music
Not sure about the other part, but about the water part.

I use this code to detect if Character is on land or underwater.
Code:
flt water_depth=0;
WaterMtrlPtr water_mtrl =Game.World.waterUnder(T.pos(), &water_depth);

It gives both water material and its depth where the character is in the water, it certainly comes in handy.
11-05-2020 07:04 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Silver Supporter

Post: #3
RE: Dynamic Ambient Music
(11-05-2020 07:04 PM)SamNainocard Wrote:  Not sure about the other part, but about the water part.

I use this code to detect if Character is on land or underwater.
Code:
flt water_depth=0;
WaterMtrlPtr water_mtrl =Game.World.waterUnder(T.pos(), &water_depth);

It gives both water material and its depth where the character is in the water, it certainly comes in handy.

I only used it for swimming, but it certainly also works for the muffled music underwater!

Cheers!
11-06-2020 09:37 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Dynamic Ambient Music
In my game I store information about climate in that area (enums in a custom area heightmap data), and play music/ambient based on climate (jungle, desert, snow, etc.), also take into account night/day time, and if combat is happening.
11-08-2020 09:24 AM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #5
RE: Dynamic Ambient Music
(11-08-2020 09:24 AM)Esenthel Wrote:  In my game I store information about climate in that area (enums in a custom area heightmap data), and play music/ambient based on climate (jungle, desert, snow, etc.), also take into account night/day time, and if combat is happening.

Possible you'd share the "custom area heightmap data"
11-09-2020 03:52 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Silver Supporter

Post: #6
RE: Dynamic Ambient Music
(11-09-2020 03:52 PM)Lancer Wrote:  
(11-08-2020 09:24 AM)Esenthel Wrote:  In my game I store information about climate in that area (enums in a custom area heightmap data), and play music/ambient based on climate (jungle, desert, snow, etc.), also take into account night/day time, and if combat is happening.

Possible you'd share the "custom area heightmap data"

Perhaps quite a nice addition to the tutorials! Saving and loading custom area data?

My initial idea was having a file and inserting all areas in there and read the data from there; is there a simpler method?
11-10-2020 08:46 AM
Find all posts by this user Quote this message in a reply
Lancer Offline
Member

Post: #7
RE: Dynamic Ambient Music
(11-10-2020 08:46 AM)Dwight Wrote:  
(11-09-2020 03:52 PM)Lancer Wrote:  
(11-08-2020 09:24 AM)Esenthel Wrote:  In my game I store information about climate in that area (enums in a custom area heightmap data), and play music/ambient based on climate (jungle, desert, snow, etc.), also take into account night/day time, and if combat is happening.

Possible you'd share the "custom area heightmap data"

Perhaps quite a nice addition to the tutorials! Saving and loading custom area data?

My initial idea was having a file and inserting all areas in there and read the data from there; is there a simpler method?

Yea same.. I gotta do that in future since I wanna set custom flags like "is battle possible" and more stuff. Would be very helpful and saves much time.
11-10-2020 12:24 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Dynamic Ambient Music
In my case I create the world terrain completely programatically in the game, so I don't use the world editor / Game.WorldManager, and use custom classes for World/Areas/terrain.
I create/save/load them completely manually, and the data is quite simple, an array like "enum CLIMATE;
CLIMATE map[32][32];"

As for the World Editor, for now storing custom data in its area files is not supported.
11-13-2020 02:09 PM
Find all posts by this user Quote this message in a reply
Dwight Offline
Silver Supporter

Post: #9
RE: Dynamic Ambient Music
(11-13-2020 02:09 PM)Esenthel Wrote:  In my case I create the world terrain completely programatically in the game, so I don't use the world editor / Game.WorldManager, and use custom classes for World/Areas/terrain.
I create/save/load them completely manually, and the data is quite simple, an array like "enum CLIMATE;
CLIMATE map[32][32];"

As for the World Editor, for now storing custom data in its area files is not supported.

Thanks for your explanation!

I think for the case at hand, I will have to check at what area the character is and based on those I will just have to create a table to check what specific data to load from there!

Thanks a lot, this was quite informative and useful!
11-13-2020 08:29 PM
Find all posts by this user Quote this message in a reply
Post Reply