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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|