Actually, it works the same, because CsoundUnity is essentially an AudioSource. I just tried it here and it works without any problems. I setup a cube to be a CsoundUnity object, and placed a sphere that has an AudioListener attached. As I move the two closer together I hear both doppler and volume changes. Don’t forget to set the Spatial Blend settings to 3D.
This should also work. For example:
public Transform soundingObject;
void Example() {
if (other) {
float dist = Vector3.Distance(other.position, transform.position);
csoundUnity.setChannel("gain", dist);
}
}
And you might have something like this in your Csound code:
instr 1
aOut oscili chnget:k("gain"), 400
outs aOut, aOut
endin
You’ll probably need to scale the distance value so that it’s between 0 and 1. And you should probably use an exponential scaling factor so that it behaves somewhat like it would in the real world.
Hope this helps.