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
Sound Activation
XeOnTricks Offline
Junior Member

Posts: 27
Threads: 12
Joined: Feb 2017
Reputation: 0
#1
Sound Activation

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?


Attached Files
.png   2017-02-24 (2).png (Size: 64.75 KB / Downloads: 145)
(This post was last modified: 02-24-2017, 10:21 AM by XeOnTricks.)
02-14-2017, 01:10 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Sound Activation

First off, you place a ScriptArea into your level at the point where you want the player to walk to activate the sound.

Hop into your script file for the level and add the collide callback between the player and your area.
Check the wiki here for information on all the scripts you can use.

PS: This callback should be within your OnStart() function, so like this:
PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_1""MyCollideFunction"true1);

    
/* 
        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.
    */


Keep in mind that if you already have an OnStart function, don't make another one; instead just add the callback inside the one you have.

Next, you need the function you defined in argument #3:

PHP Code: (Select All)
void MyCollideFunction(string &in asParentstring &in asChildint 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.
    */


Feel free to delete my comments between /* and */.

(This post was last modified: 02-14-2017, 03:58 AM by Mudbill.)
02-14-2017, 03:56 AM
Find
XeOnTricks Offline
Junior Member

Posts: 27
Threads: 12
Joined: Feb 2017
Reputation: 0
#3
RE: Sound Activation

it may be a stupid request but could you show me an example script?
02-15-2017, 11:21 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: Sound Activation

PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_1""MyCollideFunction"true1);
}

void MyCollideFunction(string &in asParentstring &in asChildint alState)
{
    
PlaySoundAtEntity("""scare_wall_stomp.snt""Player"0.0ffalse);


PlaySoundAtEntity found here

Trying is the first step to success.
02-15-2017, 11:29 AM
Find
XeOnTricks Offline
Junior Member

Posts: 27
Threads: 12
Joined: Feb 2017
Reputation: 0
#5
RE: Sound Activation

Thank you Smile
02-15-2017, 10:13 PM
Find




Users browsing this thread: 1 Guest(s)