+2 votes

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

in Engine by (49 points)
recategorized by

2 Answers

+5 votes

set the rigidbody to Character mode

by (580 points)
can confirm this
+3 votes

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")
func _process():

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
by (1,594 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.