Menu
CoddyTech

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 height

Scale 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) * delta
challenge icon

Challenge

Easy

Make the robot start small and grow.

  1. In _ready(), set scale to Vector2(0.5, 0.5), half its size.
  2. In _process(), add 0.5 a second to scale, wide and tall alike, with delta.

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
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Nodes and Scenes

Practice on your own: Godot playground