XP How to make BGS play when you're near an event? And no BGS when you move away?

Hi all, I have a sprite of 2 people swordfighting, and I'd like to make it so that when the player approaches that particular moving sprite/event, BGS of swords clanging/swooshing would play, and vice versa, when the player moves away, the BGS stops (I don't want to make it the overall BGS of the entire map because honestly that'll make me go mad lol).

I found Heretic's Super Event Sensor, and I've read through it, but it was mostly used for enemies and such. I couldn't quite figure out how to adapt it to what I mentioned above (Not sure if it's doable... or maybe I missed something because it's 1.30am here and my brain's fried xD)

Please and thank you in advance <3
Hello, just so you know, by default there can be only one BGS at the time so using a swordfighting BGS will take over the map's BGS, if you have another BGS running, maybe simulating the swordfight can be done with SE.



Regarding your position detection, what you could is set a parallel event that checks the player's position, when it's close to your battling sprite/event, you can then run some sounds (or start a BGS), and when it is too far, the sounds disappear.

Here is an example:
1763057549952.png

Assuming that the fighters are an event with id 4, whenever the player is close to them (by 5 tiles), I activate a switch and start the sound, and when the player gets far away, I deactivate the switch and stop the sound.

I used a tiny script because it makes me use less instructions but you can also use event calls to get the player or event's positions and do the maths:
Ruby:
p = $game_player
ev = $game_map.events[4] #swords
dist = (p.x - ev.x).abs
dist += (p.y - ev.y).abs
$game_variables[1] = dist

Here is the event call that you can use to get a character's position on the map:
1763057766617.png

Can be seen used in this demo

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-bgs-play-when-youre-near-an-event-and-no-bgs-when-you-move-away.181009/