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.

-----
YouTube
GitHub
Discord: @tunmi13#1880

2020-02-12 21:46:18

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

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.

2020-02-13 12:57:41

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

-----
YouTube
GitHub
Discord: @tunmi13#1880

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