generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: how to play music in certain areas?

Previous Thread :: Next Thread 
patias is not online. patias
Joined: 18 Sep 2012
Total Posts: 31
02 Nov 2016 10:18 PM
I know there's a way to do this, as in when you pass through a part and music plays, But are there any more accurate methods so you can play music in certain areas? An example would be how open world RPG's have it to where you can leave a certain area in any direction and it plays the different types of music.


Report Abuse
patias is not online. patias
Joined: 18 Sep 2012
Total Posts: 31
02 Nov 2016 10:22 PM
like making a zone script that detects players in the area, plays music for them, once player is outside, music volume goes down and music is muted for that player.


Report Abuse
membra is not online. membra
Joined: 14 Oct 2008
Total Posts: 6313
03 Nov 2016 03:40 AM
Use a Region3 to define the space that a player must be in to hear the music. You can then use the FindPartsInRegion3 function to find out which players are currently in that space.
Report Abuse
Sen_Takatsuki is not online. Sen_Takatsuki
Joined: 07 Aug 2013
Total Posts: 673
03 Nov 2016 03:49 AM
Or you could just use a part.. And check if the player is within the parts boundaries.
Report Abuse
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
03 Nov 2016 04:02 AM
Having triggers (invisible, nonsolid parts) that change the music when a player touches them is by far the easiest way I can think of. That, or having a different universe place for each location in the game world, and then just playing a single piece of music per place.

Other than that I think the only other way is to use maths to decide which area the player is in. The simplest form would be to have a part at the center of each area, and then just compare the distance between the player and all those parts to find the nearest. But that might give problems if your areas are not at least somewhat circular in shape.

Then you could put parts at the lower and upper corners of each area and then use Region3 to check if the players are inside the area, but that has similar problems because Region3s are always AABBs, so the areas in your game have to be somewhat rectangular, and always aligned with the world axes. It'd look like this: i.imgur.
#################### sure you see the issue with this way of doing it.

The last method I can think of is to use "real" collision detection. Bounding box (not axis aligned) detection might be enough for your needs, and would be pretty easy. But the most flexible way is probably to use collision detection that works with concave polygons. This *still* has the limitation that you can't have one area on top of another, but other than that you have complete freedom to make your areas have weird shapes. Of course it's a lot more complex too, but you might be able to find a library somewhere. It'd look something like this: i.imgur.
###################### in all I suggest using part triggers. Make them fairly thick (I'd go with 10 studs), and make sure that the players can't go over or around them. You're not really getting anything by using all the much more complicated ways of doing the same thing. You could also have several ######## per area, of different sizes. This will let you better approximate the actual shape of your areas. Like so: #########################
Report Abuse
direMitten is not online. direMitten
Joined: 18 Jun 2015
Total Posts: 1294
03 Nov 2016 04:04 AM
Here are the censored links, in order of appearance:

i.imgur.
com
/djVovpe
.png

i.imgur.
com
/bsEJ72O
.png

i.imgur.
com
/dI2C9KN
.png
Report Abuse
Exfiltrate is not online. Exfiltrate
Joined: 29 Mar 2013
Total Posts: 10917
03 Nov 2016 09:30 AM
24
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image