Menu
CoddyTech

Place the New Node

Part of the Game Rules section of Coddy's Godot journey. Lesson 17 of 29.

A new block starts where its scene puts it. block.tscn places it in the middle, above the screen.

The new block is a node like any other, so set its position before you add it:

var block = block_scene.instantiate()
block.position = Vector2(500, -30)
add_child(block)

Write block. in front of position. A bare position belongs to the node the script is on, here Main. Moving Main moves the whole game.

challenge icon

Challenge

Easy

Make the block fall on the left.

  1. In _ready(), set block.position to Vector2(160, -30).
  2. Do it before add_child(block).

Press Play: the block drops in from just above the screen at x = 160. Then Check.

Try it yourself

extends Node2D

var block_scene = preload("res://block.tscn")

func _ready():
	var block = block_scene.instantiate()
	add_child(block)

All lessons in Game Rules

Practice on your own: Godot playground