Detecting Sound Radius

TouchTiltGamesTouchTiltGames Member Posts: 1,162
Hey guys, I am looking for a tutorial or video tutorial or..template on sound radius.
As you get closer to an actor the sound gets louder, as you move farther away it gets quieter.
Cheers!

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Create an attribute called game.soundDistance (real). Create two integer attributes (soundSourceX and soundsourceY). Constrain these to the x and y of the source of the sound. In the moving character constrain game.SoundDistance to magnitude(self.positionX-game.soundsourceX, self.positionY-game.soundsourceY).

    Now you can put game.SoundDistance in the expression editor of the play sound behavior. If you just set the volume to that attribute it will be the opposite of what you want (i.e. louder the farther away you are) so you will need to have some number (experiment with it) divided by game.sounddistance.

    good luck! Sounds very interesting!
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Cheers Sci! I will give this a go!
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    "so you will need to have some number (experiment with it) divided by game.sounddistance."
    How would I write this? I have game.soundDistance /2
    Is that correct?
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Yeah I think this is a bit beyond me...

    On my actor that plays the sound I have:
    Game.soundSourceX to: self.positionX
    Game.soundSourcey to: self.positionY

    In the PlaySound behaivor I have Game.SoundDistance in the Volume.

    In the moving actor I have:
    Constrain: Game.soundDistance to: magnitude(self.positionX-game.soundsourceX, self.positionY-game.soundsourceY)

    Not sure this is working properly..hehe.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    made a demo for you


    search "closer to sound"
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Ah nice thanks a lot!
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Ok so how does one download templates now on the new site? I havent downloaded any since the ol' days of right clicking on the link and saving as...
Sign In or Register to comment.