Ok, then indeed solution provided by @gentlemanhal in this post should satisfy your requirements.
You just need to convert it to C# unfortunately, or you can always use GDScript for this one script - Godot allows to mix C# and GDScript together within the same project.