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 kind of value as the property: a number for rotation_degrees, a Vector2 for position. Do not mix it up with "rotation", which counts in radians. 360 radians is about 57 turns.
Challenge
EasyMake the robot spin where it stands.
- Keep the tween, but change the property from
"position"to"rotation_degrees". - Make the end value
360.0and keep the time at1.0.
Press Play: the robot makes one full turn without moving. Then Check.
Try it yourself
extends Node2D
func _ready():
var tween = create_tween()
tween.tween_property(self, "position", Vector2(480, 265), 1.0)
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