Use Script Variable as Replacement for Node Imput Variable

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kayd

So, I’m using the audiostream part of the engine for sound effect playback. However, there’s a catch - I want the sound effect playback noise level to be relative to the distance the player is to an event. I already know how many decibels the audio playback has to drop relative to the distance (normally, the level would drop -6db per doubling of distance, but in Godot +/-3db is a doubling/halving of playback-sound-level when in reality it’s usually 10 db so in this instance it is -1.8db per doubling of distance). So, I incorporated a script into the “amplify” effect on a new audio bus. I am new to Godot, so it’s bad code, and if you have recommendations for that as well please let me know.

Anyway, I’m trying to incorporate the exported script variable “decibels” as a replacement to the original Volume Db variable in the amplify effect in my new audiobus. I’m not exactly sure how to do this.

Recommendations are appreciated.

Here’s the picture/overview of what I’ve done:

P.S. Because I’m new to godot, I’m not really sure how to import playerPosition or how to import the position of the node that the audiostream is a child node of. If you know, that’s also greatly appreciated.

:bust_in_silhouette: Reply From: flurick

Sounds like you might be looking for the AudioStreamPlayer2D :slight_smile:

I just realized that I was using the 3D one and not the 2D. However, now I have a different problem.

How do I set member variables? I can’t set volume_db in the audio bus script because of its status as a member variable.

Kayd | 2018-10-26 21:11