[SOLVED] Sound component. One or several?

For example, I have players on the map.
Each player can make different sounds: footsteps, shots, etc.

Is it correct to use multiple Sounds on the same entity?
Player
–SoundWeapon
----SlotShot
----SlotReload
–SoundFootsteps
----SlotFootstep0
----SlotFootstep1
----SlotFootstep2

Or should there be one Sound source per entity?
Player
–Sound
----SlotShot
----SlotReload
----SlotFootstep0
----SlotFootstep1
----SlotFootstep2

The question is related to the fact that when changing weapons, their sounds will also change.
And, for example, if the sounds of steps will be along with the sounds of weapons, then it will be necessary to constantly delete and create sound slots.

P.S. And another question, will separate memory be allocated for the same sounds of each instance of the player, or will one sound, for example steps, be downloaded and will be used for all players?
After loading to the scene, the sound will be used by all Sounds?

Having multiple sound slots or sound components is fine. The actual resources used for sound in the browser is only allocated for sounds that are currently playing.

How you want to manage this is up to you, there isn’t really a single ‘right’ way

As I understand it. The sound is downloaded from the server, played, and left in memory to be used again. Remains in memory until the object is destroyed?

Is the same instance of the sound in memory used by other entities also when playing? No duplication of sound samples in memory?

The actual sound is an asset. If it the sound is marked as Preload, it is loaded on startup up. If it isn’t, then it needs to be loaded by the game before being used.

I think there is some logic that if it’s referenced in the scene by a sound component when the scene is loaded, then an asset load is triggered.

It will remain loaded until the asset is unloaded.

The sound slots reference the asset. So even if 5 different entities are referencing the same sound asset, that one asset is loaded.

1 Like

Thanks for the information.