Tween interpolate Node2D scale and rotation?

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

I’m making a sprite hover in place, so I Tween it’s position, but I also need to tween the scale and rotation.

This is the tween for the movement. Tween node is called move_tween.

func move(target):
	var move_tween = get_node("move_tween")
	move_tween.interpolate_property(self, "position", position, target, 3, Tween.TRANS_QUINT, Tween.EASE_OUT)

And then I call this tween from a Timer

  func _on_Timer_timeout():
        var x = rand_range(-130,130)
         var y = rand_range(-130,130)
	  var r = rand_range(-5,5)
	  get_node("Node2D").move(Vector2(x,y))

var r is supposed to be rotation angle, and also I need scale - but how?
And do I need additional Tween node, or can I use the same move_tween?
Or can I use lerp instead?

:bust_in_silhouette: Reply From: kidscancode

Tween can interpolate as many properties as you like. Add another interpolate_property() line right after the first one, targeting the "rotation" property.

I tried it, and added that line, and then I called it like that

func _on_Timer_timeout():
	var x = rand_range(-130,130)
	var y = rand_range(-130,130)
	var r = rand_range(-5,5)
	get_node("Node2D").move(Vector2(x,y))
	get_node("Node2D").rotate(r)

The sprite doesn’t rotate smoothly, it just jumps around.

verbaloid | 2020-04-19 06:07

Why are you calling two different functions? That’s not at all what I suggested.

kidscancode | 2020-04-19 06:46

Okay, I get it, I need to call .move but where do I put the rotation degree into this line?
get_node(“Node2D”).move(Vector2(x,y))

verbaloid | 2020-04-19 10:38

You’re passing the position to move(), also pass the rotation:

get_node("Node2D").move(Vector2(x,y), r)

Then make sure that move() accepts it:

func move(target, rot):

kidscancode | 2020-04-19 17:43

Thank you so much!!

verbaloid | 2020-04-20 05:39