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
EasyMake the block fall on the left. Set its position to (160, -30) before you add it.
Try it yourself
extends Node2D
var block_scene = preload("res://block.tscn")
func _ready():
var block = block_scene.instantiate()
add_child(block)
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Game Rules
4Spawning
A Packed ScenePlace the New NodeA Spawn FunctionSpawn on a TimerRandom PositionsRandom LanesPractice on your own: Godot playground