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,

1 Like