Rotate a 2D Object to a degree permanent

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Juan Manuel

Hi guys, how are you?

Im working on a Flappy Bird clone and I have a problem. When the bird flap I want it to rotate instantly to a 30 degree angle. It does but it last only a fraction of a second and then comes back to its previous angle. How can I archive that? Here is my code

extends RigidBody2D

func _physics_process(delta):
  if Input.is_action_just_pressed("ui_jump"):

  if (linear_velocity.y > 0):

func _flap():
  set_linear_velocity(Vector2(linear_velocity.x, -200))

func _rotate():

See, the physics engine gets fussy if you directly mess with the RigidBody2D in the wrong way.

Look into the _integrate_forces(state) method that RigidBody2D has.

System_Error | 2020-03-16 16:14