2020-02-12 21:15:24

Hello guys,
I have a question about SoundPool and playing things on a map.
I was wondering, is there a way I can make the sound move along with what it is assigned to?
For example, let's say I have an enemy, and  taunts you. The enemy will move, but the sound will finish playing even after the enemy has moved from that position.
If I made it say, "die suckas!", it may say "die," but by the time "suckas" is spoken, the enemy is already gone from that position.
So my question is, do I need to update the sound to move with the enemy, and how do I do so, by updating listener 1d?
Thanks.

To be my friend, you must spin around, oscillate around my head, flip flop and fleep across my room, rotate vertically in mid air, bark like a doggy, bleet like a goat, nay like a horse, honk like a donkey, oink like a pig, bawk like a chicken, pop like a balloon, jump like a monkey, fall diagonally like a bird, spin cylindrically like a tornado, and finally drop onto the ground.

2020-02-12 21:46:18

look at moving_sound_handles in bgt includes of carter temm
may it helps you

Thumbs up

2020-02-13 04:14:54

That included will not really answer his question. It is designed to be used in an online game, not a simple map.
To answer your question, you must use the update sound method. You will only update the listener if the listener coordinates change, such as when the player moves. You will not use the listener if the player is stationary, as the coordinates for it will always stay the same.  Keep in mind, you will only call the update sound method when the coordinates of your object change.  You should not, for example, stick a call in the loop somewhere where it will be constantly used, as your enemy will only move once every quarter of a second or so.  Sticking it in a place where it is constantly being fired will eventually cause your game to become slow and clunky as you add more enemies to the map, remember, every time we look through the enemies we call their update sound function. To clarify, you should not do so.  Only call the update functions when necessary.

Coding is not hard. No, not at all.
What is hard is making code that accepts different and sometimes unexpected types of input and still works.
This is what truly takes a large amount of effort on a developer's part.

Thumbs up

2020-02-13 12:57:41

Aha, thanks amerikranian. I will attempt what you suggested.

To be my friend, you must spin around, oscillate around my head, flip flop and fleep across my room, rotate vertically in mid air, bark like a doggy, bleet like a goat, nay like a horse, honk like a donkey, oink like a pig, bawk like a chicken, pop like a balloon, jump like a monkey, fall diagonally like a bird, spin cylindrically like a tornado, and finally drop onto the ground.

2020-02-14 11:56:28

I agree, it was amusing how my zombies would be a half a headphone stereo field away by the time they'd finished growling - xd

It is not strength or talent, but courage and persistance that bring reward and happiness.
-Rory Michie, 2020