02-14-2017, 01:10 AM
i was creating a custom story and i ran into a problem being fairly new. idk how to activate a sound upon walking through a scripted area, also what would be the Script for activating a sound?
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "MyCollideFunction", true, 1);
/*
The first two arguments here define the two entities that should collide.
Make sure ScriptArea_1 matches the name of your script area in the level.
MyCollideCallback can be whatever you want;
it is the name of your function that will run when the two entities collide.
The "true" means this only happens once, and 1 means when you enter the area.
*/
}
void MyCollideFunction(string &in asParent, string &in asChild, int alState)
{
/*
This function will run when Player hits ScriptArea_1.
There are 2 main functions you can use to play sounds.
If you want it to play from a source in the level, use PlaySoundAtEntity.
If you just want to play it and don't care, use PlayGuiSound.
I'll let you try that one yourself. Look those two functions up on the wiki I linked and put them here.
*/
}
void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_1", "MyCollideFunction", true, 1);
}
void MyCollideFunction(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "scare_wall_stomp.snt", "Player", 0.0f, false);
}