That's what I trying to do right now. I'm doing this:
for body in get_tree().get_nodes_in_group("bodies"):
if body is RigidBody2D:
create_physics_puppet(body)
body.queue_free()
func create_physics_puppet(body):
var body_pos
var body_rot
var body_collision_scale
var body_collision_shape
var body_sprite_texture
body_pos = body.position
body_rot = body.rotation
for child in body.get_children():
if child is CollisionShape2D:
body_sprite_texture = child.get_child(0).texture
body_collision_scale = child.scale
body_collision_shape = child.shape
var new_body = KinematicBody2D.new()
var new_body_collision = CollisionShape2D.new()
var new_body_sprite = Sprite.new()
get_node("ShootingRange").add_child(new_body)
new_body.add_child(new_body_collision)
new_body_collision.add_child(new_body_sprite)
new_body.position = body_pos
new_body.rotation = body_rot
new_body_collision.scale = body_collision_scale
new_body_collision.shape = body_collision_shape
new_body_sprite.texture = body_sprite_texture
For some reason only two of these new kinematic bodies are showing up in-game. They all show up in the remote scene tree though. I turned on visible collisions just to see if the sprites were messed up, but that wasn't it. Browsing through the kinematic bodies in the remote scene tree, they all seemed to have reasonable transforms.