Can I change the default size of an object like rigidbody2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nichefect
:warning: Old Version Published before Godot 3 was released.

Because changing the size in the editor will scale down any child like a sprite, I’ve found that I have to scale the sprite up to make everything even. Can I set the default size of a rigidbody2D object?

:bust_in_silhouette: Reply From: SupToasty

RigidBody2D nodes update their transform constantly, as it is generated by the simulation from a position, linear velocity and angular velocity. As a result, [STRIKEOUT:this node can’t be scaled]. Scaling the children nodes should work fine though.

Link to the Documentation site where I got this from.
This is probably a reason for why they added the multi edit tool.

:bust_in_silhouette: Reply From: sergey

Indeed as pointed by SupToasty RigidBody2D will always scale to it’s original size (1). The work-around I use is rewriting set_scale of the RigidBody2D node:

func set_scale(scale):
	# Override behaviour only if it is a RigidBody2D and do not touch other nodes
	if self extends RigidBody2D:
		for child in self.get_children():
			if not child.has_meta("original_scale"):
				# save original scale and position as a reference for future modifications
				child.set_meta("original_scale",child.get_scale())
				child.set_meta("original_pos",child.get_pos())
			var original_scale = child.get_meta("original_scale")
			var original_pos = child.get_meta("original_pos")
			# When scaled, position also has to be changed to keep offset
			child.set_pos(original_pos * scale)
			child.set_scale(original_scale * scale)
	else:
		.set_scale(scale)