Topic was automatically imported from the old Question2Answer platform.
Asked By
Florix
Old Version
Published before Godot 3 was released.
I would like to have a ball in my game that would be affected by the gravity, however i don’t want that the sprite rotate with the ball because i have a sort of shade effect on it. Thanks
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):
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