Tween Any Property
Part of the Game Feel section of Coddy's Godot journey. Lesson 2 of 23.
A tween can change any property that holds a number, a Vector2 or a Color. Write the property's name in quotes, the same name you use in code: "position", "scale", "rotation_degrees", "modulate".
var tween = create_tween()
tween.tween_property(self, "scale", Vector2(2, 2), 0.5)This makes the node twice as big in half a second.
The end value must be the same type as the property. rotation_degrees holds a decimal number, so write 360.0, not 360. Do not mix it up with "rotation", which counts in radians. 360 radians is about 57 turns.
Challenge
EasyThe robot glides to the pad. Change the tween so the robot stays in place and makes one full spin. Tween rotation_degrees to 360.0 in 1 second.
Try it yourself
extends Node2D
func _ready():
var tween = create_tween()
tween.tween_property(self, "position", Vector2(480, 265), 1.0)
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Game Feel
1Tweens
Your First TweenTween Any PropertyFade OutEase OutOne After AnotherAt the Same TimeA Coin That PopsPractice on your own: Godot playground