![]() |
sound playing in area - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: sound playing in area (/thread-21846.html) |
sound playing in area - 39Games - 06-16-2013 I have a little water setup and when a player is inside an area at the bottom i want the game to play a sound that loops, and when the player leaves, the sound stops. Whats the code for that? Cheers RE: sound playing in area - PutraenusAlivius - 06-16-2013 I don't get it. What you're meaning. EDIT: At the part where the Player loops. RE: sound playing in area - 39Games - 06-16-2013 (06-16-2013, 10:45 AM)JustAnotherPlayer Wrote: I don't get it. What you're meaning.Oops, fixed RE: sound playing in area - PutraenusAlivius - 06-16-2013 Code: void OnStart() RE: sound playing in area - 39Games - 06-16-2013 it crashed at Code: else if RE: sound playing in area - ExpectedIdentifier - 06-16-2013 (06-16-2013, 11:06 AM)39Gamer Wrote: it crashed at Just use else, not else if. RE: sound playing in area - 39Games - 06-16-2013 (06-16-2013, 11:11 AM)sonataarctica Wrote:i experimented and this code appears to work, thanks for the rest of the code(06-16-2013, 11:06 AM)39Gamer Wrote: it crashed at ![]() Code: void OnStart() RE: sound playing in area - Adrianis - 06-18-2013 Just wanted to offer a quick explanation - when you use if...else statements, it ensures that only one of the pieces of code will run (i.e. the code in the 'if' or the code in the 'else'). That applies to if... else if statements as well (the 'else if' is for checking another condition) However, when you use 'if' and then another 'if' instead of an 'else', it is possible for the code for both if's to run. This can create some nasty bugs if both of your statements turn out to be true (impossible in this example, but very possible elsewhere) It is therefore much more secure to use this method in the future Code: void PlayerCollideSound(string &in asParent, string &in asChild, int alState) This way, you can always be absolutely certain that ONLY PlaySoundAtEntity OR StopSound will be executed, never both. Again, not so important right now but I thought it might help you out in the future ![]() |