Grow With Scale
Part of the Nodes and Scenes section of Coddy's Godot journey. Lesson 12 of 28.
scale is a node's size, as a Vector2 of width and height. Vector2(1, 1) is the normal size. Vector2(2, 2) is twice as big, and Vector2(0.5, 0.5) is half.
scale = Vector2(3, 1) # three times wider, same heightScale works on the node and all its children, so the whole robot grows together.
To grow over time, add to the scale on every frame. Use the same number for x and y to keep the shape:
func _process(delta):
scale += Vector2(0.1, 0.1) * deltaChallenge
EasyMake the robot start small and grow.
- In
_ready(), setscaletoVector2(0.5, 0.5), half its size. - In
_process(), add0.5a second toscale, wide and tall alike, withdelta.
Press Play: the robot is back to its normal size after one second, and keeps growing. Then Check.
Try it yourself
extends Node2D
func _ready():
pass
func _process(delta):
pass
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Nodes and Scenes
1Your First Godot Game
What Is Godot?Ready Runs OncePrint in GodotThe Scene TreeSet a PositionMove a Node Once2Every Frame
Process Runs Every FrameDeltaPixels per SecondMove DiagonallySpin With RotationGrow With ScalePractice on your own: Godot playground