Godot 4.2 stable script problem
Asked Answered
A

2

0

Hyy guys I am learning godot, I was watching an tutorial on YouTube he was using godot 3
And I am using godot 4.2 stable.
Is used code in my scene, and then run my project but it's not running, getting stuck on logo of godot, even not getting any error 🥲
After removing script it's working fine.

This is script

@onready var card = preload("res://card.tscn")

func _ready():
create_vboxes()

func create_vboxes():
var x = $VBoxContainer/PanelContainer/ScrollContainer/VBoxContainer/HBoxContainer.rect_size.x
var number_of_vbox = int(x / 190)
var hbox = $VBoxContainer/PanelContainer/ScrollContainer/VBoxContainer/HBoxContainer

for c in hbox.get_children():
	c.queue_free()
	
for n in range(number_of_vbox):
	var vbox = VBoxContainer.new()
	hbox.add_child(vbox)
	var card_new = card.instance()
	vbox.add_child(card_new)

func _on_resized():
create_vboxes()

Aguilera answered 2/12, 2023 at 7:56 Comment(0)
V
0

Aguilera instance() is called instantiate() in Godot 4.

In general it is advisable to use Godot 3 for older projects unless you know what you are doing.

Vinegar answered 2/12, 2023 at 10:33 Comment(0)
P
0

Aguilera he was using godot 3
And I am using godot 4.2 stable.

As Toxe said, that's not a good idea if you're new to Godot. It's best to use the same Godot version as the tutorial.

Picked answered 2/12, 2023 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.