Rotate and change position at the same time
-
Hello, fellow developers!
I've been playing a bit with Godot this month, and I'm a bit confused by this:
I've got a RigidBody2D with a Polygon2D and a CollisionPolygon2D. I set the gravity to 0 so it doesn't fall down, and I try to make it move and turn at the same time.
So, I attach a script to it and I try something like this:
func _process(_delta): linear_velocity += Vector2(5, -5) global_rotation_degrees -= 5
The result is a shape that rotates but doesn't change position. If I only use the "linear_velocity" line, it moves just fine, if I just use the "global_rotation_degrees", it rotates just fine, but it seems I can't get the RigidBody2D to do both at the same time.
I can do something like this:
func _process(_delta): position += Vector2(5, -5) global_rotation_degrees -= 5
And I get the node to move, but then I can't use the physics engine and have to do everything by hand, and nobody wants that.
Am I doing something wrong? Is that a limitation of the engine? Is it a bug? How could I get the node to do both?
Thanks!
-
Rigidbodys, arent really made for custom physics, I suggest using characterbody. You could also try changing your rigidbody mode to character, I dont know if it still works in godot 4