Jump to content

Sound Volume at Stop() smoothly to 0


Slastraf
 Share

Recommended Posts

function Script:UpdatePhysics()
Script.H=false
Script.count = 100
...
if H == true then
self.Stop()
end
end
function Script:Stop()--in
H=true
local t = Time:GetCurrent()
local bb = 500
if self.count[insert or modify code here] then
if t == t+bb then
bb=bb+t49
count = count -0.01
self.source:SetVolume(count)
end
else
self:Disable()
H=false
end
end

This code is a modified noise script.

This code doesnt work, I have a trigger at my map that uses Stop() with the flowgraph .

So when I touch the trigger with the fpsplayer the pivot with this script attached the program crashes and says attemt to index local self ( a null value ) at the line marked.

Is there an easyer way of just doing this without the timer that i didnt knew yet or does someone got a fix for this ?

Link to comment
Share on other sites

well there is a problem that you call stop once then use the stop function for the count. Unless you are calling stop more than once you will never "count". if you do call stop more than once you are setting local bb every count. try something like this.

 

add a Script.stop to the variables at the top.

 

change the stop function to this

 

function Script:Stop() --in

self.stop = true

end

 

then in UpdateWorld add something like

 

if self.stop == true and self.volume > 0 then

self.volume = self.volume -1

self.source:SetVolume(self.volume)

end

 

so in this example the stop only changes a bool that triggers the UpdateWorld passes to start counting and lower the volume. UpdateWorld is looped constantly so this will now count as opposed to the stop function which only runs through once when called.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...