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?
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: