Fair Distance

Get help using Construct 2

Post » Mon Apr 15, 2013 7:52 pm

If you are using this expression to determine the volume:

System every tick -> Set volume(-distance(player.X, Player.Y, Sound.X, Sound.Y)/10 dB)

and you want the volume to be affected by the size of the sprites, why don't you subtract half the width of the sprite from the distance. Something like this:

System every tick -> Set volume((-distance(player.X, Player.Y, Sound.X, Sound.Y)-(sound.width/2))/10 dB)





B
44
S
13
G
7
Posts: 338
Reputation: 10,389

Post » Mon Apr 15, 2013 8:07 pm

[QUOTE=R0ller] Well... The good news - it's works. Alot of really cool sound staff in new version. But it's works only in Chrome... [/QUOTE]

Oh, i was a little blinded by cool staff there. But generally "play at object" doesn't solve the problem, becouse it still working around origin point. And also it makes panning sound around that point.
So, i still hear sound from center of the object, not from whole object..

It's like we have a river, but sound of water going just from center of it.
B
4
Posts: 13
Reputation: 376

Post » Mon Apr 15, 2013 8:34 pm

[QUOTE=zatyka] If you are using this expression to determine the volume:

System every tick -> Set volume(-distance(player.X, Player.Y, Sound.X, Sound.Y)/10 dB)

and you want the volume to be affected by the size of the sprites, why don't you subtract half the width of the sprite from the distance. Something like this:

System every tick -> Set volume((-distance(player.X, Player.Y, Sound.X, Sound.Y)-(sound.width/2))/10 dB)

[/QUOTE]

Well, i get the idea but i'm too stupid to make it work...

System every tick -> Set volume((-distance(player.X, Player.Y, Sound.X, Sound.Y)+(sound.width/2))/10 dB)

Something like that works nice, if the object is square. But if it's not?... Player can come to the object from any side. And the object isn't square.
B
4
Posts: 13
Reputation: 376

Post » Mon Apr 15, 2013 8:41 pm

It's more like the object is a circle, with the radius of the circle being half the sprite's width. I can see this possibly being a problem if there is a huge differences between the sprite's width is the sprite's height. If that's the case, you might want to consider adding a few image points around the sprite, and setting the sound volume based on the distance between the player and the sprite's closest image point. However, if your sprite's width is remotely close to its height, this shouldn't be necessary.
B
44
S
13
G
7
Posts: 338
Reputation: 10,389

Previous

Return to How do I....?

Who is online

Users browsing this forum: selaus and 0 guests