- Edited
DaveTheCoder Quotes are only needed when using a string literal, not when using a string variable.
Aha, this did the trick! I removed the quotes and now the function finds the correct mesh in the node path. Here's what I ended up with:
func _keymove(midi_event: InputEventMIDI): #make function point to the correct object based on midi_event.pitch
var key_node = str("KB/") + str(midi_event.pitch)
print (midi_event.pitch)
print (key_node)
print(get_node(key_node))
print(" ")
if midi_event.message == 9:
get_node(key_node).rotation.x = deg*92.5
elif midi_event.message == 8:
get_node(key_node).rotation.x = deg*90
Playing each note now prints an address to the console, something like 48:<Node3D#495870439857> for example, and of course moves the 3D mesh of the correct key.
Thank you all for your ideas, each of which gave me a little insight into various aspects of how this works. I'm thankful to now have this as a handy part of my toolkit!