Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Level Editor Help Sounds(5) not working
TimProzz Offline
Junior Member

Posts: 23
Threads: 8
Joined: May 2016
Reputation: 0
#1
Sounds(5) not working

Hello,

I'm making a custom story and somehow I can't put sounds in the map. I can play them at entity but not randomly in the map. I'm talking about sounds on the left side of the editor (Sounds(5)).

For example, I use the sound "critter_rat.snt".
Minimum distance: 1
Maximum distance: 5
Volume: 1

I put the sound in the middle of the map where I can walk but I can't hear anything. I even tried copying the .snt file and all the included .ogg files into my custom story folder and giving it a different name but it didn't work.

Does anybody know how to fix this?

Tim
05-23-2016, 05:32 PM
Find
Darkfire Offline
Senior Member

Posts: 371
Threads: 22
Joined: May 2014
Reputation: 15
#2
RE: Sounds(5) not working

The sound you're using is not what you think. It actually plays randomly from time to time (at least that's what I experienced) and the distance you can set is the distance at which you'll hear it. But it isn't a trigger; if you enter the hearable distance it doesn't necesseary have to play the sound.

To actually do that you have to use some basic scripting.

Use PlaySoundAtEntity (with entity being a script area) triggered by entering an area (AddEntityCollideCallback, entities being the player and the area). You can use the same area for both, or separate if you want the sound to come from a very specific point in space.

If you need more help with the script just say

EDIT: You can see the properties of the sound by opening the .snt file.

Keep in mind that there are sounds that play all the time, in the file the line that states it is Stream="true", I believe. These are for example some water sounds.

(This post was last modified: 05-23-2016, 06:18 PM by Darkfire.)
05-23-2016, 06:12 PM
Find
TimProzz Offline
Junior Member

Posts: 23
Threads: 8
Joined: May 2016
Reputation: 0
#3
RE: Sounds(5) not working

So, if I want a sound to play, I need to use a script area and when I walk into that area it will play the sound at another script area outside the map?

I know how that works but isn't it possible to let a sound play every 30 seconds or so?
05-23-2016, 06:43 PM
Find
Darkfire Offline
Senior Member

Posts: 371
Threads: 22
Joined: May 2014
Reputation: 15
#4
RE: Sounds(5) not working

You can place the script areas at any chosen place.

If you want it to play at a random time then it's the correct tool you're using.
There's just no guarantee that it will play every time.
I just checked and to be able to change the distances you have to uncheck the "default" box. Just sayin because it's easy to miss and I forget about that every time I use it.

05-23-2016, 06:58 PM
Find
TimProzz Offline
Junior Member

Posts: 23
Threads: 8
Joined: May 2016
Reputation: 0
#5
RE: Sounds(5) not working

I was thinking about:

Walk into script area 1.
Script area 2 will play a sound.
Add timer for 30 seconds.
After 30 second you'll be able to walk through script area 1 again to play the sound again.

You think this will work? Or is there an easier way to do this?
05-23-2016, 07:50 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: Sounds(5) not working

Forgive my 6:30am scripting mind, doing this from memory, but try this.

PHP Code: (Select All)
void OnStart()
{
    
AddLocalVarInt("Sound_hasPlayed"0);
    
AddEntityCollideCallback("Player""ScriptArea_1""SoundCheck"false1);
}

void SoundCheck(string &in asParentstring &in asChildint alState)
{
    if(
GetLocalVarInt("Sound_hasPlayed") == 0)
    {
        
AddLocalVarInt("Sound_hasPlayed"1);
        
PlaySoundAtEntity("soundname""soundfile""ScriptArea_2"1.0ffalse);
        
AddTimer("Sound_Check"30.0f"SoundCheckTimer");
    }
}

void SoundCheckTimer(string &in asTimer)
{
    
AddLocalVarInt("Sound_hasPlayed", -1);


Breakdown

In OnStart(), we declare a variable and set it a value of 0, meaning false. We then use this as a check to determine if the sound has played.

When the player passes through a particular ScriptArea, if the sound has not played within 30 seconds ago, it executes code which plays the sound, then sets the variable to 1, disallowing any further playing of the sound. In this code block, we also start a timer.

When the 30 seconds are up as determined by the timer, the variable resets back to 0, then can be played again by walking through the ScriptArea assigned to the collide callback in OnStart(). Because of that "false" argument in the Collide Callback, we can constantly walk through that area and it won't disappear.

What you should change

You'll need to change the ScriptArea which you'll collide with to your Area's name. You'll also need to define which snt to play in the second argument of the PlaySoundAtEntity();, as well as where it will play.

If you want the sound to replay in lesser than 30 seconds, change the timer's "30.0f" value to one which is desired more.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 05-23-2016, 09:54 PM by Romulator.)
05-23-2016, 09:51 PM
Find
TimProzz Offline
Junior Member

Posts: 23
Threads: 8
Joined: May 2016
Reputation: 0
#7
RE: Sounds(5) not working

So if the player walks into the script area, it plays the sounds and sets the value from 0 to 1. If the value is 1 it won't trigger the sound if you walk through the area. After 30 seconds it sets the value back to 0.

I get it now. Thanks. I think I'll be using this a lot. And not just for sounds :)
05-24-2016, 12:53 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#8
RE: Sounds(5) not working

Yep! Variables are pretty useful for conditionals (If-Then-Else) and Loops (For, While, Do). We have plenty of pages on the wiki which are pretty handy at explaining how they work Smile

Good luck with your project, and feel free to ask questions if you have any Smile

Discord: Romulator#0001
[Image: 3f6f01a904.png]
05-24-2016, 03:53 PM
Find




Users browsing this thread: 1 Guest(s)