I want to know how to reduce the sound as the distance between two objects in the script is farther.

Hello. I have a question about script code.

First of all, what I’m going to do is take a 3D drone model, put a person at the starting point, and as the drone moves away from the person, I’m going to lower the volume.
(Note, I know how to adjust the volume.)

So I think we should figure out how many meters away people and drones are, and adjust the sound according to the interval.
For example, if a drone is very far from a person, I will make a sound of 1, and if it is very far, I will make a sound of 0.01.
(Use the map function used in c language to form a sentence like “val=map (val, 0, 100, 1, 0.01)”. But in Java,
The map function had a different meaning from the c language. I wonder what function Java should use.)

I also want to know how you can figure out the distance between an object and an object.

I’m going to look at the index on the site one by one and make code.

Please help me write the code.
(Sorry for the long text…)
If the way I’m trying to do it is foolish, please give me another good idea.
You may not understand the language using the translator…I’m sorry.
Please give me an answer. Thank you!

Hi @11161,

There is no volume control blocks in CoBlocks, but you could set volume using typescript:

You could use Time.scheduleRepeating function to check the distance to the drone and adjust volume regularly.

Hope that helps!

Thank you!
I’ll refer to it.

Actually, this is a good point - is positional sound on the roadmap? It would be a great addition, and easily attached to Items.

Many thanks,


Positional sound is something that should be added…

Can you show an example?

I found out how to do it.

1 Like

Nice work @Blazifying! FYI, you can do away with the READ script - no one except PRO users will see it, as you can only remix with PRO. You could also remove your 1st distance var initialisation if you wanted.

I’ve remixed and set a min/max distance, with a linear increase between the two:

It would be interesting to see what an exponential curve increase sounds like - easings for sound.

1 Like