Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411582 Posts in 69386 Topics- by 58445 Members - Latest Member: Mansreign

May 06, 2024, 02:28:21 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Small Question in Game Maker
Pages: [1]
Print
Author Topic: Small Question in Game Maker  (Read 1055 times)
ink.inc
Guest
« on: July 06, 2010, 01:09:09 AM »

Right. I've got a bit of a problem in GM 8 and would be eternally grateful if someone could help me out with it.

So I've got a bit of code that plays a sound from a certain object, and adjusts the volume based on distance to the player (louder if close, softer if far).

Quote
if distance_to_object(oAlinaPlayer)>500//the max distance to be able to hear it
{
sound_volume(xBubbleEnergy,0)
}
else
{


Vol=.8
Vol-=distance_to_object(oAlinaPlayer)/1000//increase this if you want the volume to decrease/increase slower
sound_volume(xBubbleEnergy,Vol)
}

This is the problem:



I think it is caused by the volume setting for one object is overriding the volume setting for all the others. Do you guys know how I can deal with this properly?

Thanks,
John Sandoval
Logged
___
Vice President of Marketing, Romeo Pie Software
Level 10
*


View Profile
« Reply #1 on: July 06, 2010, 02:44:17 AM »

Does distance_to_object return a positive or negative result?  If so, try adding abs() into your volume formula.
Logged
ink.inc
Guest
« Reply #2 on: July 06, 2010, 07:29:06 AM »

No, distance_to_object is returning a positive result.

When there's just one instance of this object, it works fine. But when I create another instance of this object (in-game) I can only hear the sound coming from the new instance.

Perhaps this can be solved by using 3d sound? Will test this out.
Logged
ink.inc
Guest
« Reply #3 on: July 06, 2010, 09:07:31 AM »

Never mind; I managed to fix the problem. Thanks though.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic