0 votes

I am successfully rotating a node to mouse position by tweening.
After the rotation tween finishes, I want to use a second tween to move the node to mouse position. The ontweencompleted function gets called, "rotation_degrees" gets printed, but not "Rotation ended". Why? What am I missing?

func rotate_tween(target_position: Vector2):
  var angle_to_target: float = rad2deg(parent.get_angle_to(target_position))

  tween.interpolate_property(
        parent, 
        "rotation_degrees", 
        parent.rotation_degrees, 
        parent.rotation_degrees + angle_to_target, 
        1.0, 
        Tween.TRANS_LINEAR, 
        Tween.EASE_IN_OUT)
  tween.start()

func _on_tween_completed(object, key):
  print(object, key)
  if key == "rotation_degrees":
    print("Rotation ended")
Godot version 3.3.2.stable
related to an answer for: On_tween_complete parameters
in Engine by (32 points)

1 Answer

+1 vote
Best answer

The correct code is:

if key == ":rotation_degrees":

I missed ":"

by (32 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 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.