Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Play sounds on trigger activation without pausing game?

A topic by Scruffy86 created 38 days ago Views: 163 Replies: 7
Viewing posts 1 to 4

Is there a way to play a sound when walking over a trigger without pausing the game? I have an animated computer panel wall texture and I would like to create a trigger square in front of it, so that whenever the player steps onto this trigger, it will play a computer beeping sound, but not pausing or interrupting the game. 

Create an enemy with a radius, sprite scale, speed, and damage of 0. 

Then, assign the sound you want to sound to the attack sound. 

By having its perform melee, a floor that makes a sound when stepped on is completed.

If you want the sound to play only once, you must either increase the attack delay or use the FSM to make it commit suicide.

Thanks, this might be the way to do it for now since it seems the "official" trigger method is broken.

(2 edits)

jumppad.script
```

//player move [offsetX] [offsetY] [offsetZ]
//sound [name] [path] - loads sound and sets it's name. Path rules are the same as for images.
player move 512 0 512

sound woosh Sounds\09_human_charging_1_loop.wav //- loads sound and sets it's name. Path rules are the same as for images.

keeptrigger
map quickreturn keepsounds3
```

Another approach is to use the map quick return with keep sounds too because that will immediately return back to the player and not lag at all but keep any sounds that are played

Thanks. Still can't get it to work quite right. Two questions: 1. In your script below, do you not need to add "Play sound X after loading/setting the name?

2. Here is my script that won't work: 

SoundComputerPanel1.script

sound RetroComputerPanel Sounds/RetroComputerPanel.wav

play sound RetroComputerPanel

timeout 2

keeptrigger

map quickreturn keepsounds3

In my script, the only way the sound plays is if I have a timeout, which pauses the game. If I don't have a timeout, its true that the gameplay mostly returns immediately, but there is no sound. I want the game to play the sound when I walk on the square, with no interruption or at most a millisecond of interruption while still playing the sound.

Sorry your script looks right to me and unfortunately I can't test it right now. There are keepsounds1,2,3 And I think for maybe try using different versions?

Its almost as if the map quickreturn + keepsounds1/2/3 has a bug in the latest version but I'm not sure. After experimenting with keepsounds 1/2/3, the sounds still only play if I put a short timeout in the game, which really breaks the immersion. This happens even with fairly short sounds. 

(1 edit)

```

//player move [offsetX] [offsetY] [offsetZ]
//sound [name] [path] - loads sound and sets it's name. Path rules are the same as for images. 

auto 1

sound woosh Sounds/jump.wav //- loads sound and sets it's name. Path rules are the same as for images.

play sound woosh

player move 0 0 512


keeptrigger
map quickreturn keepsounds3
```
I just tried with various Versions of the script and I can't get it to work either it might be something worth mentioning in the discord?