Download

How to Get Variable from String

Hello, I was hoping someone might be able to help me figure out how to get a variable from a string. Basically, I have a string that matches the name of a sound file variable, so I want to plug the string into the ‘Play Sound 2D’ node. Any advice on how to go about this would be greatly appreciated!

Can you use the sound file variable instead of the string with its name? Or, if you are okay with hard-coding it in, you can just “Select asset” manually in that Play Sound 2D function, as long as you have the sound file you need in your project you should be fine.

I don’t think there is a way to find a variable by its name through a string, and if there is, it probably wouldn’t be considered a good practice (not to mention you’ll most likely have to implement it from scratch)