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
Item pickup trigger sound help
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#1
Item pickup trigger sound help

Hey, sorry for posting so much, just running into a few problems that I can't figure out. I want to make it so when the player picks up a key, a sound is played, but besides using an area near the key to simulate that, I can't see a way to do that.

Also, along the same lines, is it possible to take control of player's camera after the key is picked up and turn them to a closet so a monster can come out kinda thing?

The ones at the front always die first...
06-05-2016, 08:53 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Item pickup trigger sound help

You can use PlayGuiSound() if you don't care where the sound is coming from. If you want the sound positioned 3D in the level, use an area with PlaySoundAtEntity().

You can control the player's view with StartPlayerLookAt(). Just tell it where to look (I recommend script areas) and how fast and such. Remember to use StopPlayerLookAt() or else they will be stuck looking there. Combine these with AddTimer() to have it happen at specific times.

You'll find all the info on the scripts page. Just ctrl-F what you need:
https://wiki.frictionalgames.com/doku.ph..._functions

(This post was last modified: 06-05-2016, 09:47 PM by Mudbill.)
06-05-2016, 09:47 PM
Find
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#3
RE: Item pickup trigger sound help

When I run the game, it crashes and says expected data type. I'm pretty sure my code is wrong, I'll put it here:

void OnStart()
{

AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
AddUseItemCallback("OpenDoor", "LevelKey1", "LevelDoor1", "UseKeyOnLevelDoor", true);
AddEntityCollideCallback("Player", "SpawnScare", "SoundCheck2", true, 1);
AddEntityCollideCallback("Player", "OpenScare", "SoundCheck", true, 1);
SetEntityCallbackFunc("Key", PickUp);
}



void PickUp("Key", "OnPickup")
{
PlaySoundAtEntity("pickupsound", "21_screams.snt", "PickupSound", 0.01f, false);
}


void SoundCheck2(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("ambientsound", "ambience_wind_eerie.snt", "SpawnScare", 0.01f, true);
}

void SoundCheck(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("scaresound", "notice.snt", "Player", 0.01f, false);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

void UseKeyOnLevelDoor(string &in asItem, string &in asEntity)
{

SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}
void OnLeave()
{
SetupLoadScreen("Loading", "LoadScreen1", 0, "LoadingScreen1.jpg");
}

The ones at the front always die first...
06-05-2016, 11:27 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Item pickup trigger sound help

void PickUp("Key", "OnPickup")

This line; you're not supposed to fill in the constructor. Copy and paste the original callback syntax.

06-06-2016, 12:47 AM
Find
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#5
RE: Item pickup trigger sound help

Also, this isn't really related but I didn't want to start a whole thread, but how do I import custom sounds? I took a YouTube link, converted to MP3, and then exported to OGG, but when I put in my script, no sound plays in the level. It's in my custom story folder so I don't know whats wrong.

Oh never mind, got it to snt

The ones at the front always die first...
(This post was last modified: 06-06-2016, 01:19 AM by Xallikk.)
06-06-2016, 01:13 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#6
RE: Item pickup trigger sound help

I also just noticed this line

SetEntityCallbackFunc("Key", PickUp);

is missing a pair of quotes around PickUp. Other than that, what did you mean by your last comment?

06-06-2016, 08:06 AM
Find
Xallikk Offline
Junior Member

Posts: 35
Threads: 7
Joined: Jun 2016
Reputation: 0
#7
RE: Item pickup trigger sound help

Oh that was just me getting the sound to work, kinda worded it weirdly.

The ones at the front always die first...
06-07-2016, 01:32 AM
Find




Users browsing this thread: 1 Guest(s)