If you want to allow the RigidBody2D
to rotate, but want to keep the sprite upright at all costs, you can just rotate the sprite in the opposite direction. Sample script (assuming it is run on the RigidBody2D
, and the sprite is a child of it):
var sprite
func _ready():
sprite = get_node("Sprite")
set_process(true)
func _process():
sprite.set_rot(-get_rot())
Also, for a nicer effect, you can have one multiplicative Sprite
for the shadow (which you keep upright), and another Sprite
for the texture, that would rotate with the RigidBody2D
. In this case the node tree would look like so:
ball (RigidBody2D)
-- shadow (Sprite) # You would use this one in the code above
-- texture (Sprite) # Leave this one to rotate