First you must ensure that your subviewport share the same world that the parent viewport. You can set that using the function set_use_own_world(bool enable)
of the subviewport object. In case you need to see the current world or do more code magic check the Viewports API.
Then, to keep your node structure, I think you'll have to implement the movement of the camera by yourself. You can do so by moving its position. So, implement code in the Camera and add a function that receives the object it will follow, then you have several ways to get this objects position: You can poll this objects position inside a _process(delta)
function or you can implement a homemade signal into the object, and connect that signal in the camera, getting all the objects movements:
# Code in Minion
signal moved
# Inside in the code, this is where the place where the minions move
move(new_position)
emit_signal('moved', get_global_pos())
Then code in the Camera2D a connection to this signal, and every time the minion moves, the camera will update its position.
# Code in Camera2D
var following = null
func follow_minion(minion)
if following != null:
stop_following_minion()
following = minion
following.connect("moved", self, "followed_moved")
func followed_moved(new_pos):
set_global_pos(new_pos)
Remember to implement code to stop this signal from shooting if you want to move the Camera to another minion or object.
func stop_following_minion()
if following != null:
disconnect("moved", self, "followed_moved")
following = null
I didn't have the time to test this. Tell me if it works, I'll try to squeeze some time to try it out.