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?
look at moving_sound_handles in bgt includes of carter temm
may it helps you
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.
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.
Aha, thanks amerikranian. I will attempt what you suggested.
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
-Rory Michie, 2020