Unreal Engine How to stop playing sound which is executed every frame? (BOOL) C++?
Go to solution
Solved by Beesman,
I hope i understood you correctly that want to play a sound once the character enters an area but only when he enters and your problem is it starts playing each frame he is in there.
Well you can check if he is beyond the position each time but only set some play sound bool when the crossing happens.
If you want to play the sound only if he just crossed and is in the area, there are many ways to do that.
Simple example that crossed my mind is to control his being in the area for the last frame and the current one.
fe. pseudo code example:
bool isInArea51(Player player){...} //...function that returns if he is in - if it's just some x boundry probably just x => ??.. void playArea51ThemeSong(){...} //...function that plays the sound (probably in another threat bool wasInArea51 = false; //... //... //The block where your stuff you do each frame happens or the tick of the pawn or w/e { //... If( isInArea51(player) && !wasInArea51)//he is in but wasn't here last frame { playArea51ThemeSong();//probably in another threat dunno if unreals sound playing stuff handles this for you } //... wasInArea51 = isInArea51(player); }
This will work for re-entering the area and will not loop if you stand directly on the threshold.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now