Grow With Scale
Part of the Nodes and Scenes section of Coddy's Godot journey. Lesson 12 of 27.
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
Easy- When the game starts, make the robot half its size.
- Then make it grow by 0.5 every second, wide and tall alike. After one second it is back to its normal size, and it keeps growing.
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