How to loop a sound while certain conditions are true?

I’m trying to figure out how I can program a footsteps sound into my game, but I can’t really find any documentation on sound. I already know how I can write conditions that dictate when the sound plays or not, but I don’t know how to tell the program that I want to loop a sound asset while the condition is true, and stop looping it while it is false.

All I’ve managed to do is import the sound file in to the project, given it a name, and after that I’m pretty much clueless. Do I make a variable of some sound class type and then bind the asset to it, and then call member functions to set looping to true/false or something? If so, what’s the name of the class, the member functions, and how do I bind the asset to the object?

All I’ve found so far is just tutorials on how to make different sounds come from different ground types, that base itself on matching the animation of the character. But I have no character model and only one floor type, and I don’t intend to change that, so I pretty much only need to know how to make a sound loop while some simple conditions are true, and stop when they’re false.

Check if this works for you :slight_smile:

That is blueprints, unfortunately. As you can see, I posted this in the C++ Programming section, so what I’m looking for is how to solve this with code.

If you check the documentation of UAudioComponent you have the equivalent:

Play(float StartTime)

and

Stop()

Oh, lovely! I was looking for some reference to all the different components, didn’t think to look in the API part. Thanks, this will probably help for more than the question I asked as well!

You’re welcome, please set the answer as correct to close this question :slight_smile: