I’m trying to create the effect similar to The Legend of Zelda for NES in which when the player is in a dungeon and is close to the boss room (in my case, in a certain room which borders the boss room), you can hear the “scream” of the boss so you know they’re nearby, and the scream sound repeats every few seconds until you are a certain distance away or in a room that doesn’t border the Boss Room.
If I loop the sound file on its own, the scream sounds play constantly and don’t have any time in between them. I’m shooting for the scream sound to play every 3 or 4 seconds. Here is the code I tried:
With this code, using a scene timer, I tried to repeat the “Boss_Scream1” sound every 3 seconds. However, when I run the game and enter the appropriate room (Room 14, in this example) no sound plays at all, even after 3 seconds. I’m getting nothing. I also tried changing the Loop option to both yes and no, as well as with Trigger Once and without Trigger Once, and I’m still not getting the sound effect to play at all, let alone repeated every 3 seconds.
I saw a similar forum post from a couple years ago describing a similar issue, and it was though to be a bug which had supposedly been fixed shorty after. So I don’t think this is a bug, but I could be wrong.
Could someone please explain to me why this code isn’t giving me the desired result which I described above? Thank you!
Thank you for your reply. I tried what you suggested (which makes perfect sense, by the way), but I’m still getting no sound. When I set the timer condition to "Timer BossScream < .2 seconds, the sound will play once but won’t repeat (I would expect it to repeat very fast, due to the short period of time before resetting the timer). I’m stumped. Here is the new code I’ve tried, in which the sound will play once, but the timer just doesn’t seem to be resetting after 3 seconds for whatever reason.
It’s like the Trigger Once worked to make the sound play by preventing the timer from being reset immediately, but why isn’t it resetting again after 3 seconds? If I need the Trigger Once in the first block to make the sound play at all, when I reset the timer after 3 seconds, shouldn’t it go back and play the sound again after .2 seconds? I don’t get it…I’m missing something big here.
Instead of checking the room number for every room you could add a boolean variable named something like CanHearBoss to the CameraRoom object. And check it just once. Instead of adding and deleting a timer, you could pause and unpause it. If the sound gets louder as Link gets closer to the boss, you could add a volume variable to the CameraRoom objects and use it for the volume.
You must be right…there must be another event interfering with this code working. I’m lost for ideas as to what it might be at the moment, but I’ll definitely look into it. And thank you for the tip in edit2. That is a very good idea and will probably save me headaches going forward
Keith the the rescue again…lol. Your method makes a lot of sense, giving the room object a variable and just setting it to true for the specific rooms you want the boss scream sound to play in. I can’t believe I never though of that…now I can just have the code you posted one time in the dungeon event sheet rather than having to repeat it for 3 different rooms
I might play with the volume as you suggested later, but I’m happy just having the desired effect working for now. I did have to add another condition to check if the global variable for the boss being dead was true, since if it’s dead it won’t be able to scream
Keith, you continue to be of great help to me along my journey to learn basic game development. Thank you so much my friend!!!