I have 3 AudioSource
s on my GameObject
"Player"
- for walking sound
- for running sound
- for jumping sound
Is this bad?
I have 3 AudioSource
s on my GameObject
"Player"
Is this bad?
If you have 1-10 instances of this object then no, it’s ok - it shouldn’t affect performance noticeably.
Of course keep in mind that the less components there is = the less memory allocated and less work for the CPU. So still prefer less if you can.
From the perspective of engineering thinking, such a design will make it very painful to modify your functions.
For example, the time has changed, or a new sound needs to be added.
But if the time and the sound to be played are abstracted as parameters, then nothing needs to be changed to meet the above changes.