Have you tried var cylinder = get_node("Cylinder/Lead_" + str(turn))
?
One reason why the code you posed above is not working, is because you are not getting the node, but instead creating a string. If you want to use cylinder.play()
then you need to get the AudioStreamPlayer3D
node into the cylinder
variable so you can call functions on it (in this case, the play
function).
I could be wrong (I do not use the $
shorthand), but I think the reason $Cylinder/Lead_1.play()
is not working is because $
is trying to get a child node in Cylinder
called Lead_1.play()
, as opposed to getting a child node in Cylinder
called Lead_1
and then calling the play
function.
In theory, the following should work (though as I said, I do not use $
): $"Cylinder/Lead_1".play()
or get_node("Cylinder/Lead_1").play()
If neither of these work, could you post the error message Godot prints to the debugger? It would make it easier to help find a solution to the problem.