Sound Play at Object ?

0 favourites
  • 12 posts
From the Asset Store
Create your own Behaviors in Construct 3 using events! Custom Expressions, Signals & Triggers Behavior Addon Pack
  • Hi.

    I am trying to use the "Audio: Play at Object" plugin but I can't figure out how to properly set it.

    I need the sound to play at Enemy objects.

    When Player is in Enemy range I want to play at 100% volume.

    When Player is moving away from Enemy range I want to reduce the volume and when is far away to stop playing.

    I've added a listener object (Player) but it's not working properly.

    Can anyone explain how can I do this ?

    Here is an example .capx with my attempt:

    dropbox.com/s/tylwuqeoy8l41b4/SoundAndObjects.capx

  • Move "Set listener" to On start of layout.

    Also, you have two enemies with SoundOn=1, so when you play sound at object Enemy, the instance with the lowest UID is selected. That's why the sound is only played from the right. If you need to play sound at each enemy, use "For each" loop and different sound tags.

  • I can't make it work.

    Also, the sound never stops even if I'm far away from the Enemy.

  • You don't hear any change of volume? Are you using headphones? Check condition "Advanced audio supported", maybe your browser doesn't support it.

    With your first example when I set SoundOn=1 for just one enemy, it worked fine for me.

    You can change volume depending on the distance to the player, something like this:

    volume = lerp(-10, -100, abs(enemy.x-player.x)/1000)

  • If you could provide me an example would be much better.

  • Thanks a lot !

  • Hi! Can I have a bit more help here ?

    I need the sound of the enemies to be at max volume when the distance between enemy and player is between 0 and 400.

    If it's over 400 px I need the sound to fade out.

    If you open my example .capx and move the Player to the left enemy you will notice the sound volume works properly.

    If you move to the right enemy you will notice the sound volume will not fade (at right enemy) and it will jump to max volume when the player is in enemy's distance range.

    How can I fix that ?

    Example :

    dropbox.com/s/lel2jtxpa8wvacs/SoundAtObjects_exp2.capx

  • Instead of conditions 5 & 6 you can change the formula to something like this:

    lerp(-0, -100, (max(abs(Enemy1.X-Player.X),400)-400)/1000)

  • It works in terms of distance/volume, but the other think that happens its the same.

    I think I found what could be the issue. If I am placing a few enemies very close to each other and I move the player near them the sound volume is higher than if it where just one enemy.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't know why the positioned audio works like this.

    If I have an object with positioned audio and there's no other object in its range the volume works fine when I move the player(listener) near it.

    But if I have 2 or more objects with positioned audio next to each other the volume is higher than normal, and I think it shouldn't be like this, right ? They should just "mix" and not change their volume.

    Ashley Why is this happening ?

    Also, even if I go far away from an object I can still hear it slowly. I've played with the roll-off factor in the audio Properties tab but couldn't solve this, so I think the option is to add additional events for each sound in the project and set volume in relation with the distance to the Player.

    I've created an example here:

    dropbox.com/s/9rifwrtpjip5yq6/SoundAtObjects_1.capx

  • No the sound should be louder, just like in real life.

    Like you said yourself, I would suggest having the loop playing in the background, and increase and decrease the volume based on the distance to the enemies. But there might be other options.

    I assume you are trying to create something like the radio static in silent hill.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)