Playing Sound at Every Instance of an Object

Just started using Construct 2? Post your questions here

Post » Thu May 05, 2016 7:45 am

Hi everyone!

Been playing around with positional sound lately and have a small problem.

I want to play a positioned sound at an enemy object. As the enemy draws near, the sound grows louder, and as the enemy disappears into the distance, the sound fades too. This is pretty straightforwad to do with the "Play audio at object" action.

The problem is, it plays the sound only at the first instance of the enemy object. For example, if I have four enemies on the layout, only the first one makes the sound and the other three are silent.

Is this at all doable with the "Play audio at object" or do I have to do this some other way? I can't find anything in the manual about this and there doesn't seem to be any tutorials concerning positional audio.

If anyone could nudge me in the right direction, I'd be grateful. Thanks!
B
5
Posts: 7
Reputation: 262

Post » Thu May 05, 2016 9:27 am

How do you currently let them make sounds ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu May 05, 2016 11:31 am

99Instances2Go wrote:How do you currently let them make sounds ?


On start of layout -> Play (Enemy sound) looping at object (Enemy)

Works perfectly if you only have one instance of Enemy, but I can't figure out how to extend this to other instances of the same object.
B
5
Posts: 7
Reputation: 262

Post » Thu May 05, 2016 2:34 pm

Here is a capX that works nicely.

https://drive.google.com/open?id=0B1SSu ... ThyM0JFb0k

It will not work in an 'on start of layout' if you created the objects in it & tried to pick them also there also .. in the 'for each loop'. But that has nothing to do with the audio plugin. You just cant pick newly created objects before the next top-level event.

It wil not work if your sounds are in the 'music folder'. See browsers limitations in the manual.
https://www.scirra.com/manual/109/audio

I used a timer to hear the sounds individual and to stop/start them in one event. The wait action is not a good option. For the same reason i gave them tags.

Click an object to start/stop an engine. Press numpad 0 - 3 to choose a 'car' to be able to steer it.

Hope this helped you some.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri May 06, 2016 10:13 am

This was extremely helpful, thanks yet again!

I realized my mistake was omitting the "For each" condition. With your example I got it to work flawlessly.
B
5
Posts: 7
Reputation: 262


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests