Hey, so I’m a total rookie and made this account just to ask this question since I can’t find anything online and I’m having trouble figuring it out myself. How would I go about checking multiple enemies for their states and then playing music if at least one is in a chase state? Thank you.
You can mark your enemies in a group to find them as a collection later in code.
Though it sounds more like you should have a global/autoload music manager so you can increment and decrement “aggressive” enemies and play specific music when there are more than zero aggressive enemies.
I assume you have a script that toggles enemy ‘chase’ state on/off?
If so:
When an enemy is switched to the ‘chase’ state, make the same script start the music.
Add enemies to an array when they chase the player, or use a variable to count how many are chasing.
When your code makes an enemy stop chasing the player (e.g. it dies, or the player gets too far…), remove the enemy from the array or decrement the variable by 1. If the array is empty or the variable is 0, stop the music.